zed-industries/zed · error · LanguageModelCompletionError

response completed with an unfinished compaction item

Error message

response completed with an unfinished compaction item

What it means

Stream-consistency error in handle_completion: the Responses stream ended while a compaction item had been added but never completed, meaning the server pruned context without delivering the canonical replacement window. Treating the turn as successful would desynchronize local context, so it errors instead.

Source

Thrown at crates/open_ai/src/completion.rs:1089

            | ResponsesStreamEvent::Unknown => Vec::new(),
        }
    }

    fn begin_reasoning_summary_part(
        &mut self,
        item_id: &str,
        summary_index: usize,
    ) -> Vec<Result<LanguageModelCompletionEvent, LanguageModelCompletionError>> {
        let part = (item_id.to_string(), summary_index);
        if self.current_reasoning_summary_part.as_ref() == Some(&part) {
            return Vec::new();
        }

        let separator = self.current_reasoning_summary_part.replace(part).is_some();
        if separator {
            vec![Ok(LanguageModelCompletionEvent::Thinking {
                text: "\n\n".to_string(),
                signature: None,
            })]
        } else {
            Vec::new()
        }
    }

    fn handle_completion(
        &mut self,
        response: ResponsesSummary,
        default_reason: StopReason,
    ) -> Vec<Result<LanguageModelCompletionEvent, LanguageModelCompletionError>> {
        // A compaction item that was added but never done means the server
        // already pruned its context, but we never received the canonical
        // replacement window. Continuing as if the turn succeeded would
        // leave the conversation unable to continue coherently.
        if self.pending_compaction_items > 0 {
            return vec![Err(LanguageModelCompletionError::Other(anyhow!(
                "response completed with an unfinished compaction item"

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Retry the turn/request
  2. If it persists, start a fresh thread to rebuild context without the broken compaction state
  3. Check OpenAI Responses API status
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/open_ai/src/completion.rs:1364 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20). Data as JSON: /api/errors/06404549f1d4b21c. Report an issue: GitHub.