[Engine] Qwen4: a tool call written inline inside the thinking is dropped (the answer comes back reasoning-only, stop_reason "stop")
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 79/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
issue では、保留中の呼び出しを処理する際の serve/frontend.py にある OutputParser._feed() の reasoning state が示されています。まずその分岐を読み、issue にある parser のみの再現手順を、インラインと改行の tool call で実行してください。両方のケースで、拒否せずに2つの tool call が出力されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
[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).
- 主要言語
- C++
- スター
- 11.6k
- フォーク
- 1k
- 平均マージ
- 4日 17時間
- マージ済み PR(30日)
- 28
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Niko1221/Strata のほかの issue
-
[Benchmark] RX 6900 XT (gfx1030): Linux rx6000 package runs Qwen4-35B-A3B Balanced, 60 tok/s decodeオープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 3 日以内に返信
-
[GUI] Status page: Speculation line prints "MTP drafts up to NaN tokens" on the strata-q4-lite hostオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Niko1221/Strata#7970 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Niko1221/Strata#7922 · コメント 3 件 · リアクション 3 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Niko1221/Strata#7895 · コメント 3 件 ·
メンテナーはふだん 3 日以内に返信
Niko1221/Strata の issue をすべて見る
似ている issue
-
RTL-SDR: re-enumerating while streaming removes the in-use entry from the device selection dialog対応中かも @dpc00 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
throneproj/Throne#2227 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
メンテナーはふだん 1 日以内に返信