Repository navigation
[PR] fix: carry the uncovered recent tail in codex forge compaction handoffs (#4035) - #4045
ranxianglei wants to merge 4 commits into
Conversation
Pass-by cleanup found while working #4035: seven of the ten symbols imported from ./codex-compact.js were unused (leftovers of the forge logic moving into prepare-responses); only CODEX_COMPACT_HEALTH_RATIO, codexCompactMode and isCodexClient are actually referenced.
…fs (#4035) The trigger/prompt forge handed off ONLY the active-block summaries. The recent work between the last fold and compaction time (assistant progress, tool drafts/results not yet folded) sat in neither the summaries nor codex's retention (remote v2 keeps user messages only; inline adopts a prose summary), so after a local forge compaction it vanished from the model's view and the model regressed to older progress — while a real upstream compaction summarizes the WHOLE input. - collectUncoveredTailItems: coverage-aware selection over the wire layout — slots covered by an active fold stay summarized, partially covered multi-core slots are skipped honestly (carrying the whole item would resurrect folded bytes), everything else rides byte-exact (thinking-family included verbatim per KDD #10); the prompt-form template message is excluded as instruction, not content. - Forged blobs gain a v2 JSON envelope (bili:acp:v2:) carrying summaries + tail items; empty tails keep the legacy plain-sentinel byte shape stable across builds, pre-v2 blobs still expand (mid-session upgrade). - Echo-time expansion splices handoff + tail back in place, deduping (key-order-insensitively) any tail item codex itself still carries verbatim in the same request. - Prompt form renders the tail as a labeled section inside the adopted summary text (its channel is prose by protocol). - Fork-adoption agent-side replica mirrors the expansion for parity (tests/pi-omp-fork-adopt pins it against incomingCoreMessages). Behavior change (disclosed): after a local forge compaction the model now SEES the previously-dropped recent work until ACP folds it — post-forge context is larger than before by design; zero-egress (upstream untouched) and the endpoint form are unchanged.
a4cb6ab to
dd8fba1
Compare
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4827-pr.4045.efb0b41This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4045.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…cs-sync gate) The generated param-ref blocks must come from website/config-reference/*.yaml; hand-editing CONFIGURATION*.md drifts. Seed now carries the coverage-completeness disclosure in desc_en/desc_zh; artifacts regenerated.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 检索 open+closed issue/PR:无其他针对 #4035 的并行修复工作。最接近的 #4247(交接文档缺最新助手回复)是另一机制—— 标签: bug / codex / scope/wiring / p1(客户端接入层协议缺口;数据丢失类——本地 forge compaction 后近期工作从模型视图消失,核心承诺失灵)。 八问1. 是什么问题 2. 什么原因导致的 3. 影响范围与严重程度 4. 怎么修复的 5. 是否有回归问题
6. 是否破坏缓存 7. 是否改了设计方向 8. 是否引入了新的配置 测试有效性单测矩阵双向齐全(covered/partial/no-core/inactive-block/sub-id 归一化 × 模板排除 opt-in × v2 构建形状 × malformed 三类 drop);e2e 正是 issue 要求的最小场景全闭环:old fold + uncovered draft → trigger → blob 带 tail 且不重带 covered 内容 → client echo → 下一轮 wire 请求按序含 tail、codex 自留副本去重;另有 no-tail→legacy blob 与 prompt-form 渲染两个 e2e。断言有牙(字节级 includes/excludes、去重计数),不是恒真断言。 CI 状态与合并判定head 判定:代码审查通过,可合的前提是先 rebase ——分支落后 master 224 个提交,其中 |
What & why (issue #4035)
Codex trigger/prompt forge compaction handed off ONLY the active-block summaries. The recent work between the last fold and compaction time (assistant progress, tool drafts/results not yet folded — 21.7K tokens in the incident session) sat in neither the summaries nor codex's own retention (remote v2 keeps USER messages only; inline prompt form adopts a prose summary), so after a local forge compaction it vanished from the model's view: the model regressed to older progress while bili's local archive still held the content. A real upstream compaction summarizes the WHOLE input — the local forge must be coverage-complete.
Verified against the incident's exact client tag (
rust-v0.163.0-alpha.10.2):build_v2_compacted_historyretains only user messages (+ narrow conditions), never assistant/tool/reasoning — so the forged blob is the ONLY survival channel for that content.Fix
collectUncoveredTailItems(src/codex-compact.ts): coverage-aware selection over the wire layout. Covered slots stay summarized; partially-covered multi-core slots are skipped honestly (carrying the whole item would resurrect bytes the kernel folded out of it); everything else rides byte-exact — thinking-family included verbatim per KDD release v0.1.3 #10 (move, never rewrite). The prompt-form template message is excluded (instruction, not content).bili:acp:v2:+{v, summaries, tail}). Empty tails keep the legacy plain-sentinel byte shape stable across builds; pre-v2 blobs still expand, so a mid-session upgrade never loses an already-echoed marker. Malformed v2 → drop (fail-safe).Behavior change (disclosed)
After a local forge compaction the model now SEES the previously-dropped recent work until ACP folds it — post-forge context is larger than before, by design (that is the fix). Zero-egress contract unchanged (upstream still untouched); endpoint form unchanged; no-tail sessions see a byte-identical blob to before. No new config surface.
Tests
Closes #4035