Repository navigation
[PR] fix: drop a tool-typed tag-echo span whole instead of keeping its fabricated body (#6557) - #6633
Conversation
…anxianglei#6557) TOOL_TYPED_OPEN's tail [^<>]*> read a self-closing imitation (<acp type="tool:…"/>) as an OPENING, so the whole-text path made it own the rest of the field (or pair it with a later orphan close) while the streaming path killed it in place via SELF_CLOSE — a whole-text/streaming divergence on the same input, the ranxianglei#4178/ranxianglei#4210 split-invariance class this channel exists to prevent, and a loss of the prose that follows the imitation. Exclude the self-closing form from the opening match (the character before the final > must not be /); it then falls through to the SELF_CLOSE pass, killed in place — the same verdict streaming already reaches, so both paths agree again. A refs-only body with a non-acplike degenerate close still owns the rest of the field in both paths: the corrupted close is not the span's terminator, consistent with the wrapped-turn EOF rule. +4 regression tests: self-close dies in place with following prose surviving (whole-text, both shapes), streaming split-invariance for the self-close shape, and a guard that a type="text" self-close keeps its following prose (SELF_CLOSE semantics unchanged). Reviewer fix-up on the PR branch: found by whole-text vs streaming differential repro during review; one-line regex change, no state-machine change.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — searched open + closed issues/PRs for a tool-typed tag-echo span fix; no other thread targets the #6557 mechanism, and the only open [PR] row on this thread is this one. Review① Issue direction: correct. The producer of the fabricated tool result is the filter's own verdict: the #1720/#2023 rule ("body not refs-only = prose wearing tags: tags go, content stays") was written for ③ Code: the fix is at the right layer, one defect found and fixed directly on the branch.
④ Tests: real teeth. 11 original cases (split-invariance via every 2-way split + byte-at-a-time, drop-callback fires once, guards for the rules that must not move). I verified the negative direction: filter reverted to master → 7 of 11 fail; restored → 11/11. My fix-up adds 4 more (self-close dies in place with following prose surviving, both whole-text shapes; streaming split-invariance for the self-close shape; a guard that a ⑤/⑤b Diff & cleanliness: clean. Two files, every line on-purpose; naming, dense cross-referenced comments, and hex-escaped angle brackets match the file's existing style; no dead code, no new dependencies. Verification (targeted, per §7.2):
八问
判定: 修复方向正确、机制成立, 审核发现的自关闭缺陷已直接在 PR 分支修掉(commit |
(ai: vllm-qwen/qwen3.8-27b) Status after the daemon restart (the session went idle after posting the full review above — no work was lost, nothing pending on my side):
|
|
Closes pair #6557 was auto-closed by the batch merge. Superseded by #6765 (merged to master as 9f1c291). Your commit 32aa9d7 is in master verbatim — same content, same authorship, only the object ID changed (the batch used a real Thanks for the fix — it is live in master from 9f1c291 onward. (Your source branch was deleted after the merge, which is why GitHub could not detect the ancestor relationship either — tip 32aa9d7 is an ancestor of master.) |
|
Superseded by #6765 (merged to master as 9f1c291). Your commit 32aa9d7 is in master verbatim — same content, same authorship, only the object ID changed (real git merge, no rebase/cherry-pick rewrite). Your source branch was deleted after the merge, which is why GitHub could not detect the ancestor relationship — tip 32aa9d7 is an ancestor of master. Thanks! |
What
A model-emitted render tag whose
typenames a tool lane (type="tool:acp_cache") frames a fabricated tool result. The tag-echo filter treated it liketype="text": it stripped the markup and kept the body, so the invented result became ordinary assistant text — and from then on the model opened nearly every reply by copying "tag + that body" (production session in #6557: the same JSON block 25 times in 23 minutes, until the range was folded).A tool-typed span now dies whole, in both paths:
stripAcpTags→stripPass)TOOL_TYPED_PAIRdrops the span from the opening through its close; an opening with no close in the field owns the rest of it (the wrapped-turn EOF rule, reused)createTagEchoFilter)swallowReleases = false+IMITATION_SWALLOW_CAP), so the body is discarded — closed and never-closed (EOF) shape alikeThe distinction is the one the #1720/#2023 rule already makes, extended to a third case: a render tag wraps only kernel refs, so a body that is not refs-only is prose wearing tags when the type is
text— there the body IS the model's own words and keeping it is correct. Undertype="tool:…"the body can only be an invented tool result; the #1720 rule applied verbatim is what turns one echo into a self-reinforcing loop.typeis matched through casing drift (#1731 joins here: an echoed type drifts like an echoed name), and the quote aftertype=is part of the match so atype=inside another attribute's value cannot be mistaken for the attribute.Accepted trade
A model that legitimately quotes a tool-typed render tag (e.g. "the kernel emits
<acp tokens="1" type="tool:acp_cache">…</acp>") loses that span — the same bounded trade the filter already makes for an echoedtype="text"pair, and the reason the #1039 invariant (tool-call arguments byte-exact) is untouched: nothing here routes through the argument channel.Not in scope, deliberately
<br>/whitespace should emit empty text) — that changestype="text"body semantics (缺陷:PAIRED正则吞掉最多 64 个字符的助手正文 #1720), which is an owner call, not a side effect of this fix.Testing
tests/issue6557-tool-typed-echo-span.test.ts— 11 cases: whole-text pair / multiple pairs in one field / unclosed open / casing drift on both the attribute name and the value; streaming single chunk, every 2-way split and byte-at-a-time (split-invariance, the tag-echo filter: space-separated long reference strings trigger catastrophic regex backtracking; 30 references block the | tag-echo 过滤器:空格分隔的长引用串触发正则灾难性回溯,30 个引用阻塞流式管线约分钟级(DoS) #4178/[PR] fix: make streaming tag-echo verdicts chunk-split independent (#4169/#4107) #4210 discipline); the drop callback fires once per artifact; guards for the rules that must not move (type="text"keeps its prose body, a refs-only body still dies whole, tool-call arguments stay byte-exact).src/loop/tag-echo-filter.tsto master with the new test in place: 7 of 11 fail. Restored: 11/11 pass.plugin-passthrough-tag-strip,…-chat,…-tool-xml-warn,…-finish-tail,plugin-empty-turn-retry,loop-core,loop-degenerate-retry,loop-strict-echo): 108/108 pass.tsc --noEmit: clean.check:test-import-graph/check:unused-exports: clean.admin-origin.test.ts(EACCES, port 8285 unusable in this sandbox) andanthropic-pck-verbatim.test.ts(EBUSYon a tempindex.db) — neither touches the filter.Fixes #6557