Skip to content

[PR] Compression cycle fix: identify and confirm pointer echo, condense duplicate failure receipts into a single line, and co | 压缩循环修复:认出并确认指针回声、把重复失败回执缩成一行、修复折叠后压力表虚高 - #5961

Merged
ranxianglei merged 3 commits into
masterfrom
fix/compress-burst-loop
Nov 9, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #5960(现象/现场证据/根因链见 issue)。

改了什么

  1. kernel 解析(kernel/src/parse-compress-input.ts):content 里含 compressAtFoldPoint v2 的指针文案 → 新 kind already-folded-echo(与 v2 分支的 RELOCATED_POINTER_MARKER 字面量保持一致,本 PR 不依赖该分支);content 字符串整体编码单个 entry 对象 → 经共享 entry 校验器抢救为合法 range。新 kind+抢救共 4 个 kernel 测试。
  2. 回执(src/stream.ts):指针回声回一行「那次压缩早已完成,别重发」的确认——不进失败计数(不给模型「用户问了 N 次」的错觉),但仍计入 dsh内部问题 出现这个错误后,重启dsh可以发消息 但陷入无限压缩失败 #2146 熔断防失控;相同格式的解析失败从第 2 次起回执缩成一行(首次保留完整格式教程+范围清单)。
  3. 计量(src/server.ts effectiveTokenCount):[Bug] 0.1.209: Claude Code CLI main conversation forks onto <id>|sub:<fp>; the session-title call claims the raw key (regression from #4774) #5135 压缩信用分支去掉 !anchorStale 前置——连续压缩回合无上游结算,锚点整个爆发期都判过期,信用豁免恰好在最需要时失效,计量跌回原始重发历史上界(现场 238112/212992=112%,实际出站 83K)。信用仍由下次真实结算清零,不会冻结计量。

验证

  • kernel 全量 1617/1617;定向 host 套件 24/24(reject-reasons / 新增 ghost-pressure / credit / fork-nudge-trigger / fork-nudge-deadzone / anthropic-lane-nudge / issue1470);tsc 干净。
  • 新增 tests/compress-burst-ghost-pressure.test.ts 钉住「有信用→用净后 usage;无信用→过期守卫仍拒绝冻结锚点」两条。

kernel-change: acp-kernel 0.0.188 → 0.0.189(parse-compress-input 新增 CompressParseKind 成员与字符串化 entry 抢救;owner-directed fix,2026-11-08 会话 01a1b6b3 现场复盘)。

… repeat failure receipts, credit overrides cycle-stale meter

Field incident (2026-11-08, session 01a1b6b3, four symptoms, one loop):
a model under nudge pressure copied its most recent compress call as a
template — but compressAtFoldPoint v2 had rewritten that call's args to a
short ack pointer, so every re-send failed content-not-array; each failure
receipt re-appended the ~200-word format lecture plus a repeat counter the
model misread as "the user asked the same thing N times"; and because the
burst's turns never reached an upstream settle, the token meter fell back
to the raw resent-history bound and read 112% right after a successful
fold (238112/212992 while the real outbound was 83K) — re-nudging the very
loop the fold was supposed to end.

1. kernel: parse-compress-input classifies content echoing the v2
   relocation pointer as kind=already-folded-echo (no lecture), and
   salvages a content STRING that encodes one entry OBJECT (refs inside
   the JSON) through the shared entry validator.
2. host: stream.ts acks already-folded-echo as a one-line no-op (no
   repeat-guard counter; still loop-tracked so runaway bursts hit the
   #2146 breaker), and collapses identical parse-failure receipts to a
   one-liner from the 2nd occurrence on — first failure keeps the full
   teaching receipt.
3. meter: effectiveTokenCount's #5135 pending-credit branch no longer
   requires !anchorStale — during a compress burst the send chokepoint
   keeps contextTokensSource="estimate" so the credit exemption was dead
   exactly when needed; credit is still bounded by the next real settle.

kernel-change: acp-kernel 0.0.188 -> 0.0.189 (parse-compress-input: new
CompressParseKind member + stringified-entry salvage; owner-directed fix
per 2026-11-08 field review of session 01a1b6b3).
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/compress-burst-loop (c297545)

Latest build — install this exact version

npm install -g billion-context@0.0.8688-pr.5961.75ec665

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

Recent builds (commit → version)

commit version build
c297545 billion-context@0.0.8688-pr.5961.75ec665 build
61cca20 billion-context@0.0.8672-pr.5961.2de67f5 build
e03cc4b billion-context@0.0.8661-pr.5961.051ad10 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title 压缩循环修复:认出并确认指针回声、把重复失败回执缩成一行、修复折叠后压力表虚高 [PR] Compression cycle fix: identify and confirm pointer echo, condense duplicate failure receipts into a single line, and co | 压缩循环修复:认出并确认指针回声、把重复失败回执缩成一行、修复折叠后压力表虚高 Nov 8, 2026
…ne; gate the one-liner collapse on the tracked lane

- issue5134 T5: pending credit now outranks cycle-staleness — the stale
  estimate is the resend's raw upper bound (field: 112% phantom pressure
  right after a successful fold). #4383's unreported-growth protection
  still applies with no fold pending; preflight + the next settle bound
  the window.
- #1029-② / #4812: pin 1st=full lecture, 2nd+=one-liner (count climbs,
  arm paragraph rides it), n>3=armed short refusal.
