[Engine] Qwen4: a tool call written inline inside the thinking is dropped (the answer comes back reasoning-only, stop_reason "stop")
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 79/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- backend-api-design
Research direction
The issue points to serve/frontend.py, in OutputParser._feed()'s reasoning state while pending calls are handled. Start by reading that branch and run the parser-only reproduction from the issue with inline and newline tool calls. Done means both cases emit the two tool calls without refusing them.
Written by the indexing model from the issue text.
Description
[Engine] Qwen4: a tool call written inline inside the thinking is dropped (the answer comes back reasoning-only, stop_reason "stop")
What happens
Serving Qwen4-35B-A3B UD-Q4_K_XL through the Anthropic /v1/messages route, with thinking enabled and tools declared, the model sometimes writes its tool calls inside the thinking block and never closes the thinking. When the first <tool_call> of such a run is written inline (no newline between the preceding sentence and <tool_call>), Strata's parser refuses the calls: the client receives an assistant message with a single reasoning block and stop_reason: "stop".
An agent client (Claude-Code-style) sees "no tool call, answer finished" and ends the turn; the user has to type "continue" every time. In one real session this happened on 3 of the last 11 assistant steps (the session had 7 turns / 38 steps in total; each failing reply was 3.5-4.5k tokens, almost all thinking).
Minimal reproduction (parser only, no model needed)
import sys
sys.path.insert(0, "<control-0.1.74>") # /root/.local/share/strata/components/control/0.1.74
import os
os.chdir("<control-0.1.74>")
from serve import frontend
C1 = ("<tool_call>\n<function=read>\n<parameter=file_path>\n/etc/hostname\n"
"</parameter>\n</function>\n</tool_call>")
C2 = ("<tool_call>\n<function=grep>\n<parameter=pattern>\nPRIVATE_KEY\n"
"</parameter>\n</function>\n</tool_call>")
tools = [{"name": "read", "description": "", "input_schema": {"type": "object"}},
{"name": "grep", "description": "", "input_schema": {"type": "object"}}]
for name, text in {
"inline": "Let me check." + C1 + C2, # <tool_call> on the same line as the text
"newline": "Let me check.\n" + C1 + C2,
}.items():
p = frontend.OutputParser(thinking=True, tools=tools, stream_tools=False, recover=True)
ev = p.feed(text)
out = p.finish(None)
calls = [e for e in list(ev) + list(out) if getattr(e, "kind", None) == "tool_call"]
print(f"{name:8s} rescued={p.rescued} refused={p.refused} calls={len(calls)}")
Actual on control 0.1.74:
inline rescued=0 refused=2 calls=0
newline rescued=2 refused=0 calls=2
Expected: both cases deliver the 2 calls (the model meant both as actions; the turn ends right after them).
Why
In serve/frontend.py, OutputParser._feed(), the elif self.state == "reasoning": if self.pending: branch holds calls found in the reasoning until </think> or the end of the turn. When parsing a wrapped call, the code can leave the call's own </tool_call> in self.buf (the drop = 0 path, which happens when the call is written inline). On the next loop the pending-call branch sees a buffer that starts with </tool_call> — not <tool_call>, not </think>, not a bare <function= — and takes the final else: self._release(False), i.e. it decides the calls were quoted prose and returns them as reasoning text.
Suggested patch
In serve/frontend.py, _feed(), inside the elif self.state == "reasoning": if self.pending: branch, right after if not self.buf: return out:
if not self.buf:
return out
+ if self.buf.startswith(CALL_END): # the closer of the call just stored
+ self.buf = self.buf[len(CALL_END):]
+ continue
bare = self._bare_in_reasoning() if self.recover and self.schemas else None
With that line, the reproduction above prints rescued=2 refused=0 for both rows, and a live Anthropic request with thinking: {type: "enabled", budget_tokens: 31999} plus a declared read tool returns stop_reason: "tool_use" with the correct tool_use block.
Impact
Any Anthropic/OpenAI client that relies on tool calls in the answer: a reasoning-only answer is indistinguishable from "the model finished", so the turn ends early. The Anthropic route is the one Claude-Code-style harnesses use.
Environment
- Strata / Control 0.2.26 / 0.1.74 (the parser lives in Control's
serve/frontend.py) - Model Qwen4-35B-A3B UD-Q4_K_XL (Unsloth GGUF), engine
q4_lite 0.1.74-linux-x86_64-cuda-cuda12 - Tesla V100-SXM2-32GB, Linux, driver 580.196.07
- Request: Anthropic
/v1/messages,thinking: {type: "enabled", budget_tokens: 31999}(→ efforthigh), tools declared - Client: DeepSeek Harness agent (Anthropic provider)
Workaround
Patch the parser as above (the running server picks it up after a restart), or make sure the model starts every <tool_call> on a new line (not reliable — the model chooses).
- Dominant language
- C++
- Stars
- 11.6k
- Forks
- 1k
- Avg merge
- 4d 17h
- Merged PRs (30d)
- 28
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Niko1221/Strata
-
[Benchmark] RX 6900 XT (gfx1030): Linux rx6000 package runs Qwen4-35B-A3B Balanced, 60 tok/s decodeOpen
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 3 days
-
[GUI] Status page: Speculation line prints "MTP drafts up to NaN tokens" on the strata-q4-lite hostOpen
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Niko1221/Strata#7970 · 2 comments ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Niko1221/Strata#7922 · 3 comments · 3 reactions ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Niko1221/Strata#7895 · 3 comments ·
Maintainers usually reply within 3 days
Similar issues
-
RTL-SDR: re-enumerating while streaming removes the in-use entry from the device selection dialogPossibly taken @dpc00 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
throneproj/Throne#2227 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
Maintainers usually reply within 1 day