zed-industries/zed · error · LanguageModelCompletionError
Anthropic ended the stream without finishing its compaction…
Error message
Anthropic ended the stream without finishing its compaction summary
What it means
On Event::MessageStop the Anthropic mapper found a compaction content block that was started but never closed with a finishing delta; Anthropic closes every block before message stop, so an unclosed compaction block means the stream was truncated or malformed and the compaction summary cannot be used.
Solutions
- Retry the compaction request to get a complete stream
- Retain the pre-compaction context when the summary is incomplete so history is not lost
- Log the raw event sequence and report persistent truncation to Anthropic
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/anthropic/src/completion.rs:736 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/5d0e246e7700a5cc.
Report an issue: GitHub.
Appendix: source
Thrown at crates/anthropic/src/completion.rs:739
"end_turn" => StopReason::EndTurn,
"max_tokens" => StopReason::MaxTokens,
"tool_use" => StopReason::ToolUse,
"refusal" => StopReason::Refusal,
"compaction" => StopReason::EndTurn,
_ => {
log::error!("Unexpected anthropic stop_reason: {stop_reason}");
StopReason::EndTurn
}
};
}
vec![Ok(LanguageModelCompletionEvent::UsageUpdate(
convert_usage(&self.usage),
))]
}
Event::MessageStop => {
// Anthropic closes every content block before ending the
// message, so an unclosed compaction block means the stream
// was malformed and its finalized summary never arrived.
// Consumers would otherwise see `Started` with no terminal
// event and treat the compaction as still in progress.
if !self.compactions_by_index.is_empty() {
self.compactions_by_index.clear();
return vec![Err(LanguageModelCompletionError::Other(anyhow::anyhow!(
"Anthropic ended the stream without finishing its compaction summary"
)))];
}
vec![Ok(LanguageModelCompletionEvent::Stop(self.stop_reason))]
}
Event::Error { error } => {
vec![Err(completion_error_from_anthropic_api(
error,
self.provider_name.clone(),
))]
}
_ => Vec::new(),
}View on GitHub (pinned to 916fc2b8cb)