Repository navigation
fix: strip model-degraded render-tag closes (#2176) - #2183
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2256-pr.2183.6293268This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2183.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Independent second-pass review (code + tests + CI). Verdict up front: fix is correct, scope is right, mergeable — the only red CI lane is a pre-existing master breakage unrelated to this diff. What I verified
Regression audit (existing behaviors carried by the touched paths)
CI statusAll lanes green on head 结构化七问
收工判定: 可合并。代码正确、范围收敛、回归面已被测试钉住;唯一红 lane 是已存在 master 上的 #2152 web-index ENOENT 问题(修复在途 |
The render-tag CLOSE-name matcher was a closed acplike set, but models degrade the close into an open set (</ap>, </a>, </p>, </aph>, </ck>) in non-reasoning mode, so bare-ref spans escaped stripping and leaked into the visible answer. Relax only the close side (PAIRED close + a bare-ref-gated lenient fallback in the streaming swallow path); keep the open side and standalone LONE_CLOSE strict so prose markup is untouched (#1039).
ae9eee8 to
d0b1915
Compare
|
Closing as superseded. The unified remediation shipped via #2267 (merged, commit c564b18 - 'Unify ACP tag-echo remediation under four invariants'), which fully covers this PR's B-class degraded-close surface: my 7-case test file runs 7/7 green on #2267 and a 77/77 multi-split scan is clean (verified by @ranxianglei). Per owner direction, closing to avoid a same-layer double-fix. The behavioral test file tests/issue2176-degraded-close.test.ts is preserved on branch wt-2176-ework-daemon @ d0b1915 and can land on master as a regression guard for #2267's fix if wanted. C-class (empty-visible-turn -> host abort; summary-as-answer; reasoning-in-content) is tracked under the first-cause governance issue #2229. |
[bot] 🏷 Verified the supersession, independently re-ran the preserved guard file — claim holds:
No action taken on the closed PR, nothing pushed. If you want the guard file landed on master, say so and I'll open a minimal test-only follow-up (single commit adding just that file, referencing #2267/#2176). Otherwise this thread can rest. |
Part of #2176 — fixes the tag-leakage mechanism (report categories A/B). Category C (reasoning-as-answer + premature stop) is a separate mechanism, documented below, not bundled here.
Root cause
The render-tag close-name matcher was a closed set (
NAME= acplike 3–4-letter case-folded alternation), but models degrade the close into an open set we cannot enumerate — in non-reasoning mode the observed degraded closes were/ap,/a,/p,/aph,/ck. The open side stays strict (it anchors legitimacy); only the close slips. Because every close recognizer demanded a close-name inNAME:stripAcpTags'sPAIREDreplace left the ref-plus-degraded-close residue behind the stripped open;createTagEchoFilterswallow path could not terminate at a degraded close, over-ran its cap, and released the whole span as prose.Both let the tags reach the visible answer, where they then re-echo and amplify across turns (the "5-in-a-row" bursts).
Fix (all in
src/loop/tag-echo-filter.ts)Relax only the close side; keep the open side and standalone closes strict so user prose markup is untouched (#1039):
PAIREDclose relaxed fromNAMEto any bounded letter-name{1,16}→ a bare-ref span now terminates on a garbled close in both the whole-text and streaming paths.CLOSE_ANY_ANCHORED(bounded letter-name) used only as a fallback.looseCloseSpan(s, lenient)gains a gated lenient mode; the streaming swallow branch invokes it only when the swallowed body is a bare ref (the echo shape). Wrapped-turn/prose bodies keep the strict path, so their inner tool-call wrapper closes are never cut early.Regression audited
tests/tag-echo.test.tscases): my first attempt relaxed the terminator globally and broke them all (early cut at an inner tool-call wrapper close → orphan leak). Caught by tests; fixed by the bare-ref gate. Re-green.Behavior change (old → new)
Downlink client-visible text: model-degraded render-tag closes that previously leaked verbatim (a leaked ref-plus-degraded-close plus surrounding tag bursts) are now stripped, with the real answer preserved. This is intended — it removes the source of the self-reinforcing echo amplification. No change to well-formed handling; tool-call argument bytes remain byte-exact (#1039).
Modes
Fix lives in the shared downlink text stripper used by BOTH proxy mode and pluginMode, so both are covered.
Config surface
None added. No new env var, config key, CLI flag, or default changed.
Tests
New
tests/issue2176-degraded-close.test.ts(7 cases): well-formed regression, degraded pairs whole-text + streaming, multi-tag burst incl. degraded closes (answer preserved, no tags/refs leak), whitespace-padded ref, and the #1039 prose guard. Targeted run: 64/64 pass (57 existing + 7 new). Typecheck clean; build succeeds. Full suite left to CI.Category C (not fixed here)
"Reasoning emitted as the answer in analysis/summary form, then the turn stops" is a distinct mechanism (reasoning-channel/format leak + premature termination), not the close-set defect. It needs a wire trace (raw SSE of one C-type turn without the plugin) to isolate model-side vs proxy-side before a fix. Kept as a separate facet of #2176.