Repository navigation
fix: strip redundant in-place acp_summary for plugin-mode folds (#1567) - #1570
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1611-pr.1570.b557309This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1570.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Reviewing PR #1570 now — pulling the branch ( |
d6d2246 to
4b1827c
Compare
[bot] 🏷 Review complete — mergeable (human merge per §7.4, wire-shape change). I rebased the branch onto current master and pushed; CI is fully green on the new head. Details below. What I did to the branchThe PR base had gone stale (declared base
① Original issue — direction check (passed)#1567's claim is real and I reproduced it rather than trusting the description: with master's Root cause vs symptom: the fix lands at the decision point (the redundancy predicate), not a payload mask — if the same root cause surfaced in another shape tomorrow (another synthetic-id path), the prefix contract still holds because it's tied to the mint site, not to a byte pattern in transit. And the deviation from the issue's suggested session-level gate is the right call: the mode-transition edge is real — a session that did wire-loop compresses in proxy mode then flips to plugin mode would lose those earlier blocks' only carrier under unconditional session-level stripping; block-prefix leaves them on id-match logic, unchanged. ② Regression inventory (existing behaviors on touched paths)
③ Code reviewVerified the full chain the fix hinges on, end to end:
Also confirmed every plugin lane funnels through that one endpoint — Two-way safety of the predicate: even if some client did echo a ④ Test validityReal teeth, verified both ways on the rebased head (not taken on faith): master ⑤ Diff cleanliness3 files, +32/−4, every line on-purpose. No whitespace churn, no generated/lock-file noise. Follow-up after mergePR #1571 carries the cross-wire pins with its intended-strip assertions skip-gated behind 中文摘要:修复了插件模式下压缩摘要双重载体的问题—— |
stripKernelSummaries keyed suppression on an inbound tool-call matching block.compressCallId, which is unsatisfiable for folds executed through POST /__bili/plugin/tool: they mint a synthetic plugin_<ts> id the client can never echo back, even though the client's own re-sent compress pair rides inbound history every turn and IS the summary carrier by contract. Result: the kernel's in-place [Compressed conversation section] anchor rode every post-fold body alongside the pair — one extra full copy of every active summary per turn, contradicting README 'Two compression modes'. Strip on the plugin_ callId prefix instead of (not in addition to) the echo match: the prefix is minted at exactly one site, so it marks precisely the blocks whose client necessarily holds its own pair. Preflight blocks (no compressCallId) keep skipping — no tool call exists for them, so their in-place anchor remains the only carrier (#247). Proxy/wire-loop blocks keep the existing id-match logic unchanged. Regression test: the plugin tool-API fold test now asserts the post-fold body carries no '[Compressed conversation section] — <topic>' anchor while the client's orphaned pair stays visible (KEEP_LAST_ORPHANED=2).
…und (#1567 hardening) The unconditional prefix strip could lose a summary outright: if the client prunes or fails to re-send its compress pair, the in-place anchor was stripped with no carrier left (zero carriers). Restore the old predicate's self-verification — strip per-block only when that exact fold's pair is present in the (post-prepare) inbound history, matched by tool name plus the folded range quoted in the call args (flat {startId,endId} or {content:[...]}). hideConsumedCompressCalls (KEEP_LAST_ORPHANED) runs before the strip, so a kernel-hidden pair also keeps its anchor — fail-safe in both directions. Matrix (#1571) re-pinned to the intended behavior (0 carriers while pairs ride; exactly 2 pair quotes) and supplemented with two hardening scenarios: client drops a re-sent pair → anchor re-carries, bytes stable; 3rd concurrent fold → oldest pair pruned by KEEP_LAST_ORPHANED, oldest anchor kept.
4b1827c to
efb780a
Compare
What
stripKernelSummariessuppressed a block's in-placeacp_summary_<blockId>anchor ONLY when an inbound message carriedtoolCallId === block.compressCallId. Folds executed throughPOST /__bili/plugin/toolmint a syntheticplugin_<ts>callId that the client can never echo back — yet the client's own re-sentcompresstool_use+tool_result pair rides inbound history on every turn and IS the summary carrier by contract (README "Two compression modes"). The strip predicate was therefore unsatisfiable in plugin mode: every post-fold body carried the summary twice — the in-place[Compressed conversation section]anchor plus the pair — one extra full copy of every active summary per turn, compounding linearly with fold count.Fix
Strip on the
plugin_callId prefix instead of the echo match (isPluginFoldCallId, src/plugin.ts — minted at exactly one site, so the prefix marks precisely the blocks whose client necessarily holds its own pair):Why block-level prefix, not the issue's session-level gate
The issue suggested stripping unconditionally when the session is bound to a plugin agent. The block-level predicate is strictly safer:
compressCallId(no tool call exists), so their in-place anchor is the ONLY carrier; the existing!b.compressCallIdguard keeps them intact under either approach.acp_loop_*pairs the client never re-sends) and later flips to plugin mode would, under session-level stripping, lose those earlier blocks' only carrier. Block-prefix stripping leaves them on the id-match logic, unchanged.Interaction with #1548 (master)
Rebased onto current master. #1548 changed the ephemeral-loop call site to strip against inbound-derived messages only (so proxy-mode round-2 views keep the in-place summary). The two compose: loop blocks keep #1548's survival semantics (prefix doesn't match
acp_loop_*ids); plugin blocks are stripped at every call site including that one — correct, since a plugin-mode client always resends its own pair regardless of which path built the view.Behavior change (old → new)
Old: in plugin mode, the kernel's in-place
[Compressed conversation section]anchor rode every post-fold outbound body alongside the client's own compress pair (double carrier; contradicted README's "the agent's view never renders the kernel'sacp_summary").New: the anchor is stripped from all post-fold bodies for blocks created via the plugin tool API; the client's own pair remains the sole visible carrier (its visibility still governed by kernel KEEP_LAST_ORPHANED pruning). Proxy-mode bodies are byte-identical to before (id-match logic untouched).
Wire-shape change → human merge per §7.4.
Regression test
tests/plugin-protocol.test.ts— the existing plugin tool-API fold test now asserts the post-fold upstream body contains no[Compressed conversation section] — <topic>anchor while the orphaned client pair (toolu_c_1) stays visible. Teeth verified both ways on this exact base: with master'ssrc/server.tsthe assertion fails; with the fix it passes.Pre-flight (rebased head d6d2246, base 5ffafae)
npm run typecheck— cleannpm test— 3046 tests, 0 fail, 12 skippednpm run build— successCloses #1567