zed-industries/zed · error
Anthropic ended the stream without finishing its compaction
Error message
Anthropic ended the stream without finishing its compaction summary
What it means
Anthropic closes every content block before message_stop. This error fires when Event::MessageStop arrives while compactions_by_index still holds an open compaction block: the finalized summary never arrived, and consumers would otherwise see a Started compaction with no terminal event and treat it as still in progress. The partial compaction state is cleared before erroring.
Source
Thrown at crates/anthropic/src/completion.rs:677
_ => {
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(),
}
}
}
struct RawToolUse {
id: String,View on GitHub (pinned to bc538def45)
Solutions
- Retry the completion - truncation is usually transient.
- Check for proxy/VPN idle timeouts on long-lived streaming connections and raise them.
- Reduce the conversation size before compaction triggers (clear or split the thread) so summaries stay short.
- If it persists, report to Zed/Anthropic with the request id and stream log.
Defensive patterns
Strategy: retry
Try / catch
on stream end, if the final event is Err containing "without finishing its compaction summary", drop the partial compaction state and retry the completion once; otherwise surface the error to the UI layer.
Prevention
- Raise proxy/VPN idle timeouts for long SSE streams
- Trim conversation size before compaction triggers
- Watch for correlated network drops when the error repeats
When it happens
Trigger: The stream ends (MessageStop) with a compaction content block that was started but never closed - a dropped content_block_stop event, a connection cut mid-block, or upstream truncation of a long encrypted summary.
Common situations: Network interruptions during long compaction summaries; proxies that close long-lived SSE connections; very large encrypted summaries hitting server limits.
Related errors
- Anthropic streamed a compaction delta before starting its co
- 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/5d0e246e7700a5cc.
Report an issue: GitHub.