zed-industries/zed · error · LanguageModelCompletionError
Anthropic streamed a compaction delta before starting its…
Error message
Anthropic streamed a compaction delta before starting its content block
What it means
Anthropic's event mapper received a ContentDelta::CompactionDelta before any compaction content block was opened by a ContentBlockStart event; per the streaming protocol compaction deltas only validly arrive inside an open block, so the mapper treats this as a malformed stream and rejects it immediately in map_event.
Solutions
- Retry the completion/compaction request — malformed streams are typically transient provider-side glitches
- Track block state strictly: ignore or buffer deltas that arrive before their ContentBlockStart rather than failing the whole stream
- Report the inconsistency to the provider if it reproduces with a captured raw event trace
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/anthropic/src/completion.rs:600 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/59a441313bdfa394.
Report an issue: GitHub.
Appendix: source
Thrown at crates/anthropic/src/completion.rs:603
}
},
Event::ContentBlockDelta { index, delta } => match delta {
ContentDelta::TextDelta { text } => {
vec![Ok(LanguageModelCompletionEvent::Text(text))]
}
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 {View on GitHub (pinned to 916fc2b8cb)