zed-industries/zed · error

Streaming not supported with batching client

Error message

Streaming not supported with batching client

What it means

Thrown by AnthropicClient::generate_streaming when the client is the AnthropicClient::Batch variant. The enum wraps either a plain (interactive request/response) client or a batching client that only submits jobs to Anthropic's Batch API, which is inherently non-streaming — results arrive only after the whole batch completes. Calling a streaming API on it is a programming error, so it bails immediately.

Source

Thrown at crates/edit_prediction_cli/src/anthropic_client.rs:836

    #[allow(dead_code)]
    pub async fn generate_streaming<F>(
        &self,
        model: &str,
        max_tokens: u64,
        messages: Vec<Message>,
        on_progress: F,
    ) -> Result<Option<AnthropicResponse>>
    where
        F: FnMut(usize, &str),
    {
        match self {
            AnthropicClient::Plain(plain_llm_client) => plain_llm_client
                .generate_streaming(model, max_tokens, messages, on_progress)
                .await
                .map(Some),
            AnthropicClient::Batch(_) => {
                anyhow::bail!("Streaming not supported with batching client")
            }
            AnthropicClient::Dummy => panic!("Dummy LLM client is not expected to be used"),
        }
    }

    pub async fn sync_batches(&self) -> Result<()> {
        match self {
            AnthropicClient::Plain(_) => Ok(()),
            AnthropicClient::Batch(batching_llm_client) => batching_llm_client.sync_batches().await,
            AnthropicClient::Dummy => panic!("Dummy LLM client is not expected to be used"),
        }
    }

    pub fn pending_batch_count(&self) -> Result<usize> {
        match self {
            AnthropicClient::Plain(_) => Ok(0),
            AnthropicClient::Batch(batching_llm_client) => {
                batching_llm_client.pending_batch_count()

View on GitHub (pinned to f4178619ac)

Solutions

  1. Use AnthropicClient::Plain (non-batching provider/flag) when you need streaming progress
  2. Switch the call site to the non-streaming generate() plus sync_batches() flow for batch runs
  3. Guard call sites with a variant check before choosing the streaming path (see typeGuard below)

Example fix

// before
let output = client.generate_streaming(model, max_tokens, messages, on_progress).await?;

// after
let output = match &client {
    AnthropicClient::Plain(_) => client.generate_streaming(model, max_tokens, messages, on_progress).await?,
    _ => client.generate(model, max_tokens, messages).await?,
};
Defensive patterns

Strategy: type-guard

Type guard

fn supports_streaming(client: &AnthropicClient) -> bool {
    matches!(client, AnthropicClient::Plain(_))
}

Try / catch

match client.generate_streaming(model, max_tokens, messages, on_progress).await {
    Err(e) if e.to_string().contains("Streaming not supported") => {
        // fall back to the batch flow: generate + sync_batches
        let out = client.generate(model, max_tokens, messages).await?;
        client.sync_batches().await?;
        Ok(Some(out))
    }
    other => other,
}

Prevention

When it happens

Trigger: Constructing the CLI with a batching Anthropic client (e.g. a --provider that uses batch mode / --sync-batches flow) and then invoking generate_streaming(), which the Plain arm maps to streaming and the Batch arm rejects. The Dummy variant panics instead.

Common situations: Switching an edit_prediction_cli training/eval run from a non-batching teacher provider to a batching one while keeping a streaming progress callback path; refactoring call sites so a batch client leaks into a streaming code path.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/3fb8fc334a5088f9. Report an issue: GitHub.