{"record":{"id":"d3bfbe7f8fe7876f","repo":"zed-industries/zed","slug":"anyhow-error-new-error-tool-call-entry-confli","errorCode":null,"errorMessage":"anyhow::Error::new(error) — tool call entry conflict error pushed as completion event (message from error)","messagePattern":"anyhow::Error::new\\(error\\) — tool call entry conflict error pushed as completion event \\(message from error\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/language_model_core/src/chat_completion.rs","lineNumber":496,"sourceCode":"            if let Some(reasoning_content) = delta.reasoning_content.clone() {\n                push_thinking_event(reasoning_content, &mut events);\n            }\n            if let Some(content) = delta.content.clone() {\n                if !content.is_empty() {\n                    events.push(Ok(LanguageModelCompletionEvent::Text(content)));\n                }\n            }\n\n            if !self.tool_call_accumulation_failed\n                && let Some(tool_calls) = delta.tool_calls.as_ref()\n            {\n                for tool_call in tool_calls {\n                    let entry = match self.tool_calls.entry(tool_call) {\n                        Ok(entry) => entry,\n                        Err(error) => {\n                            self.tool_call_accumulation_failed = true;\n                            self.tool_calls = ToolCallAccumulator::default();\n                            events.push(Err(anyhow::Error::new(error).into()));\n                            break;\n                        }\n                    };\n\n                    if let Some(function) = tool_call.function.as_ref() {\n                        if let Some(name) = function.name.clone()\n                            && !name.is_empty()\n                        {\n                            entry.name = name;\n                        }\n\n                        if let Some(arguments) = function.arguments.clone() {\n                            entry.arguments.push_str(&arguments);\n                        }\n\n                        if let Some(thought_signature) = function.thought_signature.clone() {\n                            entry.thought_signature = Some(thought_signature);\n                        }","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/language_model_core/src/chat_completion.rs#L478-L514","documentation":"Validation failure inside map_event's tool-call accumulation: an incoming tool_call delta could not be matched to (or allocated within) the accumulated tool call entries — e.g. a chunk whose id/index cannot be attributed to any accumulated call, or conflicting ids sharing an index (see the rejects_id_only_chunks_for_calls_sharing_an_id and rejects_unattributable_tool_call_chunks tests). The accumulation error is converted to anyhow::Error and pushed as an error completion event so the stream terminates instead of emitting a corrupted tool call.","triggerScenarios":"Thrown at crates/language_model_core/src/chat_completion.rs:496 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the provider's streamed tool_call chunks: every call needs a consistent id and index across its delta chunks","Ensure ids are present when a provider sends parallel tool calls that reuse indices","If chunks are genuinely malformed, surface the error event to the user rather than emitting partial tool calls"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-09-05T10:33:00.413Z","contentChangedAt":"2026-09-05T10:33:00.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}