{"record":{"id":"f3a63c6fc4bef06c","repo":"zed-industries/zed","slug":"stream-ended-without-receiving-a-complete-tool-use","errorCode":null,"errorMessage":"Stream ended without receiving a complete tool use","messagePattern":"Stream ended without receiving a complete tool use","errorType":"exception","errorClass":"LanguageModelCompletionError","httpStatus":null,"severity":"error","filePath":"crates/language_model/src/language_model.rs","lineNumber":337,"sourceCode":"                    }\n                }))\n                .boxed();\n\n            Ok(LanguageModelTextStream {\n                message_id,\n                stream,\n                last_token_usage,\n            })\n        }\n        .boxed()\n    }\n\n    fn stream_completion_tool(\n        &self,\n        request: LanguageModelRequest,\n        cx: &AsyncApp,\n    ) -> BoxFuture<'static, Result<LanguageModelToolUse, LanguageModelCompletionError>> {\n        let future = self.stream_completion(request, cx);\n\n        async move {\n            let events = future.await?;\n            let mut events = events.fuse();\n\n            // Iterate through events until we find a complete ToolUse\n            while let Some(event) = events.next().await {\n                match event {\n                    Ok(LanguageModelCompletionEvent::ToolUse(tool_use))\n                        if tool_use.is_input_complete =>\n                    {\n                        return Ok(tool_use);\n                    }\n                    Err(err) => {\n                        return Err(err);\n                    }\n                    _ => {}\n                }","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/language_model/src/language_model.rs#L319-L355","documentation":"Raised in stream_completion_tool after draining the entire completion event stream: no event carried a ToolUse with is_input_complete (complete tool inputs), yet the caller expected the model to invoke a tool. The model ended its turn with plain text, a stop, or an incomplete tool use instead of delivering a finished tool call, so the tool-use contract of the request was violated.","triggerScenarios":"Thrown at crates/language_model/src/language_model.rs:301 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request — models occasionally omit the expected tool call","Check that the request actually requires a tool (tool_choice forced) and the tools are correctly advertised","Inspect the stream events for incomplete ToolUse chunks or a Stop reason explaining the early end","Reduce prompt complexity or max_tokens constraints that may end the turn before the tool call completes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}