Skip to content

Agent tool calls fail when OpenAI-compatible models return XML-like function.arguments #11453

@ChrisCalzaretta

Description

@ChrisCalzaretta

Summary

OpenAI-compatible chat models can return tool_calls[].function.arguments as XML-like payloads (e.g. <tool_call><function=...><parameter=...>). Continue currently assumes JSON-only arguments in multiple paths, which causes tool-call parsing/execution failures in Agent mode (seen as malformed fragmented tool calls and downstream index/list errors).

Reproduction

  1. Configure Continue model with OpenAI-compatible endpoint using a model that emits XML-like args (example: local Qwen OpenAI-compatible endpoint).
  2. Send a tool-heavy request (e.g., deep-dive / repository exploration).
  3. Observe returned tool call shape from model:
    • tool_calls[].function.name = "ls"
    • tool_calls[].function.arguments = "<tool_call>...<parameter=dirPath>src</parameter>..."
  4. Agent flow fails to parse/execute correctly because JSON parse returns {}.

Direct API sample observed

function.arguments returned by model:

<tool_call>
<function=ls>
<parameter=dirPath>
src
</parameter>
<parameter=recursive>
True
</parameter>
</function>
</tool_call>

Root cause

Argument parsing assumes JSON-only payloads in shared and streaming paths. When XML-like payloads are returned, parsed args become empty and required-arg validation fails.

Proposed fix

Normalize XML-like argument payloads into structured args in shared parser and use that in both GUI and CLI streaming paths.

Files changed locally

  • core/tools/parseArgs.ts
  • core/tools/parseArgs.vitest.ts
  • gui/src/util/toolCallState.ts
  • gui/src/util/toolCallState.test.ts
  • extensions/cli/src/stream/streamChatResponse.helpers.ts
  • extensions/cli/src/stream/streamChatResponse.test.ts

Behavior after fix

  • Keep existing JSON parse path unchanged.
  • If JSON parse fails, parse <parameter=name>value</parameter> entries.
  • Scalar coercion supported:
    • true/false -> boolean
    • numeric strings -> number
    • JSON-looking scalar/array/object values -> parsed when valid
    • otherwise string

Validation added

Regression tests added for XML-style tool argument parsing in core, GUI tool-call state assembly, and CLI stream processing.

Local commit refs (not yet pushed)

  • main-based branch: fix/Tool_Parsing-main, commit c89c2d170
  • release-based branch: fix/Tool_Parsing, commit 5840ed876

(Unable to push from this environment due 403 on continuedev/continue.git; creating issue with full details so maintainers can apply/cherry-pick.)

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