-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Summary
The system message tools parser (interceptSystemToolCalls.ts) assumes tool calls must appear at the end of a response — one per response, nothing after. This is an architectural constraint that doesn't exist in the tool calling paradigm itself.
Behavior
- After a tool call completes, any subsequent content is silently dropped (lines 100-103)
- A second tool call in the same response is never parsed —
parseState?.donebreaks the loop (line 49) - The system message suffix instructs models: "You can only call ONE tool at a time. You MUST stop generating after the closing codeblock"
Meanwhile the agent system message says "call multiple tools simultaneously."
Why this matters
Native tool calling APIs (OpenAI, Anthropic) allow models to interleave text and tool calls freely, and to make multiple calls in a single response. The system message tools path restricts models to a subset of that — one tool call, must be terminal — creating a capability gap that makes local models on this path appear less capable than they are.
The suffix instruction is a consequence of the parser limitation, not the other way around. The parser was built with the positional assumption, and the instruction exists to keep models inside those bounds.
Where
core/tools/systemMessageTools/interceptSystemToolCalls.ts- Line 49:
parseState?.donebreaks on second tool call - Lines 100-103: content after completed tool call dropped
- Line 49:
core/tools/systemMessageTools/toolCodeblocks/index.tssystemMessageSuffix(~line 71): "ONE tool at a time"
Context
This is a design limitation, not a simple bug. Fixing it means the parser needs to handle multiple tool calls per response, text between tool calls, and tool calls at any position. That's a meaningful rearchitecture of the stream interception logic.
Related
- System message tools parser intercepts quoted tool syntax as real tool calls #11070 — parser false positives (separate issue, but compounds this)
- System message tool prompts teach models to echo TOOL_NAME keyword #11072 — TOOL_NAME keyword echo
- LM Studio lmstudio-community/app#1592 — similar positional assumptions in their parser
Metadata
Metadata
Assignees
Labels
Type
Projects
Status