{"record":{"id":"06404549f1d4b21c","repo":"zed-industries/zed","slug":"response-completed-with-an-unfinished-compaction-i","errorCode":null,"errorMessage":"response completed with an unfinished compaction item","messagePattern":"response completed with an unfinished compaction item","errorType":"exception","errorClass":"LanguageModelCompletionError","httpStatus":null,"severity":"error","filePath":"crates/open_ai/src/completion.rs","lineNumber":1089,"sourceCode":"            | ResponsesStreamEvent::Unknown => Vec::new(),\n        }\n    }\n\n    fn begin_reasoning_summary_part(\n        &mut self,\n        item_id: &str,\n        summary_index: usize,\n    ) -> Vec<Result<LanguageModelCompletionEvent, LanguageModelCompletionError>> {\n        let part = (item_id.to_string(), summary_index);\n        if self.current_reasoning_summary_part.as_ref() == Some(&part) {\n            return Vec::new();\n        }\n\n        let separator = self.current_reasoning_summary_part.replace(part).is_some();\n        if separator {\n            vec![Ok(LanguageModelCompletionEvent::Thinking {\n                text: \"\\n\\n\".to_string(),\n                signature: None,\n            })]\n        } else {\n            Vec::new()\n        }\n    }\n\n    fn handle_completion(\n        &mut self,\n        response: ResponsesSummary,\n        default_reason: StopReason,\n    ) -> Vec<Result<LanguageModelCompletionEvent, LanguageModelCompletionError>> {\n        // A compaction item that was added but never done means the server\n        // already pruned its context, but we never received the canonical\n        // replacement window. Continuing as if the turn succeeded would\n        // leave the conversation unable to continue coherently.\n        if self.pending_compaction_items > 0 {\n            return vec![Err(LanguageModelCompletionError::Other(anyhow!(\n                \"response completed with an unfinished compaction item\"","sourceCodeStart":1071,"sourceCodeEnd":1107,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/open_ai/src/completion.rs#L1071-L1107","documentation":"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.","triggerScenarios":"Thrown at crates/open_ai/src/completion.rs:1364 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the turn/request","If it persists, start a fresh thread to rebuild context without the broken compaction state","Check OpenAI Responses API status"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}