Skip to content

[PR] Session compression reminders no longer starve under frequent interruptions: absorption debt is paid in steps starting f | 中断频繁的会话压缩提醒不再饿死:吸收欠账从第 2 次中断起付台阶(#5415) - #5416

Merged
ranxianglei merged 2 commits into
masterfrom
2026-11-01_abort-absorb-starvation
Nov 1, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

修什么

0.1.210 起,用户中断(Esc/断流)频繁的会话,压缩提醒几乎不触发,可压内容攒到几十万 token 才一次性压一大包。实测报告日志(4.5 小时)里 85 次中断,最后在 33 万 backlog、usage 44% 时才压——此前 idle 日志反复出现:

reason="growth 4450 < floor 33750, ready: T1 302220"

可压质量早就 ready(30 万),但增长台阶永远攒不够——因为每次中断都把增长参照点抬到当前读数。

根因(机制链)

  1. In pi, Esc triggers compression injection. | pi中esc会触发压缩注入 #5293(0.1.210)修复「中断后立即弹提醒打扰用户刚改的主意」:吸收中断增长时把参照点重锚到当前 meter。这个重锚不仅清掉中断轮的未上报 partial(本意),连「参照点→中断前锚点」之间已实测的真实增长也一起清零。
  2. 高频中断客户端每隔几分钟被清一次,growth 永远 < floor 33750;而 T1 触发需要 mass≥阈值 且 growth≥台阶(209 是单腿,只有 mass 一条)。
  3. 大质量闲置数小时 → 用户看到「几十万才触发一次压缩」。

修复(v2:单次中断保持 #5293 的安静)

  • host 吸收时把被清零的实测增长记入 nudge.absorbedDebt,并累计 nudge.absorbCount;
  • 欠账与新「排水」兑底只在第 2 次起的中断后生效:单次中断字节级保持 In pi, Esc triggers compression injection. | pi中esc会触发压缩注入 #5293 钉住的安静(一次长安静段后的中断可能攒出一整个台阶的欠账,但绝不在 redirect 当口弹提醒);第二次中断证明会话是「高频中断型」而非「改主意」,209 时代节奏恢复;
  • 排水兑底(与 fix: compress over unpruned view + acp-kernel 0.0.38 (billion-context-pi#195) #194 first-sight 同哲学):count≥2 + 欠账>0 + 当前无未消化提醒 + 可压量≥2×T1 阈值 → 立即排水,不再等饿死的增长腿;
  • applyCompression 把欠账与计数随其它基线一起清零;idle reason 显示 growth X + absorbed Y across N aborts < floor Z(count=1 显示 held (single abort, #5293))。

无欠账/单次中断的会话:决策字节不变。

验证

Closes #5415

kernel-change: 仅 kernel/src/compress.ts(nudge 判定)+ types;host 侧仅 src/session.ts 吸收记账;无新配置面。

#5293 re-anchors the growth reference to the current meter on every
user-aborted turn, which also zeroes the MEASURED growth from the old
reference up to the pre-abort anchor. Abort-heavy clients (85 absorbs
in one reported 4.5h log) never cross the growth floor again: a 300K
ready mass idles for hours ("growth 4450 < floor 33750, ready: T1
302220") and the session finally compresses a ~330K backlog.

Fix, v2 semantics (single abort stays byte-identically quiet as #5293
pinned):
- the host banks the skipped measured growth into
  state.nudge.absorbedDebt and counts the absorbs (absorbCount);
- debt and the new backlog-drain guard pay only once absorbCount >= 2 —
  one abort after a long quiet stretch can bank a whole interval, but
  it must not re-fire the cadence on the user's redirect (#5293 pin);
  the second absorb proves the session is abort-heavy, not
  redirect-polite, and the 209-era cadence recovers;
- backlog-drain guard (same philosophy as the #194 first-sight
  bypass): count >= 2 + debt > 0 + no outstanding nudge + ready mass
  >= 2x the T1 threshold drains now instead of idling behind the
  starved growth leg;
- applyCompression resets the debt bank and the count with the other
  baselines; idle reasons surface the debt for diagnosability
  ("growth X + absorbed Y across N aborts < floor Z", or "held
  (single abort, #5293)" for count 1).

kernel-change: nudge decision only (kernel/src/compress.ts, types),
host booking only (src/session.ts absorbAbortedTurnGrowth); no config
surface added.

tests: kernel/tests/issue5415-absorb-debt-nudge.test.ts (8 cases incl.
the #5293 single-absorb pin), tests/issue5415-absorb-debt.test.ts
(booking arithmetic + count), #5293 e2e unchanged and green; kernel
suite 1521/1521; host nudge/abort suites 23/23; tsc clean.
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-01_abort-absorb-starvation (fb2f385)

Latest build — install this exact version

npm install -g billion-context@0.0.7675-pr.5416.de59d22

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
fb2f385 billion-context@0.0.7675-pr.5416.de59d22 build
c91ef1a billion-context@0.0.7673-pr.5416.2a4a5ed build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title 中断频繁的会话压缩提醒不再饿死:吸收欠账从第 2 次中断起付台阶(#5415) [PR] Session compression reminders no longer starve under frequent interruptions: absorption debt is paid in steps starting f | 中断频繁的会话压缩提醒不再饿死:吸收欠账从第 2 次中断起付台阶(#5415) Nov 1, 2026

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查完成。结论:代码通过,无阻塞项;CI 绿即可人工合并(kernel 0.0.176,走 Kernel Boundary gate)。

核验记录

机制对症性:日志证据链完整——#5293 的重锚把 [oldRef→anchor] 的已实测增长一并清零,高频中断客户端每几分钟清一次,growth 腿永远攒不到 floor,而 T1 触发是"mass ∧ growth"双腿(0.1.209 时代单 leg mass 就够),于是几十万 ready 质量 idle。修法「记欠账 + 第 2 次中断起才付 + 2×T1 排水兑底」对因果形状正确。

关键契约逐条核过:

  1. 单次中断字节不变(#5293 契约):count==1 时 payableDebt=0、drain 要求 count≥2 → growthReady 表达式退化为原式;只有 idle 日志 多出一段 held (single abort, #5293),非模型可见面。✓(测试钉死)
  2. 无欠账会话字节不变:drain 要求 debt>0、floor 侧 +0 → 健康会话决策路径零变化。✓
  3. 欠账口径正确:host 只记 [oldRef, anchor](实测段),abort 轮未上报 partial [anchor, tokenCount] 不计入——与 #5293 "清掉未计量输出"的本意一致,不双算不超算。参照点已越过 anchor 时 recovered=0 只计数不记账(有专测)。✓
  4. 排水不会打不响的铃:lastNudgeShownTokens === 0 门控,被忽略的 nudge 保持戳位→同一 backlog 上不重发;applyCompression 在 kernel/src/compress.ts:846 清零该戳并(新增)清欠账+计数 → 压缩成功后可再武装,且新节拍从干净基线起步。✓
  5. 持久化兼容:absorbedDebt?/absorbCount? 可选字段 + 全部消费点 ?? 0,旧存档 state 加载安全,无需迁移。✓
  6. kernel-guard:version 0.0.175→0.0.176 + 双 lockfile 同改 ✓;无新配置面(纯状态字段)✓。

本地验证(正式全量留给远程 CI):kernel 新套件 8/8;host 记账套件 5/5;回归批(issue5293 单元 + nudge-decide/fork-nudge-{deadzone,trigger}/anthropic-lane-nudge/plugin-nudge-injection/silent-backend-nudge)28/28;根 tsc exit 0。

备注:PR 标题说"从第 2 次中断起付台阶"与实现一致(count 在第 2 次吸收时才让 payableDebt>0)。

@ranxianglei
ranxianglei merged commit 6ab1c89 into master Nov 1, 2026
78 of 83 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 本条是 #5403(用户侧 6× OOM 症状报告)的指定机制修复项,与相关条目关系如下,均为「相关但不同」而非重复:

开始实现 PR#1 scope: dsh × chat-completions 形状 × rollout 门(默认 0%)× storage 可读(replicasAvailable 模式)。改动面按 issue §3:新模块 src/server/fastpath-scan.ts、server gate + fastpath openai 变体(prepare-openai.ts 上游)、dsh-native.ts stamp/echo(复用 maybeIncrementalNative 处已解析 body 与 scoped store)、src/rollout.ts 一个条目、双向测试矩阵行、文档同步。anthropic/google/responses 入口留 PR#2。

先读透现有代码(server.ts 全量解析点、prepare-openai.ts、incremental-lane.ts 门模式、session.ts/persist.ts 驻留与折叠闸门、snapshot-render.ts pluginMode 旁路、dsh-native.ts stamp 处),再落实现。进展与验收(A/B 黄金逐字节相等、门双向矩阵、dsh hermetic e2e、定向测试+typecheck+build)会在后续回复与 PR 里给出。

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.982-master.6ab1c89 (rolling master tag).

npm install -g billion-context@0.0.982-master.6ab1c89  # 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.

ranxianglei pushed a commit that referenced this pull request Nov 1, 2026
#5416 (c91ef1a, kernel 0.0.176) added absorbedDebt/absorbCount to the
persisted nudge state (host booking in src/session.ts absorbAbortedTurnGrowth,
reset in kernel applyCompression) — an intentional persisted-state schema
change, declared in that commit ('kernel-change: nudge decision only ... no
config surface added'). After any fold the persisted session now carries the
two new keys, so the state digests drift by design.

Regenerated via the now-parity-pinned scripts/update-storage-render-goldens.ts.
Diff is surgical: per wire ONLY stateDigest, stateDigestAligned,
sectionDigests.state and stateKeyDigests.nudge change; every per-turn
sha/bytes/shaCiteNorm is byte-identical to the committed goldens (wire parity
proof) and blockContents/stats/metadata sections are untouched. Both consuming
suites green locally under the exact CI preload chain (17/17).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant