Skip to content

[PR] fix(#2778): derive compress-failure recovery hints from live eligibility - #2794

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-11_compress-receipt-live-hints
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-11_compress-receipt-live-hints

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Problem

Compression-failure receipts advertised an arithmetic span — highest message ref minus the highest active-block boundary, minus dead refs — as "Live compressible refs … Retry NOW". That arithmetic had no view of protection, coverage or size, so it could name a range the apply-side gate deterministically refuses: a fully-protected tail, an already-covered prefix, or a sub-minCompressRange range. A model following the hint hit another refusal and repeated the work — a self-amplifying retry loop.

Repro on 0.1.192: with the newest refs protected and earlier refs already folded, the receipt said Live compressible refs: m00021–m00080 … Retry NOW, while live acp_status reported no eligible range and attempting m00021–m00080 through the real gate returned refused: Range is entirely within the protected zone.

Fix

Share the live eligibility calculation with acp_status instead of computing a second, divergent number in the failure path:

  • liveNudgeDecision(src) (src/stream.ts) runs processTurn read-only with the exact args acp_status uses; the result is never adopted (the receipt must not mutate session state as a side effect of reporting failure).
  • submitGatedRanges(config, nudge) factors out the submit gate both surfaces apply — the viability floor (≥200 tokens) and the apply-side minCompressRange char count.
  • liveSpanHint(ctx) offers only ranges that clear those gates; when nothing raw is eligible it falls through to block distillation (≥2 active blocks, by real id) or an honest stop ("continue the task"), and degrades to "run acp_status" when status is unavailable. Never a fabricated span.
  • src/acp-status.ts now calls the same two helpers, so the two surfaces can no longer disagree. Its output stays byte-identical (existing acp_status suite green).

Preserved untouched: single-line receipt visibility (#1029), the repeat guards, the cause-aware circuit breakers, and the success-tail offers. No kernel, config, persistence, or wire-shape changes.

Behavior change (flagged)

Model-visible failure-receipt text changes. Where the old code could say "Live compressible refs: m00021–m00080 … Retry NOW" for a range the gate would refuse, the new code either names genuinely-eligible ranges (matching acp_status) or tells the model to continue / inspect blocks / run acp_status. This is the intended fix — the old wording was the bug. acp_status output itself is unchanged.

Tests

tests/compress-span-hint.test.ts rewritten to pin the new contract: protected tail (core regression), eligible-range offer, ≥2-block distillation by real id, dead/absent refs never named as targets, sub-minimum conversation, unavailable status, decompressed-block release, and both failure receipts carrying the live hint single-line. Targeted suites green (span-hint 9/9, acp_status 8/8); typecheck + build clean on rebased master (v0.1.192). Full regression left to CI.

Closes #2778

Failure receipts advertised an arithmetic span (highest-ref minus block
boundary) that ignored protection, coverage and min size, so 'Retry NOW'
pointed at a range the apply-side gate deterministically refuses, turning one
refused call into a self-amplifying retry loop.

Share the live eligibility source with acp_status: liveNudgeDecision runs
processTurn read-only with the same args acp_status uses; submitGatedRanges
factors out the viability+minCompressRange submit gate both surfaces apply.
liveSpanHint offers only ranges that clear those gates, else falls through to
block distillation (>=2 active blocks) or an honest stop; unavailable status
degrades to 'run acp_status'. Receipts stay single-line; repeat guards, cause
breakers and success-tail offers are untouched. No kernel/config/wire changes.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-11_compress-receipt-live-hints (a55ddf6)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3068-pr.2794.881db15

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-pr2794.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #2794 review — 可合(待 owner 合并)

审前状态核对:head a55ddf6af 恰为当前 master(e7b94a2e0f)之上 1 个提交,base 即最新 master,无需 rebase;CI 全绿(test ubuntu/windows × node22/24、codex/dsh/opencode/pi 真实客户端 lane、registry e2e、kernel-guard、config-surface-guard 等 ~27 项)。本地在 head 上定向验证:npm ci && npm run build 干净(build-info commit=a55ddf6af),node --import tsx --test tests/compress-span-hint.test.ts tests/acp-status.test.ts → 15/15 通过(span-hint 9/9 + acp-status 6/6)。

① 是什么问题:压缩失败回执里的恢复提示是纯算术值(最高 ref − 最高活跃块边界 − dead refs),对保护区/已覆盖前缀/minCompressRange 完全无感知,于是 "Retry NOW" 指向一个 apply-side gate 必然拒绝的范围——模型照做再被拒,单次失败放大成自我强化的重试环(#2778,0.1.192 实测复现)。

② 什么原因导致的:失败路径自己算了一个与 acp_status 分叉的"第二个数字"。根因是双源:同一"当前可压范围"问题存在两套独立计算,算术版缺少 eligibility 视图。不是提示文案写错字——是计算源选错了。

③ 影响范围与严重程度:所有走 proxy/plugin 压缩路径、且触发过 compress 失败的会话;触发条件=保护尾/已折叠前缀/低于最小范围时失败(即最常见的三类拒绝)。严重度:不丢数据、不坏协议,但把一次本可终止的失败变成多轮空转重试,浪费 token 并可能顶到 circuit breaker——特定条件下有实质问题的体验+成本缺陷。

④ 怎么修复的:消灭第二源,不做文案补丁。liveNudgeDecision(src)(src/stream.ts:107)以 acp_status 的完全相同参数只读跑一遍 processTurn,结果只取 turn.nudge、绝不采用(state 不被回执路径变更——我核过 kernel:runPipeline 是顺序 io-mapping,kernel 内唯一 state.nudge.*= 写在 applyCompression 成功分支而非管线里,且返回的是新 state 对象);submitGatedRanges(config, nudge)(src/stream.ts:129)把两表面共用的提交门槛(≥200 token viability floor + minCompressRange 字符数)逐字抽出;liveSpanHint(ctx)(src/stream.ts:143)只报过门范围,无原始可压则落到 ≥2 活跃块蒸馏或诚实停止,status 不可用降级为"run acp_status, do not guess"。永不再造 span。

⑤ 是否有回归问题(逐项清点 diff 触碰路径的既有行为):

⑥ 是否破坏缓存:不涉及。无缓存/重试策略/增量游标/去重键改动;回执文本变化不影响 prefix-cache 语义(工具结果文本本就不参与上游前缀缓存键的既有约定)。

⑦ 是否改了设计方向:不涉及架构转向;方向收敛——"可压范围"从双源变单源(两表面共享同一 live eligibility),这是向既有设计意图(acp_status 是唯一权威表面,#2451)的回摆,不是新方向。

⑧ 是否引入了新的配置:不涉及。无新 env/config/默认值;config-surface-guard CI 绿佐证。

测试有效性(质量关):重写后的 9 个用例断言有牙——核心回归用例精确编码 #2778 复现(defaultConfig 保护尾 → 断言不含 "Retry NOW"/"Live compressible refs right now"、含诚实停止句),负向断言钉死旧 bug 措辞不再出现,单行约束逐例检查;全部走真实 kernel core(createCore/applyCompression/processTurn)而非 mock(仅 unavailable-status 一例故意 stub throw);两条回执经 applyRanges 端到端覆盖。bug 回归时这套测试抓得住。

diff 整洁度:3 文件全部与本 PR 目的直接相关,无跑题文件、无锁文件连带、无空白重排;测试文件整体重写属范围内(钉住新契约)。干净。

结论:可合。方向正确(修根因不堵症状)、回归清单逐项过完无意破坏、测试有牙且本地+CI 双层绿。唯一留给人工的一点:模型可见失败回执文本变更属 flagged behavior change,按仓库纪律该由 owner 拍板合并——请自行合并:#2794

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

陈旧票清理(第三批动作①):目标 issue #2778 已关。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 核对完毕:关闭判断成立,不予 reopen。

查证过程与证据:

  1. Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 的修复已经通过另一条路线合入并上线:报告者自己的 PR Use live compression eligibility for recovery advice #2800("Use live compression eligibility for recovery advice",同为"与 acp_status 共享 live 资格判定"机制)于 2026-10-13 合入,merge commit 9b50d1cfc。
  2. 当前上游 master(c87185a05,v0.1.204)确认仍携带该修复:src/stream.ts:138 现为 compressibleSpanHint(ctx: RewriteCtx) → 委托 compressionRecovery(ctx)(由 state 算术改为 ctx 级 live 判定),另新增 tests/compress-recovery-ranges.test.ts;2026-10-12 以来的 revert 提交均未触碰该区域。
  3. 无遗留重复:检索所有引用 Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 的 PR([PR] fix(#2778): derive compress-failure recovery hints from live eligibility #2794/Use live compression eligibility for recovery advice #2800/fix: stop advertising DEAD refs as compressible in receipts and acp_status #3195/fix: stop advertising DEAD refs in the nudge decision directive and /acp panel (#3204) #3213/recommend/apply 共用一个区间可折叠性判定:acp_status 不再推荐必然被拒的区间 #3268 等)全部已关,无悬空并行票。

因此本 PR 在关闭时已是"修复已上线后的冗余并行实现",reopen 只会制造重复劳动——与清理意图一致。两套实现机制收敛一致(共享 live 资格、不削弱保护窗、保留单行回执与守卫),本 PR 此前的代码审核结论对 diff 本身仍然有效,可视为对已合入方向的独立佐证。

更正一条:我今日早些时候的 review 回复中"head 恰为当前 master 之上 1 个提交、无需 rebase"一句基于一个陈旧本地引用(e7b94a2e0f,2026-10-11,落后真实上游 2237 个提交)——#2800 的合入实际早于我的 review。diff 级审核结论不受影响,但该表述应以此为准更正。

@ranxianglei ranxianglei changed the title fix(#2778): derive compress-failure recovery hints from live eligibility [PR] fix(#2778): derive compress-failure recovery hints from live eligibility Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compression failure recovery hints advertise protected or already covered refs as immediately compressible

1 participant