Skip to content

fix(tool_parser): support XML function_call and tool_call with invoke_name and parameters - #671

Merged
davide221 merged 5 commits into
Luce-Org:mainfrom
dpavlin:fix/tool-parser-function-call-xml
Aug 28, 2026
Merged

fix(tool_parser): support XML function_call and tool_call with invoke_name and parameters#671
davide221 merged 5 commits into
Luce-Org:mainfrom
dpavlin:fix/tool-parser-function-call-xml

Conversation

@dpavlin

@dpavlin dpavlin commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #670

Summary

During multi-turn tool-calling sessions with DeepSeek-V4 (e.g., autonomous coding agents), the model may output tool calls wrapped in XML <function_call> or <tool_call> envelopes with <invoke_name> and <parameters> tags:

<function_call>
<invoke_name>read</invoke_name>
<parameters>
<path>/home/dpavlin/koha-rfid-go/internal/rfidops/ops.go</path>
</parameters>
</function_call>

Previously, Pattern 4b and Pattern 8 in tool_parser.cpp did not handle XML parameter blocks, leading to parse_tool_calls returning 0 calls, suppressing buffered tool text, and emitting an empty stop response to the client.

Changes

  1. Added helper parse_xml_tool_call_body() in server/src/server/tool_parser.cpp:
    • Identifies tool name from <invoke_name>, <name>, <tool_name>, <function_name>, or <invoke name="...">.
    • Extracts parameters from <parameters> or <arguments> sections (supporting element tags <key>val</key> and attribute style <parameter name="key">val</parameter>).
    • Coerces parameter types based on declared tool schemas.
  2. Hooked parse_xml_tool_call_body() into Pattern 4b (<function_call>) and Pattern 8 (<tool_call>).
  3. Added comprehensive unit tests to server/test/test_server_unit.cpp covering single and multi-argument XML function/tool calls.

Verification

  • test_server_unit: 426/426 passed.
  • Verified on live DeepSeek-V4 Flash ROCm server with streaming SSE requests and agent workflows.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/server/tool_parser.cpp Outdated
Comment thread server/src/server/tool_parser.cpp Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/server/tool_parser.cpp Outdated
@davide221
davide221 merged commit 136ad9c into Luce-Org:main Aug 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeepSeek V4 tool parser fails on XML <function_call> with <invoke_name> and suppresses response

2 participants