Skip to content

Parse bare <call name="..."> blocks instead of streaming them as text - #69

Merged
dekrezz merged 2 commits into
dekrezz:mainfrom
Blue-B:fix/bare-call-markup
Nov 4, 2026
Merged

dekrezz merged 2 commits into
dekrezz:mainfrom
Blue-B:fix/bare-call-markup

Conversation

@Blue-B

@Blue-B Blue-B commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • DeepSeek Web sometimes answers a tool turn with only a <call> block:
    <call name="bash">
    <parameter name="command">sed -n '215,270p;3110,3135p' server.js</parameter>
    <parameter name="timeout">20</parameter>
    </call>
    
  • No detector matches a bare <call> tag (looksLikeToolCallMarkup, hasDsmlToolMarkup, the JSON parsers), so the reply skips repair and is streamed to the client as the final answer with tools=0.
  • collectAgentToolCalls now reads <call name="..."> blocks as DSML invokes, but only when the whole reply is such blocks, so a <call> quoted in prose never runs. The result still goes through listDsmlToolCalls and the tool whitelist.
  • looksLikeToolCallMarkup flags <call name=...>, so a partial or prose-wrapped block gets the strict retry instead of leaking.

Logs

On 2026-11-03 one pi session got this shape three times within four minutes. One of them:

[01a1a018-3d89-75f7-9fdb-6a95a8148d71] Got 557 chars (+0 reasoning chars) in 1200ms (msg#28)
[01a1a018-3d89-75f7-9fdb-6a95a8148d71] Streamed openai (tools=0) in 1201ms

pi showed the <call name="bash">...</call> block above as the assistant's answer.

Testing

  • npm test: 354 pass. The one failure, with real git: check sees a new release, install fast-forwards and switches channels, local edits are kept, fails the same way on main on this machine.
  • tests/parser_bare_call.test.js: 4 cases. The captured reply, two blocks in a row, a tool the client did not offer (dropped), and a <call> inside prose (not executed, but detected). 3 of 4 fail on main.
  • Live: pi through the patched proxy completed a bash tool call and its final answer. The <call> shape cannot be triggered on demand, so that path is only covered by the captured reply.

DeepSeek Web sometimes answers a tool turn with only
<call name="bash"><parameter name="command">...</parameter></call>.
No detector matched a bare <call> tag, so the reply skipped repair and
reached the client as the final answer.

- collectAgentToolCalls reads <call> blocks as DSML invokes, but only
  when the whole reply is such blocks, so a <call> quoted in prose never
  runs. Results still go through the DSML parser and the tool whitelist.
- looksLikeToolCallMarkup flags <call name=...> so a partial or
  prose-wrapped block gets the stricter retry instead of leaking.
@Blue-B
Blue-B requested a review from dekrezz as a code owner November 3, 2026 07:15
Literal </call>, <invoke or a JSON tool envelope inside a value no longer loses or replaces the call, and values keep their entities. looksLikeToolCallMarkup now needs <call ...> followed by <parameter, so <Call name="x" /> in an answer stays text. Native tools in <call> take the native repair path.
@dekrezz
dekrezz enabled auto-merge November 4, 2026 16:26
@dekrezz

dekrezz commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution. The captured reply in the description made the problem easy to follow.

I pushed a follow-up commit on your branch. Next time you touch the parser, please try values that contain the markup itself, like grep "</call>" or grep "<invoke", and a JSON tool call inside a parameter. Those are what broke the regex version. Also keep detection narrow enough that <Call name="x" /> in a normal answer doesn't end in a 502.

@dekrezz
dekrezz merged commit cf48ec2 into dekrezz:main Nov 4, 2026
2 checks passed
@dekrezz dekrezz mentioned this pull request Nov 4, 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