Repository navigation
fix: codex lane — keep the proactive compression channel alive (#3008) - #3018
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3456-pr.3018.696e3ecThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3018.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 完成——已 rebase 到当前 master(96f2f38,Merge #3010)逐项核验,零冲突。结论先行:代码本身可合(质量门全过),但与 #3019 存在机制级重叠,两个 PR 不能按现状都合并。查重:非重复立项(#3008 CODEX 取证 vs #3004 dsh-tui 取证,不同会话),但同机制族、同文件族,需排序去重(见下)。 结构化八问1. 是什么问题:codex lane 的主动压缩通道被双重夹死——advisory nudge 被 self-heal 以 "injected but nothing ever compressed" 判死后永久锁存(上下文单调增长永远产生不了恢复证据,证据式解除自锁,实测静默 83 分钟);同时 decide side call 继承 host reasoning 旋钮, 2. 什么原因导致的:三个独立根因,各修各的源头——① D1 抑制锁存的解除条件与唯一恢复来源(nudge→压缩)构成循环等待;② side call 以 3. 影响范围与严重程度:任何 nudge 通道被误判死的会话(上下文单调增长 + 模型/客户端不配合压缩时触发,不限 codex lane);codex 显式压缩路径(forge dispatch)在幻值压力下退化为 passthrough。特定条件下有问题而非完全不可用——事后 detect+rebase 兜底(#2372)仍工作,数据不丢,但主动压缩实质停摆(本会话最终由 codex 自己压掉 725,892→11,037,bili 只认账)。 4. 怎么修复的:三机制均修产生侧而非遮症状——① suppress-nudge 锁存加时限分支( 5. 是否有回归问题:逐条审过既有行为——
6. 是否破坏缓存:不涉及(未触碰缓存/重试/增量游标/去重键失效策略;prefix cache 无关)。 7. 是否改了设计方向:无。三机制全部骑在既有 self-heal 状态机 / decide ladder / codex compact gate 上,无新架构面;「不给冷缓存 continuation request 加拦截谓词」的边界处理正确(会伪造拦截普通 relay-cache 过期请求,灾难性假阳性)。 8. 是否引入新配置:无。 验证证据(rebased head 实测)
|
| 机制 | 本 PR | #3019 |
|---|---|---|
| 抑制锁存寿命封顶 | SELF_HEAL_SUPPRESS_MAX_MS = 30 min |
SELF_HEAL_SUPPRESS_CAP_MS = 10 min |
| side call 剥 reasoning 旋钮 | stripClientReasoning()(四 lane 内联调用) |
stripDecisionReasoningFields()(导出) |
| 抑制期内 ladder punch-through | —(到时才放行) | consumeFallback,每 3 连败一次 |
post-gate 投递台账(nudgeOutcome) |
— | 修 pre-gate willInjectNudge 为模型否决轮虚报投递 |
两者都改 evaluateSelfHealRound 同一恢复分支 + 四条 prepare lane + tests/issue2155-self-heal.test.ts → 先后合并必然语义冲突。建议:先合本 PR(rebase 干净已证、体量小、独有 codex compact 基线修复 + 措辞更正),随后 rebase #3019:删其重复常量与 strip 函数,保留独有部分(punch-through + nudgeOutcome 台账 + INJECT-PENDING 日志)——二者互补:punch-through 在 30min 窗口内即生效,台账减少虚假武装使 cap 更少触发。cap 取值(10 vs 30 min)请你拍板:30min 封顶最坏静默 ≈30min+5 轮;若要更紧可在后续统一为 10min。
范围外项(作者明确留在 #3008 checklist,同意留置)
- L1 trigger line 算术(强制线 737,600 vs 客户端不可观测的 725,892;字面尊重 modelContextLimit 反而更糟 840K≫725,892)——需产品决策;
- L3 native compaction 后台账重建(resetSessionCompression 清零 baseline stats,rebase 后 nudge 状态从零起步)——独立机制域。
判定
代码质量:可合(diff 小而净、每行 on-topic、测试有牙、文档中英同步)。流程:待 #3019 协调定序后再合——请确认合并顺序与 cap 取值,我可以随即将 #3019 做去重 rebase。分支当前 behind master,我本地已验证 rebase 干净;定序后我可推 rebased head 刷新 CI。
04c737b to
841a938
Compare
…pe docs (#3008) Delta-only rebase onto master (#3019 merged the shared mechanisms): - dropped from this PR (covered by #3019): stripClientReasoning (master has per-protocol stripDecisionReasoningFields incl. google nested generationConfig), SELF_HEAL_SUPPRESS_MAX_MS 30min cap (master has SELF_HEAL_SUPPRESS_CAP_MS 10min at top-of-evaluate + fallback punch-through + re-arm guard), TECHNICAL-NOTES D1 English hunks. - kept, unique: codexCompactGatePre now reads the evidence-grade input baseline (statusInputBaseline) instead of raw stats.lastInputTokens — an estimate-grade phantom reading self-disabled the safety valve at >=0.9x limit (#1492/#1839 discipline); comment corrected (90% is bili's backstop line, not codex's own point — 78.7% observed, client point unobservable). - kept: docs honesty — codexCompact interception covers explicit requests only; codex-tui auto-compaction is pure client-side and never transits the proxy (detect/rebase path #2372); conflict-watch remediation no longer claims 'intercepts native compaction by default'; zh D1 aligned with the merged 10-min cap. Closes #3008
841a938 to
98e4cf4
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.380-master.1928981 # this exact build
npm install -g billion-context@master # always the newest merged build
|
) Codex's local inline auto-compact (compact.rs run_inline_auto_compact_task, observed rust-v0.162.1) transits the proxy as an ORDINARY turn: full history plus the SUMMARIZATION_PROMPT template as the last user message. No compaction_trigger item, no /responses/compact call — the only wire signature is the prompt text itself, so the existing interception never fired and the request re-cached the full unfolded history (720,706 tokens in the ranxianglei#3008 incident). If the summarization call returned no assistant content, codex fell back to a placeholder summary (template header + last conversation message). - hasCompactionPrompt(): scan input[] backwards; the last message item must be a user message opening with the built-in template anchor. A user-overridden compact_prompt falls out of detection (documented) and transits verbatim. Mid-history quotes cannot match (only the final user message is tested). - buildPromptForgeBody(): one assistant message item + response.completed — exactly what codex's drain_to_completed records item-by-item; its summary_suffix = this text, so the compacted payload becomes codex's own SUMMARY_PREFIX + bili's fold summaries. Forge reuses the same safety gate (active block + <90% usage-grade baseline + transform ok) and the same captured-summaries ledger as the trigger form. - handle.ts: skip preflight when a forge is about to be served locally. - Docs: codexCompact scope copy updated in the config reference (EN/ZH), website, and conflict remediation — 'auto-compaction never transits the proxy' was false and is now corrected everywhere (ranxianglei#3018 follow-up). Tests: detector matrix (anchor-last/quotes/assistant-last/overridden template), forge shapes (SSE + JSON), e2e forge (upstream untouched, summaries captured) + gate-fail/pass-mode/non-codex passthrough.
Closes #3008
What
Session CODEX-01A130C1 forensics proved bili's proactive compression channel was dead for over an hour while usage sat at ~75%: the advisory nudge was suppressed by self-heal with no possible recovery (the recovery evidence can never arrive while context grows monotonically), the decide side-calls kept coming back empty (inheriting
reasoning_effort=maxagainst a 200-token budget), and the codex compact safety valve had self-disabled on an uncalibrated estimate-grade token count. This PR fixes all three mechanisms plus the misleading docs that made the issue get filed as "the intercept branch never entered".Verification against the forensics
compaction_triggeritem from/compact, orPOST /responses/compact). codex-tui 0.162.1's auto-compaction is purely client-side — byte-verified from the rollout: thecompactedevent at 02:19:53.351Z carries summary = fixed template header + final assistant message VERBATIM, zero wire traffic. There is no request to intercept.Behavior changes (old → new)
src/session-self-heal.ts): old = suppression lasts until a compression reduction or bili tool use occurs — with monotonic context growth that is forever (observed 1 h 23 m 49 s in bili 对 Codex 原生压缩的拦截分支在本会话没进入(貌似自己截断自己了) #3008); new = it also lifts afterSELF_HEAL_SUPPRESS_MAX_MS= 30 min without either, re-arming the advisory nudge; it re-suppresses after another 5 idle rounds. Evidence-based lift unchanged and still wins. No new config knob (会话卡死自愈机制:卡死模式检测与代理侧主动补救 #2155 convention: constant).reasoning/reasoning_effort/thinking/thinkingConfig, so areasoning_effort=maxmain request burned the entire 200-token decide budget on thinking and came back empty (14/31 empty responses in the forensics); new = those keys are stripped from the side body before dispatch. Previously-empty decides can now return verdicts; sessions previously cycling through the failure ladder may inject model-decided nudges where they previously fell back to legacy advisory.src/codex-compact.ts): old = rawstats.lastInputTokens(can be an estimate-grade phantom — 970,475 uncalibrated in bili 对 Codex 原生压缩的拦截分支在本会话没进入(貌似自己截断自己了) #3008 — which closed the valve above 829,800 while real usage was far below); new =statusInputBaseline()(usage/overflow-arm grade readslastInputTokens, else the retained real usage anchor, else 0). Usage-grade and overflow-arm values still close the valve identically; only estimate-grade phantoms stop self-disabling it.codexCompact/BILI_CODEX_COMPACTwere described as covering "codex native compaction" generally; now scoped to explicit compaction requests only, with the client-side auto-compaction → detect+rebase ([bug] Codex local auto-compaction can destroy existing bili fold substrate instead of rebasing #2372) boundary stated. User-facing text only, no behavior change.Config surface
No new env vars, config fields, or CLI flags.
SELF_HEAL_SUPPRESS_MAX_MSis an internal constant per the #2155 no-knobs convention.Tests
tests/issue2155-self-heal.test.ts: +2 unit tests (time-cap re-arm incl. log line; sub-cap stays suppressed).tests/nudge-decide.test.ts: +1 unit test (strip removes exactly the four reasoning knobs, nothing else).tests/codex-compact.test.ts: existing gate matrix pinned to usage-grade source; +1 test (estimate phantom doesn't close the valve; usage/overflow-arm do; no anchor → open).tests/nudge-model-decided.test.tse2e lane (39 + 4 pass). Full suite left to CI per local-testing discipline.Out of scope (checklist items left in #3008)
modelContextLimitwould make THIS race worse (840K >> 725,892), so neither denominator wins deterministically. Product decision needed (learned-point cap vs explicit-limit precedence).resetSessionCompressionzeros all baseline stats, so post-rebase nudge state starts from scratch ("max compressible 0"). Days of engineering; tracked as a checklist item in the issue.