Repository navigation
[PR] [Pi/Responses] consume announced native-compaction boundary in the /v1/responses lane - #3480
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4650-pr.3480.dce3b31This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3480.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 检索 open+closed issue/PR(含近期):本 PR 针对的是「四条 prepare 车道里唯独 开始独立审查:拉取分支 |
The /v1/responses preparation path was the only one of the four prepare lanes that never consumed an announced native-compaction boundary (pi session_compact -> POST /__bili/plugin/compact -> markCompactionBoundary). It only reconciled the separate nativeCompactionBoundary rebase marker, so compactionBoundary.pending stayed true forever and pre-compaction blocks were neither archived nor ref-pruned; the session carried dead fold state indefinitely after a pi compact. Wire in applyCompactionArchive exactly as the anthropic/openai/google lanes do: snapshot activeBefore before processTurn's syncBlocks deactivates covered blocks, then archive against the post-turn live ids. Gate on compactForm === undefined so a codex compaction-generation request (trigger or recognized prompt form) cannot eat an unrelated pending marker; reuse the already-computed compactForm at the forge branch instead of re-deriving it. Regression suite tests/issue3477-responses-compaction-archive.test.ts covers plugin-mode + proxy-mode consumption, trigger/prompt-form non-consumption, and failure-isolation of committed bookkeeping. Closes #3477
d89eb55 to
4aabb3b
Compare
(ai: vllm-qwen/qwen3.8-27b) Review 结论:可合并(等 CI test lanes 绿;合并由人执行)独立审了 diff、源码语义、测试有效性与 master 现状,结论如下。 1. 是什么问题: 2. 什么原因导致的:接线遗漏,不是设计取舍。三条兄弟路径(anthropic/openai/google)都在 processTurn 后调 3. 影响范围与严重程度:所有走 Responses 线、经过插件渠道宣布 compact 的会话(plugin/proxy 两种模式都中)。无可见报错、请求照常通过,但 ACP 状态持续泄漏(ref 映射累积、pre-compaction 归档缺失、decompress 兜底记录丢失)——内部状态腐化类,运行越久越重。#3477 里附带的缓存命中率下降时间线是另一件在查的事:本 PR 不碰任何 wire 字节与缓存键,与该现象无关(既不修复也不加重)。 4. 怎么修复的:照抄兄弟路径的既有模式——processTurn 前快照活跃块,处理完压缩后历史再调 5. 是否有回归问题:逐项过完触碰路径的既有行为,无意回归未发现:
两个观察(均非本 PR 引入,不拦):① 宣布之后若下一轮仍重发完整历史(截断未落地),该轮会消费掉标记(归档 0 块),真正的截断历史到达时已无标记——anthropic/openai/google 三路径今天就是同样性质,本 PR 是达到对等而非新增风险;② responses 路径没有 6. 是否破坏缓存:不涉及。只动服务端簿记(metadata + ref map),wire 字节、prefix-cache 键、重试策略全部原样。 7. 是否改了设计方向:不涉及。纯补齐第四条路径缺失的消费者,架构/边界/数据流不变。 8. 是否引入了新的配置:无。 测试有效性:route 级真端点(seed/fold 走 我做的核验与动作:
调度提示:在途 PR #3490(lane 决策点收尾)与 #3467(preflight 超限出口)也都改 prepare-responses.ts——若它们先合入,合并本 PR 前需再 rebase 一次确认,避免热文件语义冲突。 判定:可合并(CI test lanes 绿后即可;合并操作请人工执行:https://github.com/ranxianglei/billion-context/pull/3480)。 |
(ai: vllm-qwen/qwen3.8-27b) CI 已全绿(补上审查结论里唯一悬着的一项)rebase 后的 head 之前唯一的红是
结论维持上一条评论:可合并。 合并仍由人来操作:#3480 提醒一句(与首条一致):若 #3490(lane 决策点收尾)或 #3467(preflight 413)先合入,合并前需把本分支再 rebase 一次——两者与本 PR 改的是同一文件的不同区段,冲突风险低但顺序敏感。 |
|
这个自带压缩是不是应该默认拒绝?而不是通过? |
(ai: vllm-qwen/qwen3.8-27b) 好问题——我按代码把三个客户端的「自带压缩」现状逐一核了一遍,结论:能拒的两个客户端(dsh、codex)现在就已经是默认拒绝/拦截,只有显式 opt-in 才放行;而本 PR 的对象 pi 在物理上没有可拒绝的时机。 1. Dsh —— 已经是默认拒绝。 wire 级守卫( 2. Codex —— 默认就是拦截。 3. Pi(本 PR 对象)—— 「拒绝」不成立。 pi 的 session_compact 在 pi 客户端内部完成; 为什么「默认拒绝」不能替代这层消费逻辑:即使姿态再严,总有 bili 看不见的落地路径——dsh desktop 的 summarizer 直接调 结论:本 PR 没有改变任何客户端的默认姿态,它只是补上 responses lane 对「已落地压缩」缺失的记账,让四条 lane 对齐。如果你想进一步收紧,唯一还有空间的方向是给 pi 加 dsh 式的 wire 级默认拒绝守卫——但前提是拿到流量证据:pi 的自带压缩生成请求确实以可识别的形式经过 bili(目前代码库里没有任何 pi 压缩请求的 wire 签名)。有证据了我单独立项做,现在不投机建设。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.659-master.33accd1 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3477
What was broken
The
/v1/responsespreparation path was the only one of the four prepare lanes that never consumed an announced native-compaction boundary. When pi'ssession_compactfires, the plugin postsPOST /__bili/plugin/compact, which setscompactionBoundary = { at, pending: true }. The anthropic / openai / google lanes then callapplyCompactionArchiveon the next turn to archive the deactivated blocks and prune obsolete refs — but the responses lane only reconciled the separatenativeCompactionBoundaryrebase marker (reconcileNativeCompactionBoundary) and never touchedcompactionBoundary.pending.Result: after a pi compact on a pi/Responses session, the pending flag stayed
trueforever and pre-compaction fold blocks were neither archived nor ref-pruned — the session carried dead state indefinitely. Reproducible in both plugin mode and proxy mode.Fix
Wire in
applyCompactionArchiveexactly as the sibling lanes do (src/server/prepare-responses.ts):activeBeforebeforeprocessTurn'ssyncBlocksdeactivates the covered blocks;compactForm === undefinedso a codex compaction-generation request (trigger or recognized local prompt form) cannot eat an unrelated pending marker;compactFormat the forge branch instead of re-deriving it (no forge behavior change).Behavior change (old → new)
/v1/responses, an announced/__bili/plugin/compactboundary was never consumed —compactionBoundary.pendingstayedtrue, pre-compaction blocks were never archived, refs were not pruned./v1/responsesturn consumes it exactly once — archives the deactivated blocks, prunes refs to the live ids while pinning the ref high-water mark, clearspending. Compaction-generation turns (trigger / prompt form) deliberately skip it.Config surface
None. No config field, env var, or CLI flag added / renamed / re-semantics'd.
Tests
New regression suite
tests/issue3477-responses-compaction-archive.test.ts(route-level, mirrors the #2451 harness):Local:
npm run typecheckclean; targeted suite 5/5; adjacent suites (compaction-archive,issue2451-dsh-responses-compaction,native-compact-terminal,codex-compact,codex-local-compaction,compaction-trigger-finality) 38/38. Full regression left to CI.