Skip to content

System message tools parser assumes tool calls are positionally terminal #11074

@shanevcantwell

Description

@shanevcantwell

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

  1. After a tool call completes, any subsequent content is silently dropped (lines 100-103)
  2. A second tool call in the same response is never parsed — parseState?.done breaks the loop (line 49)
  3. 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?.done breaks on second tool call
    • Lines 100-103: content after completed tool call dropped
  • core/tools/systemMessageTools/toolCodeblocks/index.ts
    • systemMessageSuffix (~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

Metadata

Metadata

Assignees

Labels

area:toolsRelates to tool usagekind:bugIndicates an unexpected problem or unintended behavior

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions