openclaw - 💡(How to fix) Fix [Bug]: valid tool call XML in LLM reasoning block is sometimes executed by gateway

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

If the reasoning (thinking) output of the LLM contains valid tool XML syntax, it'll be executed - at least under certain circumstances.

Root Cause

If the reasoning (thinking) output of the LLM contains valid tool XML syntax, it'll be executed - at least under certain circumstances.

RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

If the reasoning (thinking) output of the LLM contains valid tool XML syntax, it'll be executed - at least under certain circumstances.

Steps to reproduce

  1. Start OC 2026.5.20 - or any .5.18 and beyond - I didn't notice it in .5.12, select an LLM that produces reasoning/thinking output.
  2. Request a series of tool calls be done. I asked it to sequentially execute "sleep 5" 30 times.
  3. My observation is it'll always just stop somewhere short of 30. On examination, the tool turn in which it stopped shows a reasoning block that contains valid tool XML.

Expected behavior

Tool XML in the reasoning block should be unconditionally ignored.

Actual behavior

At some point, the model generates <function=exec>...</function> XML syntax inside its thinking block (planning to make tool calls). The API returns stopReason: "stop" or "length" instead of "toolUse". The gateway parses the XML from the thinking block as real tool calls.

The API returns stopReason: "stop" or "length" instead of "toolUse". The gateway parses the XML from the thinking block as real tool calls. This would happen when the LLM is replying with text but not intending to run a tool call - however there is tool XML in its reasoning block.

I don't think this is bad behavior on the part of the model. That said,, I don't know why the gateway would do anything but ignore the entirety of any reasoning block, as it's not itself intended to be actionable.

OpenClaw version

2026.5.20

Operating system

Ubuntu 24.04

Install method

npm global

Model

Qwen3.6-35B-A3B

Provider / routing chain

openclaw -> llama.cpp (openai-completions API)

Additional provider/model setup details

In non-thinking modes (reasoning_content blocks) absent, this doesn't happen. I recently began using the thinking-coding mode of Qwen3.6 around the time of upgrading to 2026.5.18+, then started noticing turns with many tool calls would almost always abort on their own after a minute or two - go quiet for no discernable reason. On further inspection, the (tool) turn on which the abort happened was always the model thinking and including in its reasoning_content blocks some valid tool XML.

Logs, screenshots, and evidence

Impact and severity

Affected: users of models with reasoning enabled Severity: causes unpredictable aborts of turns with tool calls Frequency: I can consistently recreate this. Turns with more than 15 or so tool calls will almost always abort. It's just a matter of the LLM outputting some tool XML in its reasoning block - which happens sooner or later with at least my model. Consequence: The turn/task stalls and I have to manually continue it, sometimes several times.

Additional information

I believe this is likely a post 2026.5.12 regression, though am not 100% sure.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Tool XML in the reasoning block should be unconditionally ignored.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING