[Engine] serve/frontend.py: recover missing '>' before newline and minor low-bit tool-name stutters in <function=NAME> (including streaming _scan)
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
調査の方向性
terminal/serve/frontend.py から始め、parse_tool_call()、_callable()、_scan()、_finish_call() に集中してください。次に、既存の terminal/serve のユニットテストを実行します。提案されているスキーマのホワイトリストに基づく名前の復旧を実装し、最初のパラメーターの前に > がない場合も許容してください。不正なストリーミングおよび非ストリーミングのケースが成功し、未宣言の名前が引き続き拒否され、既存の terminal/serve のテストがすべて成功すれば完了とします。
索引モデルが issue の本文から書いたものです。
説明
Problem
When serving low-bit quantizations (e.g. Qwen3.8-Flash-Next IQ3_S) to OpenAI-compatible tool-calling clients / coding agents with recover=True, two minor, unambiguously repairable <function=NAME> formatting glitches still fail parsing in terminal/serve/frontend.py and leak raw <tool_call> markup into assistant text (terminating the agent turn):
-
Missing
>before newline in<function=NAME>:<tool_call> <function=bash <parameter=command>echo ok</parameter> </function> </tool_call>Both
parse_tool_call()and_finish_call()require>to exist and appear before the first<parameter=...>. When the model omits>and immediately emits\n<parameter=...>,parse_tool_call()raisesmalformed tool call(or splits on the>inside<parameter=...>), corrupting the tool name and dropping the call. -
Minor quantization stutters in
<function=NAME>(and missing recovery in streaming_scan()):
Under low-bit quantizations, the model occasionally emits a single-character stutter or trailing delimiter on an otherwise valid declared tool name, such as:- Trailing punctuation or accidental
=param:<function=bash,>,<function=bash=command> - Doubled leading character:
<function=ggrep_text>(for declaredgrep_text) - Single-letter + underscore stutter prefix:
<function=p_present_files>(for declaredpresent_files)
Currently
_callable(), streaming_scan(), and_finish_call()only do.strip()+ alias lookup, so these calls are rejected and leaked as plain text even when the repaired name uniquely matches a declared tool inself.schemas. - Trailing punctuation or accidental
(Related to but distinct from #6022 [hallucinated undeclared names] and #6979 [argument name typos]. Checked v0.2.23: neither fix is present in terminal/serve/frontend.py yet.)
Proposed Fix (minimal, strictly whitelisted to schemas)
Add a conservative helper _recover_declared_name(raw, schemas, aliases) that only accepts a repaired name when it matches a declared tool in schemas (never invents an undeclared tool), and wire it into parse_tool_call(), _callable(), streaming _scan(), and _finish_call() when recover=True:
def _recover_declared_name(raw: str, schemas: dict | None, aliases: dict | None = None) -> str:
"""Safely repair minor low-bit quantization stutters in `<function=NAME>` ONLY when the repaired name
uniquely matches a declared tool in `schemas` (e.g. `ggrep_text` -> `grep_text`, `p_present_files` -> `present_files`,
`bash,` or `bash=command` -> `bash`). Never invents an undeclared tool."""
name = raw.strip()
if aliases:
name = aliases.get(name, name)
if not schemas or name in schemas:
return name
# 1. Strip stray trailing punctuation or `=param` (e.g. `bash,`, `bash=command`)
cand = re.split(r"[,;:\s=]", name, maxsplit=1)[0].strip()
if cand and cand in schemas:
return cand
# 2. Doubled leading letter stutter (e.g. `ggrep_text` -> `grep_text`)
if len(name) >= 3 and name[0] == name[1] and name[1:] in schemas:
return name[1:]
# 3. Single-letter + underscore stutter prefix (e.g. `p_present_files` -> `present_files`)
if len(name) >= 4 and name[1] == "_" and name[2:] in schemas and name[0] == name[2]:
return name[2:]
return name
Key wiring changes (diff against v0.2.17 terminal/serve/frontend.py):
parse_tool_call()&_finish_call(): whenrecover=Trueand\noccurs before>(or>is missing before\n), slice the function name at\ninstead of failing or slicing into<parameter=...>._callable(): returnTrueifself.recover and _recover_declared_name(name, self.schemas, self.aliases) in self.schemas.- Streaming
_scan()&_finish_call(): resolvename = _recover_declared_name(raw_name, self.schemas, self.aliases) if self.recover else ....
Verification
- Running in daily production for 1 week on Windows 11 + RTX 4070 Ti (12 GB) +
Qwen3.8-Flash-Next IQ3_S(strata 0.1.63->0.1.65->0.1.70) with OpenAI-compatible coding agents. - Passed 12/12 new malformed-call unit cases (both streaming and non-streaming, including negative cases verifying undeclared names are still rejected) and 72/72 existing
terminal/serveunit tests. - Zero leaked
<tool_call>blocks observed since applying this patch.
- 主要言語
- C++
- スター
- 11.6k
- フォーク
- 1k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Niko1221/Strata のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Niko1221/Strata#7537 · コメント 3 件 ·
メンテナーはふだん 4 日以内に返信
-
[TUI] --list-presets prints "not tuned" for Inkling-2-Mini presets対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
Niko1221/Strata#7507 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
-
needs-format
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Niko1221/Strata#7490 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Niko1221/Strata#7365 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
Niko1221/Strata の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 87/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ros-navigation/navigation2#6883 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`libdbgshim` crashes in `MachOModule::ReadSymbolTable` on macOS 27 when a Metal app is attachedオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dotnet/diagnostics#6293 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信