zed-industries/zed · error · anyhow::Error

anyhow::Error::new(error) — tool call entry conflict error p

Error message

anyhow::Error::new(error) — tool call entry conflict error pushed as completion event (message from error)

What it means

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.

Source

Thrown at crates/language_model_core/src/chat_completion.rs:496

            if let Some(reasoning_content) = delta.reasoning_content.clone() {
                push_thinking_event(reasoning_content, &mut events);
            }
            if let Some(content) = delta.content.clone() {
                if !content.is_empty() {
                    events.push(Ok(LanguageModelCompletionEvent::Text(content)));
                }
            }

            if !self.tool_call_accumulation_failed
                && let Some(tool_calls) = delta.tool_calls.as_ref()
            {
                for tool_call in tool_calls {
                    let entry = match self.tool_calls.entry(tool_call) {
                        Ok(entry) => entry,
                        Err(error) => {
                            self.tool_call_accumulation_failed = true;
                            self.tool_calls = ToolCallAccumulator::default();
                            events.push(Err(anyhow::Error::new(error).into()));
                            break;
                        }
                    };

                    if let Some(function) = tool_call.function.as_ref() {
                        if let Some(name) = function.name.clone()
                            && !name.is_empty()
                        {
                            entry.name = name;
                        }

                        if let Some(arguments) = function.arguments.clone() {
                            entry.arguments.push_str(&arguments);
                        }

                        if let Some(thought_signature) = function.thought_signature.clone() {
                            entry.thought_signature = Some(thought_signature);
                        }

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Inspect the provider's streamed tool_call chunks: every call needs a consistent id and index across its delta chunks
  2. Ensure ids are present when a provider sends parallel tool calls that reuse indices
  3. If chunks are genuinely malformed, surface the error event to the user rather than emitting partial tool calls
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/language_model_core/src/chat_completion.rs:496 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-09-05). Data as JSON: /api/errors/d3bfbe7f8fe7876f. Report an issue: GitHub.