Skip to content

fix(server): Parse Bare Tool-Name XML Calls#525

Merged
davide221 merged 1 commit into
Luce-Org:mainfrom
jkyamog:fix-bare-tool-tag-compat
Jul 15, 2026
Merged

fix(server): Parse Bare Tool-Name XML Calls#525
davide221 merged 1 commit into
Luce-Org:mainfrom
jkyamog:fix-bare-tool-tag-compat

Conversation

@jkyamog

@jkyamog jkyamog commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Adds a narrow compatibility case for model output that uses the tool name as
the XML tag itself:

<bash>
<parameter=command>
grep -n "f5.test" /workspace/project/tests/bootstrap.cjs
</parameter>
</function>

Before this change, the C++ server did not parse this as a tool call. The raw
XML stayed in visible assistant text and the turn finished as normal text
instead of tool_calls / tool_use.

Bug

Observed through a Pi agent session using Lucebox as the model runtime.

The session record showed reasoning was already correctly separated:

{
  "type": "thinking",
  "thinkingSignature": "reasoning_content"
}

But the malformed tool call was left in the visible text content:

<bash>
<parameter=command>
grep -n "f5.test" /workspace/project/tests/bootstrap.cjs
</parameter>
</function>

The agent therefore displayed the tool XML as assistant text and did not run
the tool.

Change

  • Adds parser support for bare tool-name XML:

    <TOOL_NAME>
    <parameter=KEY>VALUE</parameter>
    </function>
  • Also accepts a matching generic XML close:

    </TOOL_NAME>
  • Keeps the behavior constrained:

    • only runs when request tools are present
    • only accepts names in the declared tool list
    • requires at least one <parameter=...> tag
    • reuses the existing XML parameter parser and argument JSON serialization

This avoids turning arbitrary XML-ish prose into tool calls.

Review follow-up:

  • The matching generic close is implemented as a backreference (</TOOL_NAME>)
    rather than "any XML close" so the regex cannot stop early on inner tags like
    </parameter>.
  • The fixture asserts that </function> is fully stripped from visible content.

Review in cubic

@jkyamog

jkyamog commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

I encountered this issue twice on long running Pi agent session, so I decided to fix this as it occurs frequent enough. It was using Qwen 3.6 27B Q4 model. I have then run the fix with 10M-20M more tokens and so far no tool call issues.

@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

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

Re-trigger cubic

Comment thread server/src/server/tool_parser.cpp
@jkyamog jkyamog force-pushed the fix-bare-tool-tag-compat branch from 59054e6 to 3ac6efd Compare July 14, 2026 23:20
@davide221

davide221 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fix @jkyamog 🚀

@davide221 davide221 merged commit 780d9da into Luce-Org:main Jul 15, 2026
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.

2 participants