zed-industries/zed · error
Anthropic streamed a compaction delta before starting its co
Error message
Anthropic streamed a compaction delta before starting its content block
What it means
Raised inside the Anthropic streaming state machine. Compaction blocks are registered in compactions_by_index when their content_block_start event arrives; a CompactionDelta for an index with no registered block means the SSE stream is malformed (delta before block start), so the adapter errors instead of writing into a missing block.
Source
Thrown at crates/anthropic/src/completion.rs:542
}
ContentDelta::ThinkingDelta { thinking } => {
vec![Ok(LanguageModelCompletionEvent::Thinking {
text: thinking,
signature: None,
})]
}
ContentDelta::SignatureDelta { signature } => {
vec![Ok(LanguageModelCompletionEvent::Thinking {
text: "".to_string(),
signature: Some(signature),
})]
}
ContentDelta::CompactionDelta {
content,
encrypted_content,
} => {
let Some(compaction) = self.compactions_by_index.get_mut(&index) else {
return vec![Err(LanguageModelCompletionError::Other(anyhow::anyhow!(
"Anthropic streamed a compaction delta before starting its content block"
)))];
};
// Unlike summary text, `encrypted_content` arrives whole:
// a later delta carries a complete replacement value, not
// a chunk to append (Anthropic's own SDKs assign it, the
// way they do thinking signatures).
if let Some(encrypted_content) =
encrypted_content.filter(|encrypted| !encrypted.is_empty())
{
compaction.encrypted_content = Some(encrypted_content);
}
let Some(content) = content.filter(|content| !content.is_empty()) else {
return Vec::new();
};
compaction.summary.push_str(&content);
vec![Ok(LanguageModelCompletionEvent::Compaction(
CompactionUpdate::SummaryDelta(content),View on GitHub (pinned to bc538def45)
Solutions
- Retry the request - transient stream corruption usually replays cleanly on a fresh stream.
- Remove or reconfigure proxies/gateways in front of api.anthropic.com so SSE events arrive unmodified and in order.
- If reproducible with the official Anthropic SDK, capture raw SSE frames (request id, model, timestamps) and report to Anthropic.
- Temporarily disable context compaction/summarization in the client so compaction deltas are not produced.
Defensive patterns
Strategy: retry
Try / catch
while polling the completion stream, match Err(LanguageModelCompletionError::Other(e)) where e.to_string() contains "compaction delta before starting": discard partial state and re-issue the request once (bounded single retry); otherwise propagate.
Prevention
- Keep SSE connections unbuffered end-to-end (disable proxy buffering)
- Pin a known-good base URL for api.anthropic.com
- Record and replay stream fixtures covering compaction blocks in tests
When it happens
Trigger: A content_block_delta carrying ContentDelta::CompactionDelta arrives for an index whose content_block_start was never seen - dropped or reordered SSE events, a proxy rewriting the stream, or an upstream regression in Anthropic's compaction feature.
Common situations: Long-context compaction/summarization sessions on Claude; corporate proxies or LLM gateways that buffer, chunk, or reorder server-sent events; flaky connections that drop early frames.
Related errors
- Anthropic ended the stream without finishing its compaction
- unsupported Anthropic compaction state format: {}
- Claude returned no tool_use block for tool '{tool['name']}'
- Compaction produced an empty summary
- tool input was not fully received
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/59a441313bdfa394.
Report an issue: GitHub.