- #4812 preflight lane: collapse was missing the trackLoop gate — the
  internal lane must never collapse (fix, not a test change).
@ranxianglei

Copy link
Copy Markdown
Owner Author

Fix commit 61cca20 for the 3 red CI tests — all were pinning the pre-fix behavior, except one real bug it caught:

Local: targeted suites 155/155 green (compress family, nudge, receipts), tsc clean. The cache-friendly-plugin failures seen locally reproduce on pristine master on this machine (environmental, not from this branch) — CI is the arbiter.

@ranxianglei ranxianglei added bug Something isn't working p2 scope/kernel labels Nov 8, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复——本 PR 即 #5960 的直接修复(owner-directed 现场复盘 session 01a1b6b3),无其他在途同主题 issue/PR。
标签: bug + p2 + scope/kernel——已打在 PR #5961 上(镜像侧打标签 API 在当前环境未实现,试过后无法落镜像)。p2 理由:burst 窗口内计量虚高+回执堆积+无效 nudge 属明显体验/成本退化,但会话全程可用(熔断兜底失控、前缀缓存完好、无数据丢失),未达 p1「不能用/成本爆炸」档。

两个 commit(e03cc4b 原始修复 + 61cca20 红测修复)已逐行审完,关键机制独立复核过。按八问:

是什么问题:模型把压缩完成后写回历史的「指针文案」原样抄回当新的 compress 调用,连续同参失败;失败回执逐条堆长,模型误读成「用户问了 N 次」;折叠刚成功压力表读 112% 虚高又触发新一轮 nudge。三个症状,一条根链:循环对「这次调用早已完成」没有识别、回执没有去重、计量信用豁免恰在需要时失效。

