Repository navigation
[PR] fix: esc-interrupted output no longer triggers the growth-cadence nudge on resume (#5298) - #5356
Conversation
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 独立检索 open+closed issue/PR(按失败签名「abort/Esc 中断 + nudge 误触发」与机制「growth reference re-anchor」查过),无既有条目覆盖本缺陷;PR 正文自查的相关项(#5300 per-session opt-out、#4831 precompute folds、#3006/#3012 escalation-vs-suppression、#5055 model-decided nudge)机制均不同,作者查重结论成立。 标签: bug + pi + scope/kernel + p2(缺陷类;报告宿主 pi;失败域是压缩决策面的增长节奏记账;能用但有明显问题→p2)。 审核进行中,初步结论:
结构化八问结论随后跟上。 |
…5298 The original commit's title/message/comments cited #5298, which is an unrelated open decision request (dsh-injected user messages stealing the last-user-message protection slot). The bug report fixed here is #5293 (pi Esc-interrupt triggers compression injection); the test filename and the Closes line already said 5293. Comments/test labels only — zero behavior change. (review fix-up on PR branch)
(ai: vllm-qwen/qwen3.8-27b) 结构化八问(PR #5356 审核结论)1. 是什么问题 2. 什么原因导致的 3. 影响范围与严重程度 4. 怎么修复的 5. 是否有回归问题
6. 是否破坏缓存 7. 是否改了设计方向 8. 是否引入了新的配置 验证与处置记录
判定可合入(待 CI 绿)。方向正确、根因层修复、回归面清点干净、测试有牙;唯一遗留是标题里的错号(系统管道归属,仅记录)。 |
ranxianglei
left a comment
There was a problem hiding this comment.
审查完成(本地分支 @e2f3fdef,已合并最新 master @42cd5ba 并推送)。结论:代码通过,无阻塞项;CI 全绿即可人工合并。
冲突解决(本次推送)
分支落后 master 较多,试合并只有 src/plugin.ts 一处真实冲突:master(#5286 系)把 getSession 换成了 getSessionAsync(fork snapshot 冷恢复路径),本 PR 在同一 import 行加了 noteAbortedTurn。取并集一行解决——两侧改动正交、都保留。其余文件全部自动合并。验证:tsc --noEmit exit 0;新套件 2/2 + nudge/cadence 相关两批 59/59 绿(nudge-decide / fork-nudge-deadzone/trigger / anthropic-lane-nudge / issue1470 / issue3004 / issue3159 / issue3204 / issue3910-lane-nudge-wiring / plugin-nudge-injection / silent-backend-nudge / prepare-* / issue5293)。
修复本身核验
- 机制对症:故障链是「中断轮的部分输出从不报 usage → 续跑请求的重发历史里带着这段未计量质量 → 下一个 usage-grade 读数一跳正好等于这段 → flat-growth cadence 把跳变当有机增长」。「在见证客户端 abort 后、等表针真的越过锚点时再一次性上移基准」是对该因果的正确形状——与 applyCompression 成功后同一 full-reset 形状(清 shown 戳 + tier 节拍戳),不留半阈值残留。✓
- 事件门控而非启发式:只在
pipePluginChatWithStrip(:3654) /pipePluginResponsesWithStrip(:4522) 的 client-abort catch 里 stamp(且要求已有 metered 基线lastInputTokens>0);absorb 只认「meter > pre-abort anchor」才消费,flag 一次性用掉;>30min 静默过期。无 abort 的会话 flag 不存在 → 决策逐字节不变。✓ - 吸收时机正确:四个 prepare 全部在 processTurn 之前调用(openai:216 / responses:340 / anthropic:361 / google:199),传的就是本轮 meter tokenCount——先修基准再让内核做 nudge 判定,顺序无竞态。✓
- 边界如实披露:bare-proxy lane 不 instrument(dispatch catch 路径没有 session 对象)——我核实过 server.ts/handle.ts 确实无 noteAbortedTurn 挂载点,注释成立;inline-engine 走同一 pipe catch 所以覆盖到。✓
「彻底吗?只针对 pi 吗?」
不是 pi 专属。 挂点选在两个共享 plugin pipe 的 client-abort catch + 四个 wire prepare——任何走插件车道的客户端(pi/dsh/opencode/omp/codex pipe 都经过这两条 pipe),只要「中流 abort → 客户端把部分输出持久化进自己的会话 → 续跑重发」这一组合成立,就被同样处理。触发判据是 bili 侧观测到的连接中断事件,与是哪个 agent 无关。已知未覆盖面(按风险排序):① bare proxy lane(客户端直接把 base URL 指向 bili 的场景)没有 session 挂载点——同类问题在那条车道理论上仍存在,是文档化边界不是遗漏;② 首个 usage 之前就被 abort 的新会话(lastInputTokens<=0 不打标)——保守 no-op,实际被 growth floor(默认 50K)挡着,早期债务要一次未计量输出 ≥50K 才会立即触发,罕见;③ flag 在内存(重启即失)+ 30min 窗口——窗口内若客户端实际丢弃了部分输出(没有跳变),后续无关增长越过锚点会消费掉 flag,代价至多多等一轮 nudge 节拍,自愈。三者都不阻塞。
本地验证(正式全量留给远程 CI):定向批 59/59 + tsc 绿 + merge 后工作树干净。
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7547-pr.5356.65d36a9This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5356.tgz
npm install -g packageInstall instructions are refreshed on each push. |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.967-master.44fcbe4 # this exact build
npm install -g billion-context@master # always the newest merged build
|
(ai: vllm-qwen/qwen3.8-27b)
Closes #5293
查重: 不重复 (screened open+closed vs #5300 per-session opt-out, #4831 precompute folds, #3006/#3012 escalation-vs-suppression, #5055 model-decided nudge — different mechanisms).
What & why
In pi, pressing Esc mid-stream and continuing triggers an immediate compression nudge injection ("压缩注入"). Other agents with the same persist-aborted-partials behavior are affected too.
Mechanism (verified against pi source, earendil-works/pi packages/agent/src/agent-loop.ts:254):
Fix
Event-driven re-anchor, host-side only (no kernel change):
noteAbortedTurn(session)— stamped in both plugin pipe client-abort catches (src/plugin.ts, after settleUsage has landed the pre-abort input size), recordingsession.transient.abortReanchor = {anchor, at}.absorbAbortedTurnGrowth(session, tokenCount)— called in all four prepares right before the main processTurn. When the meter has actually moved past the pre-abort anchor (the persisted partial now shows up in measurement), it re-anchors the low-water reference to the current reading and clears the pending-nudge stamps — same full-reset shape as applyCompression's post-success reset (kernel compress.ts). Stale flags (>30 min) drop without touching state; sessions without an abort see byte-identical decisions.This is the deliberate inverse of #3674's retired event-gated re-anchor: that one moved the reference on drift heuristics and dead-zoned small drops; this moves it UP, gated on a witnessed client abort, for a known unmeasured mass.
Behavior change (disclosed per policy)
Boundaries
Tests
New
tests/issue5293-abort-nudge.test.ts: unit edge cases (skip/no-op/wait/consume/stale-drop/max-guard) + hermetic integration scenario through the real proxy (pi plugin lane, anthropic wire): warmup below floor → abort mid-SSE with persisted partial → resume turn reads stale anchor (no nudge, flag survives) → debt turn absorbed (no nudge = the fixed behavior) → organic growth still fires the nudge later (negative direction, #3617 discipline). Verified RED without the src changes (debt-turn assertion fails: nudge present) and GREEN with them.