Repository navigation
Unify ACP tag-echo remediation under four invariants (#2023 #2066 #2190 #2248) - #2267
Conversation
…er (#2023) The filter only treated a body of EXACTLY ONE bare ref as tag content (#1720 REF_LIKE), so refs-only text adjacent to render-tag structure was released as prose: orphan ref+close units, multi-ref/range pair bodies, EOF tails after an opening, and chunk-boundary splits all leaked mNNNNN remnants to the client reasoning stream. - Generalize single-ref to refs-run (REFS_RUN/REFS_ONLY: lists, en/em-dash ranges, comma-separated range lists) at every decision point: PAIRED body, swallow inner decision, over-budget release, flush EOF branch, PARTIAL_TAIL hold (incl. run+tag-fragment composite and bare-m/partial ref prefixes so any split position holds toward the unit). - New orphan unit: a refs run directly against an UNMATCHED close is dead markup and is stripped with the close. Whole-text applies it only to depth-zero closes (orphanCloseSpans greedy pairing); streaming only when no opening is live — so a ref cited inside a prose-wearing pair survives (#1720) in both modes. - The [\w>] lookbehind extends across chunk boundaries via lastEmitted: word-like tokens (xm01233) and tag-terminator residue (#644 over-cap drop) are never orphan-stripped or held. Tests: tests/issue2023-refs-residue.test.ts pins every shape whole-text AND streaming (char-by-char equivalence + explicit chunk splits), plus #1720 protection pins, #644 lossless pins, and documented residual pins.
…ounting (#2023) Review finding on the #2025 head: the three new PARTIAL_TAIL refs-run alternatives flow into mayStartRenderTag, which isOrphanMarkupText used as its render-tag probe. A released tail shaped like a refs run (a genuine citation held to EOF) was therefore counted as dead markup residue, so a tool-call-free turn whose only visible output was a bare ref citation read as degenerate and burned the one-shot retry (#732/#821) — and could end in the #870 in-band error instead of delivering the citation. isOrphanMarkupText now probes with TAG_PARTIAL_TAIL (PARTIAL_TAIL's \x3c-prefixed alternatives only): byte-identical classification to pre-#2023 for every tag-shaped tail, refs-run tails flip to prose. Tagged echoes need no help from this path — their drop already sets sawStrippedEcho upstream. mayStartRenderTag stays broad (fast-path gating must keep engaging on refs-run tails so split units are still stripped). Pinned: unit classification + a full openai-lane pipe test proving a bare-citation answer reaches the client with zero refetches; both fail on the previous head. #870 unclosed-tag retry pin stays green.
Production sessions (ses_efe4cfcbdffe) show the model re-emitting
internal ACP artifacts as assistant prose: mangled render tags
(<acp=1>) and the absorb tool call written as chat-template text
(<parameter=ref>...mNNNN...</parameter><parameter=summary>...</parameter>
</function></function_calls>). Both leaked into client-visible history.
- stripAcpTags: MANGLED_OPEN pattern (name=... form) + fast-path gate
- whole-field emission discriminator: field opens with a tool-call
open and carries the absorb ref+summary signature (unique to absorb)
- armed only when the shipped request carries the [ACP absorb]
instruction (proxy: wireBody; plugin: per-request marker)
- echo guard: an emission verbatim echoing a fragment from the
request is preserved, not dropped (raw + canonical JSON-escaped
containment)
- streaming tcHold (pending/committed) across chunk boundaries;
orphan close-tail drop (defensive)
- drop/requestText threaded through all adapters, plugin pipes,
JSON rewriters and field strippers
- tests/absorb-emission.test.ts: 31 tests over 13 regression
categories incl. user-requested verbatim emission survival
- nameless-toolcall-observability: session stub gains metadata {}
(Session.metadata is required)
…+ plugin-passthrough paths (#1960) PR #2067 added whole-field emission-drop to the prose filters, and the non-streaming / plugin-passthrough rewriters already applied render-tag + marker + bili-artifact stripping to signed Anthropic `thinking` and Gemini `thought` channels. Both can rewrite signature-verified bytes: on replay the client echoes the modified thinking back with its original signature, which desyncs and bricks the session (#1960/KDD#10). The loop streaming adapters already keep these channels verbatim ("prose filters never touch thinking"); this aligns the remaining paths. - createIdentityStreamFilter(): pass-through filter with honest char accounting (keeps the #673 degenerate-turn stats correct) for signed channels. - pipePluginChatWithStrip: route anthropic/google `thinking` through the identity filter instead of the prose-filter stack. - stripAnthropicText: leave delta.thinking / content[].thinking byte-for-byte (the text channel is still stripped). - rewriteGoogleJsonResponse + stripGoogleChunk: skip `thought` parts. OpenAI/Responses reasoning is not byte-signature-verified, so it stays stripped as before. Behavior change (old -> new): model-emitted render tags / markers / whole-field emissions inside SIGNED thinking or Gemini thought parts are no longer stripped on the plugin-passthrough and non-streaming wire paths — they now ride byte-for-byte, matching the loop adapters. Cosmetic tag echoes may remain inside thinking panes (accepted per #1881/#1960); replay no longer risks a signature mismatch. Tests updated to pin the corrected contract: - absorb-emission.test.ts (category 8) - plugin-passthrough-tag-strip-chat.test.ts (anthropic thinking_delta case)
Models imitate ACP render tags with drifted close names (field census: ap/p/a/apc/cap/ck/div/warn/aph/ambient/apm) that no matcher recognizes. The stream filter then swallows the open tag, hits its budget or EOF, and either releases the 'mNNNNN</word>' residue verbatim (mid-stream) or silently drops the following prose (flush). Whole-text stripAcpTags had no pair rule for degenerate closes either. - swallow mode now accepts any short close name as terminator when the body since the opening is exactly one bare ref (degenCloseAfterRef); wrapped-imitation mode is excluded (payload may hold arbitrary markup) - stripAcpTags gains DEGEN_PAIR: acplike open + bare ref + any short close removed atomically, before the lone passes - fast path gains mayStartDegenerateRenderTag (broad <word tail <=16) so degenerate heads engage the state machine instead of riding through; kept out of PARTIAL_TAIL/mayStartRenderTag so #1760 orphan-markup accounting still classifies prose tails like 'a<b' as prose - completion pre-checks gain containsEchoResidue so residue-shaped final artifacts go through the whole-text rebuild path - new warn logs at fast-path forward and filter release points make the formerly silent leak observable (#2190 fix suggestion 4) Behavior change: ref-body spans closed by a degenerate name are now stripped instead of leaking or evicting adjacent prose; fast path engages one fragment earlier on ambiguous '<word' tails (bounded delay, no byte loss). No config surface change; kernel untouched.
…tack compat) One-line compat for the agreed #2025 -> #2211 -> #2067 merge order: #2025 folds the master REF_LIKE constant into REF_TOKEN/REFS_RUN, which would leave this call dangling (silent tsc break once stacked, each PR green alone). Standalone const carries the identical regex /^\s*m\d{4,}\s*$/; behavior unchanged.
…audit raw-forward exits - buildAcplikeName: add acacp/accessp/acpx/acb (case-folded, exact enumeration; char-class generalization rejected — FP risk on real words like acgroup/acmap). All name-derived matchers pick them up; 229-session census validated 10/10 leak forms cleared, 170/170 legit-word contexts preserved. - plugin.ts: log-only residue audits at the unfiltered raw-forward exits (processOpenai E1 no-choices branch + E5 tail fallthrough, chat/responses JSON.parse-fail branches); openaiFrameHasToolCalls excludes argument frames (#1039 byte-exact). - tests: +4 drift-name cases in issue2190 suite (streaming char-by-char, cross-name pairing, whole-text, gate predicates, legit-word survival); tag-echo.test.ts fixture <acpx> -> <abc> since acpx is now a recognized echo name by design.
… ignore .tmp/ The stacked compat commit accidentally committed node compile-cache binaries and test artifacts under .tmp/ (diff-cleanliness gate). Untrack only; .gitignore gains .tmp/ (it had tmp/ but not .tmp/, which is how they got in).
…es-wire exits The #2190 exit audit (auditRawForward) covered only the openai E1/E5 and both parse-fail exits; the isomorphic raw exits named in the #2248 mechanism table were still silent, leaving holes in the zero-log-leak attribution net. Log-only, zero byte change (#1039 wire fidelity preserved by construction): - processAnthropic: content_block_start / non-delta events / unmanaged delta types (input_json_delta excluded — tool-call arguments are user intent). - processGoogle: non-candidates frames + tail fallthrough (frames carrying non-text parts excluded via googleFrameHasNonText — functionCall/ functionResponse are structured or user data). - responses pipe: unrecognized-type fallthrough (responsesFrameHasToolCalls excludes function_call/custom_tool_call argument streams). Tests: new issue2248 suite pins all ten audited exits (warn fires AND byte-exact forward) plus the three argument-frame exclusions and two clean negative controls; also pins the four #2190 sites which shipped without direct tests.
…amination Open-side census counts are inflated by models quoting tag names inside their own reasoning. Under the decontaminated standard (block-initial emission + tokens= attribute + deduped n>=4), only accessp/acacp/acb qualify; acpx's raw census (~217) proved self-referential/constructed with one case-variant sighting only. Excluded forms stay observable via the #2190 residue audits, so a clean attestation earns re-inclusion. tag-echo.test.ts fixture reverts to its original <acpx> sample, which is ordinary markup again under the reduced name set.
… always logs a drop
…ps via ref-anchored open-set rule
…esidueWarn, absorbInstructed, requestText) signature
#2248) Fold the three remediation legs (refs-run residue, degen-close strip + egress audit net, emission drop + signed-thinking verbatim) into one branch and pin four hard rules over every text-rewriting surface: 1. thinking channel byte-verbatim everywhere — extends #1960 signed thinking treatment to openai reasoning_content/reasoning and responses reasoning summaries (adapters route them through createIdentityStreamFilter; stripOpenaiChatText/stripResponsesText leave them untouched). REVERSES the #1881 reasoning-echo strip. 2. model prose remains manageable (tags/markers/residue/emissions). 3. tool-call arguments byte-identical (#1039) — never filtered. 4. user-sent bytes never rewritten (#463 exemption). Plugin passthrough: reasoning summary deltas/done events forward verbatim; the argStream strip path is retired (identity semantics). Docs: TECHNICAL-NOTES en/zh (invariants section), CLIENTS en/zh (user-facing summary). Pinned by tests/unified-acp-invariants.test.ts (8 tests, both lanes). Full affected net: 401 pass / 0 fail.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2370-pr.2267.ae18ae7This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2267.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…survives (#2267 review) The absorb field-start release ran process(held) and only then cleared the shared held buffer. process() itself can stash a PARTIAL_TAIL fragment into that same buffer when a release chunk ends in a tag-head-shaped tail (e.g. an absorb-instructed first delta "Check <ac"); the post-clear wiped the stash, so the next delta arrived tag-less and the head was re-emitted as fresh prose (tag-echo residue leak). Every other path clears before processing (normal push, flush tcHold path); mirror that here. Regression test added: red on the old ordering, green on the fix.
[bot] 🏷 Review 完成 —— 结论:可合并(等人工 merge)。审的是最终 head 验证面:本地 checkout 全读 L3 unify diff;三腿机制并解决一致性抽查(refs-run / DEGEN_PAIR+degenCloseAfterRef+mayaStartDegenerateRenderTag / emission-drop+MANGLED / auditRawForward+frame 排除,全部在最终树中);既有行为逐项回归清点;定向测试 326 pass / 0 fail(unified-acp-invariants、issue1881×2、issue2023、issue2190、issue2248、absorb-emission/absorb×3、passthrough-tag-strip×3、proxy-noinject、tag-echo、bili-artifact、fix-1760、fix-1039、nameless-toolcall、loop/pck/degenerate-retry 全家族); Review 期间发现并已处置的两件事:
结构化七问:
合并后动作:关闭被取代的三腿 PR #2025/#2067/#2211(#2067 外部贡献者 yukhymenko-yurii 的作者身份已在 merge history 中保留,无需替换);四个源 issue 由 Closes 标记自动关闭。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.81-master.c564b18 # this exact build
npm install -g billion-context@master # always the newest merged build
|
为什么
owner 定调(#2229 线程):acp 标签问题族(#2023/#2066/#2190/#2248)统一整治,一个 PR 收编全部三条已审腿;内核可改;四条硬规则:
内容
m01233</acp>remnant through to the client reasoning stream (model echoes refs from compress confirmation markers) #2023)、fix(#2190): strip model-emitted degenerate-close echo residue in streaming + whole-text paths #2211 退化闭名剥离+出口审计网(【bug】最终版issue: 模型生成的<acp …>标签会漏到用户可见输出(附根因、量化与修法建议) #2190/[bug] 出口层缺口:文本不在受管字段的帧绕过 tag-echo 状态机(E1/E5 原始转发出口 + 零日志真泄漏样本) #2248)、fix: drop model-emitted ACP tool-call emissions from the prose channel #2067 emission 整段丢弃+签名思考 verbatim(Model re-emits internal ACP artifacts into assistant prose (mangled render tags + absorb tool-call text) #2066)。冲突全部并集解决;createTagEchoFilter统一签名为(onDrop, onResidueWarn, absorbInstructed, requestText)。reasoning_content/reasoning与 responses reasoning summaries 从"[bug] ACP 标签泄漏:<acp tokens=...> 标签被模型原样复述到回复正文,仅靠系统提示劝阻不足 #1881 剥回声"翻转为逐字节 verbatim —— 适配器走createIdentityStreamFilter,stripOpenaiChatText/stripResponsesText纵深防御同样不动(reasoning 回放/签名校验验证的就是这些字节,任何改写都会失步;与 [acp-loop] In-turn compress re-request edits the latest assistant message → Anthropic 400 "thinking blocks … cannot be modified" (session stays broken) #1960 anthropic thinking/google thought 同一处理)。插件直通 lane 同步:reasoning summary delta/done 事件原样转发,argStream 剥离路径退役。[tag-echo] raw exit日志;per-shape 出口扩展等 audit 数据回来再做(follow-up)。行为变更披露
验证
tsc --noEmit -p tsconfig.build.jsonrc=0;root tsconfig rc=0Closes #2023
Closes #2066
Closes #2190
Closes #2248
Supersedes #2025 #2067 #2211