Repository navigation
[PR] Session compression reminders no longer starve under frequent interruptions: absorption debt is paid in steps starting f | 中断频繁的会话压缩提醒不再饿死:吸收欠账从第 2 次中断起付台阶(#5415) - #5416
Conversation
#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.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7675-pr.5416.de59d22This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5416.tgz
npm install -g packageInstall instructions are refreshed on each push. |
ranxianglei
left a comment
There was a problem hiding this comment.
审查完成。结论:代码通过,无阻塞项;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 排水兑底」对因果形状正确。
关键契约逐条核过:
- 单次中断字节不变(#5293 契约):count==1 时 payableDebt=0、drain 要求 count≥2 → growthReady 表达式退化为原式;只有 idle 日志 多出一段
held (single abort, #5293),非模型可见面。✓(测试钉死) - 无欠账会话字节不变:drain 要求 debt>0、floor 侧 +0 → 健康会话决策路径零变化。✓
- 欠账口径正确:host 只记 [oldRef, anchor](实测段),abort 轮未上报 partial [anchor, tokenCount] 不计入——与 #5293 "清掉未计量输出"的本意一致,不双算不超算。参照点已越过 anchor 时 recovered=0 只计数不记账(有专测)。✓
- 排水不会打不响的铃:
lastNudgeShownTokens === 0门控,被忽略的 nudge 保持戳位→同一 backlog 上不重发;applyCompression 在 kernel/src/compress.ts:846 清零该戳并(新增)清欠账+计数 → 压缩成功后可再武装,且新节拍从干净基线起步。✓ - 持久化兼容:
absorbedDebt?/absorbCount?可选字段 + 全部消费点?? 0,旧存档 state 加载安全,无需迁移。✓ - 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)。
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 本条是 #5403(用户侧 6× OOM 症状报告)的指定机制修复项,与相关条目关系如下,均为「相关但不同」而非重复:
开始实现 PR#1 scope: dsh × chat-completions 形状 × rollout 门(默认 0%)× storage 可读(replicasAvailable 模式)。改动面按 issue §3:新模块 先读透现有代码(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 里给出。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.982-master.6ab1c89 # this exact build
npm install -g billion-context@master # always the newest merged build
|
#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).
修什么
0.1.210 起,用户中断(Esc/断流)频繁的会话,压缩提醒几乎不触发,可压内容攒到几十万 token 才一次性压一大包。实测报告日志(4.5 小时)里 85 次中断,最后在 33 万 backlog、usage 44% 时才压——此前 idle 日志反复出现:
可压质量早就 ready(30 万),但增长台阶永远攒不够——因为每次中断都把增长参照点抬到当前读数。
根因(机制链)
修复(v2:单次中断保持 #5293 的安静)
nudge.absorbedDebt,并累计nudge.absorbCount;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 吸收记账;无新配置面。