什么原因导致的(三层对应三处修):

  1. 解析层:v2 fold-point 指针文本被模型回声,parser 不认识该形状,一律判 content-not-array 并给完整格式教程;
  2. 回执层:同一 spec 的失败跨回执不去重,每次堆全文教程+范围清单,ACP 状态标记被拼接进用户消息文本块;跨会话代际 stale refs 压缩整批失败 #1029 计数文案加剧误读;
  3. 计量层(虚高根因):自有折叠后 [Bug] 0.1.209: Claude Code CLI main conversation forks onto <id>|sub:<fp>; the session-title call claims the raw key (regression from #4774) #5135 信用已铸造(credit>0),但 burst 回合无上游结算,锚点整个爆发期判 cycle-stale 且自持(每发一次盖 contextTokensSource=estimate,src/server/prepare-anthropic.ts:396);旧代码信用豁免带 !anchorStale 前置 → 豁免在最需要时失效,计量跌穿到原始重发历史上界(现场 238112/212992,实际出站 ~84K)。

影响范围与严重程度:指针回声触发面 = 开了 compressAtFoldPoint v2 且模型回声指针的 pluginMode 会话(v2 默认关,暴露面小);计量虚高影响所有「刚折叠待结算」会话,窗口到下次真实结算为止(通常一轮)。严重度:体验退化+token 浪费,不丢数据、不毁缓存 → p2。

怎么修复的:① parser 认指针字面量(与 v2 分支 PR #5949 的 RELOCATED_POINTER_MARKER 逐字节一致,od -c 核过)→ 新诊断 kind already-folded-echo;顺带把「content 是单个 entry 对象的字符串化 JSON」经共享 entry 校验器抢救为合法 range(负例仍拒)。② 回声回一行确认「那次压缩早已完成,别重发」——不进重复守卫(不给模型错觉)、仍计入 #2146 熔断防失控;相同格式解析失败第 2 次起缩成一行指回首次回执。③ 计量:#5135 信用分支去掉 !anchorStale 前置,credit>0 直接返回净后 usage 级值——stamp 随之翻成 usage,自持环一轮内打破。

是否有回归问题:逐项审过既有行为——#1029 重复守卫语义:有意变更(见下方清单);#4812 armed 阶梯:f2/f3 回执有意变更,preflight 内部车道原会被误伤进缩行(缺 trackLoop gate,是修复里的真 bug)——被 CI 的 #4812 preflight 测试抓住,61cca2039a 补了 gate,我复核 diff 确认:if (trackLoop && occurrences >= 2),echo 分支同样有 gate(src/stream.ts:1074),preflight 恒保留完整回执;#4383 未上报增长保护:credit=0 时仍生效(同文件 T 系列测试全绿),credit>0 时让位净锚,且 preflight 每发实测出站、下次结算照旧重置基线;effectiveTokenCount 其余分支字节未动;字符串化抢救复用 validateEntry,信任级别与普通 entry 相同。未发现无意回归。

是否破坏缓存:不涉及。前缀缓存/重试/增量游标/去重键均未触碰;计量变化只影响 nudge 时机判断,不影响任何缓存键。

是否改了设计方向:无架构转向,两处教义澄清:①待结算的压缩信用优先于 cycle-staleness(旧:stale 赢)——stale 路径的值是重发上界而非真实增长,这是本修复核心;②失败回执「一个计数器只说一次」(首次教学,后续指回)。均为既有机制(#5135/#2146/#4812)的延伸,无新数据流。

是否引入了新的配置:不涉及。无新 env/config/CLI/默认值。

行为变更清单(强制披露,旧→新):

  1. 计量:[Bug] 0.1.209: Claude Code CLI main conversation forks onto <id>|sub:<fp>; the session-title call claims the raw key (regression from #4774) #5135 信用豁免 旧=需 !anchorStale → 新=credit>0 覆盖 cycle-stale。窗口=自有折叠至下次真实结算(src/loop/core.ts:1506 清零)。残余边界:settle 前客户端若重发大历史,最多一轮低估,preflight 实测出站兜底。
  2. 回执:指针回声 旧=完整 content-not-array 教程 → 新=一行 ack;相同格式解析失败 旧=每次全文教程+计数器 → 新=第 2 次起一行指回首次回执(计数继续爬升,armed 段落逐字随行);preflight 车道不变(恒完整回执)。
  3. kernel 对外 API:CompressParseKind 增 already-folded-echo 成员(additive,未识别的消费方走各自默认失败分支);acp-kernel 0.0.188→0.0.189,kernel-change 声明✓、版本纪律✓、golden pin 不受影响✓。

CI 实况(刚实测):最终 head 61cca20 全矩阵绿——run 42497948024 全部 11 个 test 分片(ubuntu/windows × node22/24)+静态门+build-artifact 全 success;check-runs 汇总 36 success / 20 skipped / 44 cancelled(取消为打标触发的重跑并发清理,与代码无关)/0 failure。e2e 族按设计 skipped(ci-e2e.yml gate:PR 需带 ci:full 标签才跑真客户端,nightly cron 兜底 master);想要真客户端回归可随时补打 ci:full。

非阻塞小疵(不动手):echo 分支注释里「collapses to the #2146 short refusal」措辞略宽——纯回声 burst 实际是 n≥3 起 ack 追加 pause paragraph,短拒绝只出现在熔断 armed 期间的 parse-failure 回执上;防失控性质本身成立,纯注释措辞,不值得为它触发整轮 CI 重跑。

基线新鲜度:PR 落后当前 master 6 个提交(848f59b),那 6 个全是 CI/test/docs 修复,与本 PR 零文件重叠,mergeable=true 无冲突——直接合或先 rebase 均可。

合并判定:建议合并。代码、测试(kernel 新增 4 用例 + host 三套重钉,断言有牙且双向)、CI 均已验证;kernel 改动(parse-compress-input + 版本 bump)属 human-only 合并档,请自行合并:#5961

…ot a string no receipt carries

The re-pin asserted !second.includes("Eligible ranges") — that capitalized
phrase appears in no receipt (the recovery hint reads "Current compressible
ranges", the one-liner lowercase "eligible ranges"), so the check passed
vacuously. Pin the actual lecture signature instead: "compress takes ONE
'content' STRING" is present in the full receipt and absent from the
one-liner, so a regression that re-expands repeats into the full lecture is
caught.
@ranxianglei
ranxianglei merged commit 647b525 into master Nov 9, 2026
56 checks passed
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1096-master.647b525 (rolling master tag).

npm install -g billion-context@0.0.1096-master.647b525  # 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.

Louie0806 added a commit to Louie0806/billion-context that referenced this pull request Nov 9, 2026
…sis, ranxianglei#5949 relocated fold summaries, ranxianglei#5971 codex lane fixes, ranxianglei#5961 compress-burst loop fix

Advances the base from 848f59b to 33d4951 (20 commits, 43 files). The only
overlap with this lane is src/pipe-free relay.ts; upstream touched the WS
oversize diagnosis, outbound stamping and continuation refetch paths, while the
lane's non-streaming compact egress sits at src/server/relay.ts:2103. Both
survive — the auto-merge needed no manual resolution.

Notable upstream commits adopted:
 - cc1e240 kernel: relocate-compress v2 — summary text moves to the fold point
 - e03cc4b Stop the compress-burst loop: ack fold-point pointer echoes
 - 725084b feat: context analysis — init size, nudge cadence, harvest acceptance
 - 3fcf41e fix(codex): answer WS-lane failures with object error frames (ranxianglei#4601)
 - 86aae0d fix(google): keep tool_result-first part order for Claude-through-Google
 - d3fab0d fix(codex): keep marketplace Git repos inside the codex overlay tmp
 - 50e4cdc fix(ci): sync root + kernel lockfiles to acp-kernel 0.0.189
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p2 scope/kernel

Projects

None yet

1 participant