{"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":301,"sourceCode":"            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                }\n            }\n\n            // Stream ended without a complete tool use\n            Err(LanguageModelCompletionError::Other(anyhow::anyhow!(\n                \"Stream ended without receiving a complete tool use\"\n            )))\n        }\n        .boxed()\n    }\n\n    #[cfg(any(test, feature = \"test-support\"))]\n    fn as_fake(&self) -> &fake_provider::FakeLanguageModel {\n        unimplemented!()\n    }\n}\n\nimpl std::fmt::Debug for dyn LanguageModel {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        f.debug_struct(\"<dyn LanguageModel>\")\n            .field(\"id\", &self.id())\n            .field(\"name\", &self.name())\n            .field(\"provider_id\", &self.provider_id())","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/language_model/src/language_model.rs#L283-L319","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":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}