Skip to content

[PR] Fix #4311: Block summary and compress call parameters rendered twice — no longer duplicated when the call is present | 修复 #4311:块摘要与 compress 调用参数双份上线 — 调用在场时不再重复渲染 - #4314

Merged
ranxianglei merged 2 commits into
masterfrom
fix/4311-skip-duplicate-summary-render
Oct 23, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #4311

kernel-change: skip duplicate acp_summary render when the originating compress call is visible in the composed view (prune anchor filter, #4311)

改了什么

组合快照时,若折叠块的 compressCallId 能对上当前视图里可见的 compress 工具调用,则跳过该块的 acp_summary 渲染注入 —— 调用参数本身就携带完整摘要草稿,且交换按设计永久保护,再渲染一遍就是同一份文本发两遍。调用不在视图里(已被折掉/网关丢弃)或根本没有调用来源(系统折叠、codex/dsh 伪造渲染车道)的块照常渲染,摘要永远不会凭空消失。存储零变化。

  • kernel/src/prune.ts:锚收集处按可见调用集合过滤 + 跳过说明;
  • kernel/tests/issue4311-summary-dedup.test.ts:4 个测试(调用在场不渲染 / 调用消失渲染回归 / 无调用块永渲染 / 旧渲染丢弃不再注入);
  • kernel 0.0.155 → 0.0.156。

有意不做的事(以及为什么)

issue 里讨论过的"孤儿子规则"(回执丢失、无块的调用按死处理)没有实现:#4307 调查对 1639 份真实请求转储逐个核对 tool_call_id,239 次调用对应 239 条回执,零丢失 —— 我早前普查里的"22 条无回执孤儿"是把渲染拆分误读成的假象。真实线上不存在回执丢失孤儿;线上仅有的"无回执"形态是当回合进行中的 pending 调用,而 #4289 明确要求 pending 保持保护。给一个不存在的形态加折叠通道,反而会碰 pending 契约(实现中 5 个既有测试红灯验证了这一点),遂整体回退该部分。

测试

  • kernel 全量 1441/1441;
  • 代理侧 compress/prune/fold/protect/carrier/checkpoint/recommend/refs/wire-contract/storage-engine-proofs/golden-storage-render 全绿(渲染 fixtures 无可见调用,无 golden 漂移);
  • typecheck 干净。

cc @ranxianglei

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/4311-skip-duplicate-summary-render (a890310)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.5164-pr.4314.8dbcad4

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4314.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title 修复 #4311:块摘要与 compress 调用参数双份上线 — 调用在场时不再重复渲染 [PR] Fix #4311: Block summary and compress call parameters rendered twice — no longer duplicated when the call is present | 修复 #4311:块摘要与 compress 调用参数双份上线 — 调用在场时不再重复渲染 Oct 22, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 同家族整合分支——本 PR 内容 ⊇ #4310(其又 ⊇ #4291/#4293 的修复面)+ #4311,但 base 取的是过期中间态(详见发现 A),与在途 PR 的关系需在合并前处置。

标签: bug, p1, pi, scope/kernel(压缩残渣只增不减 = 缓存泄露类一律 p1;事故会话为 pi 车道;修复全部落在 kernel/)。


审核方式说明

未复读 PR 描述与 issue 结论,从代码独立重推:逐文件读了本分支相对 origin/master 的全部 kernel diff、宿主侧回执发射点、prune/compressCallId 数据流,并与 #4291/#4310/#4293 三个在途 PR 的真实 head 做了树级对比(git diff 两两对照 + merge-base --is-ancestor),CI 结论取自 check-runs API 与失败分片完整日志(非 PR 页面状态)。

⚠️ 发现 A(拦下原因):分支 base 过期,#4310 二轮修复被回退

#4310 当前 head 是 90b95c2df(含 7b51e3e16 "exempt failed compress exchanges in every judgment site" → refused → bump 0.0.156)。本分支不是它的后代(git merge-base --is-ancestor 90b95c2df pr-4314 = false)——分支里的 #4289/#4307 部分取自更早的中间态。树级 diff(90b95c2df..pr-4314)显示本分支缺四样东西:

  1. 方言感知识别:90b95c2df 有 isCompressToolName(toolName, config?)(裸名 ∪ config.isCompressTool,覆盖 MCP 车道 mcp__bili__compress,[Bug] MCP 模式下 acp_rule 的工具名带有前缀,可能导致硬保护失效 #2578/[Bug] MCP compress 历史调用未被清理,长会话累积大量旧摘要与回执 #2970);本分支只有裸名 toolName === "compress" → MCP 车道的 failed/refused 交换仍永久保护,修复够不到那条车道。
  2. 豁免优先级:90b95c2df 把豁免放在所有内置来源之前早退(压过用户 protectedTools pattern、宿主 isToolProtected 钩子);本分支只在 ALWAYS 表内豁免 → 用户配置或宿主钩子再钉一次,failed 交换就被重新钉死。
  3. 判定点穿线:90b95c2df 给 isMessageProtectedWithPairing 加第 4 参 failedCompressCallIds,穿到 recommend buildCompressibleRanges、ccr storeLargeResults、absorb 三函数、compress assignRefsNode;本分支这些文件一行没动。后果是内部不一致:assignRefsNode 已给 failed 调用发数字 ref,但 buildCompressibleRanges 仍把调用半 advertise 成 protected(ref 账本说可折、recommend 车道说受保护)→ 死重无法经 acp_status/recommend 自动车道回收,只有显式 range 能折它。这正是 7b51e3e16 修掉的缺口,被本分支回退了。
  4. 对应 5 个回归测试全缺(recommend advertise / path-pattern protectedTools / MCP 方言正反两例 / recognizer 单元)——这也是为什么本分支自己的套件(声称 1441/1441)能全绿:缺口没有测试兜底。

处置建议(二选一):① 推荐——直接把分支重建到 90b95c2df 之上,只保留 #4311 delta(prune.ts +33 行、新测试文件、版本行),kernel 保持 0.0.156,对 master 净差一个版本覆盖三个修复,一个闭环 PR;② 先合已审过的 #4310,再把本 PR rebase master,收缩为纯 #4311 delta。

发现 B(需补进 PR 体):描述只写了 #4311,diff 实际带三个修复

diff 携带 #4289(failed 回执可折)+ #4307(refused 回执可折)+ #4311(去重渲染),但正文只有 "Fixes #4311" 和 prune.ts 说明。按行为变更披露规则,PR 体需要补:旧行为 = 所有 compress 交换永久保护(ALWAYS_PROTECTED_TOOLS 按工具名判定)→ 新行为 = 回执为 [Compression FAILED/[Compression refused 的零块交换可折(拿数字 ref,正常折叠 + #3769 清扫两条回收路径);成功/部分/在途无回执仍永久保护。合并后还需:带说明关闭 #4289/#4307,并处置被取代的在途 PR #4291/#4310/#4293(走方案①则三者均按 superseded 关闭并注明由本 PR 收编)。

发现 C/D/E(不拦下)

对 #4311 delta 本身的审核(通过)

机制从代码独立验证过:skip 仅在 block.compressCallId 精确命中当前视图可见调用时触发(按 id 不按 range 重叠,re-fold 的块照常渲染自己的摘要);系统折叠/伪造车道不写 compressCallId、external-summary 用 marker id 铸造(#preflight.ts:2143 / external-summary-compress.ts:98,106),结构上永不命中 → 摘要不会凭空消失;成功交换永久保护 ⇒ 跳过稳定、前缀缓存稳定;旧渲染经 knownSummaryIds 丢弃不再注入;存储零变化。「孤儿子规则有意不做」的决定我同意:1639 dump 取证零丢失回执、pending 契约明确、实现曾把 5 个既有测试打红灯——给未观测到的形态加折叠通道违背保守原则。

结构化八问

  1. 是什么问题:一份压缩摘要在线路上存两份——块的 acp_summary 渲染 + compress 调用参数里的全文草稿(交换永久保护,两份长期并存);事故会话 94% 上下文是压缩残渣。本分支另捎带 Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289/Compression calls with lost ACKs are permanently stuck in context: client-side message loss / model-generation switch re | 回执丢失的压缩调用永久滞留上下文:客户端丢消息/切模型世代重置产生孤儿,且无任何回收路径 #4307 两个「零块回执永不折叠」的遗留修复。
  2. 什么原因导致的:① There are two copies of the summary sent to the model: the block's acp_summary rendering and the compress call parameter | 发给模型的摘要有两份:块的 acp_summary 渲染 + compress 调用参数各存一份 — 组合快照时,调用在场就不要再渲染 #4311:块状态里有 compressCallId 但组合视图时没人消费——调用明明可见,块摘要仍照渲一遍;交换按设计永久保护,重复永远不会自然消失。② Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289/Compression calls with lost ACKs are permanently stuck in context: client-side message loss / model-generation switch re | 回执丢失的压缩调用永久滞留上下文:客户端丢消息/切模型世代重置产生孤儿,且无任何回收路径 #4307:保护判定只看工具名不看回执结局,FAILED/refused 两种零块回执语义就是「什么都没折」却享受永久保护。
  3. 影响范围与严重程度:p1 缓存泄露类。There are two copies of the summary sent to the model: the block's acp_summary rendering and the compress call parameter | 发给模型的摘要有两份:块的 acp_summary 渲染 + compress 调用参数各存一份 — 组合快照时,调用在场就不要再渲染 #4311 波及所有「调用可见 + 块已建立」共存的会话(proxy 主路径,每次成功压缩产生一对冗余);Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289/Compression calls with lost ACKs are permanently stuck in context: client-side message loss / model-generation switch re | 回执丢失的压缩调用永久滞留上下文:客户端丢消息/切模型世代重置产生孤儿,且无任何回收路径 #4307 波及触发失败/拒绝门的会话(实测 47 refused 对 ≈117K 字符 ≈ 出站 wire 14%)。存量会话自愈,无迁移脚本。
  4. 怎么修复的:① There are two copies of the summary sent to the model: the block's acp_summary rendering and the compress call parameter | 发给模型的摘要有两份:块的 acp_summary 渲染 + compress 调用参数各存一份 — 组合快照时,调用在场就不要再渲染 #4311:prune 收集锚点时,若块的 compressCallId 命中视图内真实可见的 compress 调用,跳过该块 acp_summary 注入——调用参数本身携带摘要,再渲一遍等于同一文本发两次;调用不在视图/从未有调用来源时照常渲染。② Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289/Compression calls with lost ACKs are permanently stuck in context: client-side message loss / model-generation switch re | 回执丢失的压缩调用永久滞留上下文:客户端丢消息/切模型世代重置产生孤儿,且无任何回收路径 #4307:失败回执前缀集合扩为 {FAILED, refused},failed-callId 集合穿线各判定点解除保护,复用既有 unprotect→fold 管线。
  5. 是否有回归问题:审过既有行为——成功/部分回执保持保护 ✓(负控制测试);在途无回执调用保持保护 ✓(pending 契约);acp_rule 不受影响 ✓;载体锚自愈(stripKernelSummaries 每请求重建载体索引)✓;回合完整性(孤立调用 INV2 跳缺失 partner)✓;There are two copies of the summary sent to the model: the block's acp_summary rendering and the compress call parameter | 发给模型的摘要有两份:块的 acp_summary 渲染 + compress 调用参数各存一份 — 组合快照时,调用在场就不要再渲染 #4311 skip 条件成立时源(调用)必然在场,缓存稳定 ✓。但发现 A 的 base 回归造成 ref 账本与 recommend 车道内部不一致——这是拦下的实质原因,重建 base 后此项消除。
  6. 是否破坏缓存:不涉及。There are two copies of the summary sent to the model: the block's acp_summary rendering and the compress call parameter | 发给模型的摘要有两份:块的 acp_summary 渲染 + compress 调用参数各存一份 — 组合快照时,调用在场就不要再渲染 #4311 去掉的是一份重复渲染,锚位置不变;Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289/Compression calls with lost ACKs are permanently stuck in context: client-side message loss / model-generation switch re | 回执丢失的压缩调用永久滞留上下文:客户端丢消息/切模型世代重置产生孤儿,且无任何回收路径 #4307 的消息在正常折叠边界离开 wire,断点策略不变([Bug] MCP failed compression record rotation prematurely rewrites the history prefix, triggering expensive cache recompu | [Bug] MCP 失败压缩记录轮换提前改写历史前缀,触发大额缓存重算 #3769 安静回合纪律保留)。
  7. 是否改了设计方向:不改。仍是单投影判定(KDD#12)、顺序为中心的身份、降级不猜哲学(渲染回退/载体自愈都是 fail-safe 方向)。
  8. 是否引入新配置:不涉及。无 env/config 面新增(PruneOptions.isCompressTool 是内部接线,默认裸名,宿主已传方言感知钩子)。

判定

拦下(BLOCK),待两件事:① 按发现 A 重建 base(推荐直接叠到 90b95c2df 上,只差一个机械操作);② 按发现 B 补 PR 体的行为变更披露与被取代条目处置计划。#4311 delta 代码质量本身过审,kernel 相关 CI 车道全绿。kernel 变更属人工评审档,合并由你定;我未 push 任何内容、未合并任何 PR。

@ranxianglei ranxianglei added bug Something isn't working p1 pi scope/kernel labels Oct 22, 2026
@ranxianglei
ranxianglei force-pushed the fix/4311-skip-duplicate-summary-render branch from ce9a56a to 61da38f Compare October 22, 2026 15:34
… call is already on the wire

The summary text of every fold reached the model twice: once as the
block's acp_summary render at the fold point, and once inside the
originating compress call's arguments (the exchange is permanently
protected, so it never folds). On residue-heavy sessions that
duplication is pure dead weight.

Composing the snapshot now skips the anchor render for blocks whose
compressCallId resolves to a tool-call visible in the SAME view — the
exchange itself is the model-visible recap. Blocks whose call is gone
(folded away, gateway-dropped) or that never had one (system folds,
codex/dsh forged-summary lanes) keep their render, so a summary never
disappears. Stale renders from previously-pruned views are dropped by
the existing knownSummaryIds path and not re-injected. Storage is
untouched (blockContents / payloadJson / message rows).

Companion orphan rule from the issue discussion (doom receipt-less
calls with no block) was dropped: the receipt-loss premise was a census
misclassification — 239 calls vs 239 receipts in 1639 real request
dumps (#4307 investigation), receipt-less shapes in practice are
in-flight pending calls, which #4289 keeps protected.

kernel 0.0.155 → 0.0.156.

Fixes #4311
@ranxianglei
ranxianglei force-pushed the fix/4311-skip-duplicate-summary-render branch from 61da38f to 8c9e33f Compare October 23, 2026 01:53
Rebased onto master after #4291/#4310 merged (master carries 0.0.156);
prune.ts source change needs its own version per kernel-guard.
@ranxianglei
ranxianglei merged commit 8fbf2b9 into master Oct 23, 2026
36 of 38 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.743-master.8fbf2b9 (rolling master tag).

npm install -g billion-context@0.0.743-master.8fbf2b9  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci:full Run the FULL CI matrix (all e2e lanes + 12-leg test matrix) on this PR p1 pi scope/kernel

Projects

None yet

1 participant