Skip to content

[PR] fix: use measured evidence for Codex compaction gating - #7097

Closed
ReineLan wants to merge 1 commit into
ranxianglei:masterfrom
ReineLan:2026-11-18_codex-compact-evidence
Closed

ReineLan wants to merge 1 commit into
ranxianglei:masterfrom
ReineLan:2026-11-18_codex-compact-evidence

Conversation

@ReineLan

Copy link
Copy Markdown
Contributor

Closes #7096.

Summary

The Codex compaction gate uses the last measured input or bounded overflow-arm evidence when checking its 90% guard. After an interrupted send, the estimate selected by statusInputBaseline() can otherwise veto interception despite low measured usage, or permit interception despite high measured usage. The gate and status reader now share the evidence lookup. The status reader applies its existing freshness fallbacks after selecting its baseline.

Verification

@ranxianglei ranxianglei changed the title fix: use measured evidence for Codex compaction gating [PR] fix: use measured evidence for Codex compaction gating Nov 18, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重 (duplicate screening): not a duplicate. This is the only PR targeting #7096. Related but distinct: open PR #4040 also modifies codexCompactGatePre — it fixes the block-activity condition (stale active flags, #4036) while this PR fixes the baseline-provenance condition. Different mechanism, orthogonal diffs; if #4040 merges first this branch needs a trivial rebase (no semantic interaction).

Independent verification (I did not take the PR description on faith):

Behavior change (intended, per #7096's stated expectation — old → new):

  • Old: the gate judged on statusInputBaseline = evidence baseline + two estimate fallbacks.
  • New: the gate judges on evidenceInputBaseline = last measured usage / bounded overflow-arm / retained usage-grade anchor, only.
  • Consequence A (the fix): high estimate + low measured usage → previously vetoed (forward → upstream context_window_exceeded) → now intercepted (forge).
  • Consequence B (restoration): low estimate + measured usage ≥90% → previously intercepted → now native fallback (restores the preflight fail-fast × soft-protection livelock: over-window payload never recovers, permanent 502 loop #332 backstop intent: measured pressure at the backstop line means ACP is not keeping up).
  • Consequence C: the stale-small anchor fallback no longer substitutes inside the gate.
  • Status surfaces (acp_status, panel, live nudge) are byte-identical in behavior; wire shapes and the forge path are unchanged.

结构化八问

  1. 是什么问题:中断的发送(无 usage 回报)留下的本地上界估计被 Codex 压缩门拿去判 90% 健康线;估计越过线时 bili 拒绝自己的压缩交接,把全量重放转发给上游,上游以 context_window_exceeded 拒绝,会话卡死。
  2. 什么原因导致的:[Bug] statusInputBaseline falls back to lastUsageGradeTokens instead of the calibrated local estimate — so one 4.7k side-request sample blocks folding for 4 hours | #1595 承诺的"改用本地估算"兜底在 statusInputBaseline 里没有实现,一次 4.7k 侧请求样本即可挡住折叠 4 小时 #4383 为状态/压力展示面在 statusInputBaseline 里加了两层估计回退(cycle-stale → localInputEstimate;stale-small → contextEstimateTokens),而 Codex 门注释里声明"只用 evidence-grade"却复用了这个函数,静默继承了回退——门在 [Bug] statusInputBaseline falls back to lastUsageGradeTokens instead of the calibrated local estimate — so one 4.7k side-request sample blocks folding for 4 hours | #1595 承诺的"改用本地估算"兜底在 statusInputBaseline 里没有实现,一次 4.7k 侧请求样本即可挡住折叠 4 小时 #4383 之前的语义(纯证据基线)被状态回退覆盖。
  3. 影响范围与严重程度:触发条件 = proxy 模式 + Codex 宿主 + 中断发送(无 usage)+ 高估计 + 有活跃折叠 + 实测用量 <90%。命中时该会话压缩失败、上下文大到发不出去,唯一出路是弃掉上下文(新线程/清历史)——会话不可用类,p1。
  4. 怎么修复的:把证据级核心从 statusInputBaseline 抽成具名单元 evidenceInputBaseline(实测 usage / overflow-arm / 保留的 usage-grade 锚点);门改用它,状态面保留原有回退。门与状态读者共享同一证据查找,两个面各得其所。
  5. 是否有回归问题:statusInputBaseline 重构行为保持([Bug] statusInputBaseline falls back to lastUsageGradeTokens instead of the calibrated local estimate — so one 4.7k side-request sample blocks folding for 4 hours | #1595 承诺的"改用本地估算"兜底在 statusInputBaseline 里没有实现,一次 4.7k 侧请求样本即可挡住折叠 4 小时 #4383/Status readers still trust estimate-grade failure baselines after #1846 #2029 全套 17 测试通过);状态面、wire 形状、forge 路径均未动;阈值 90% 未变。门的判定语义在三个场景变化,全部是 Codex compaction falls through when an interrupted send leaves a high local estimate #7096 声明的期望行为(A 高估计+低实测→拦截;B 低估计+高实测→原生回退;C stale-small 不再进门内替代)——有意变更已披露,无意回归未发现。fail-fast 变吞错:无。
  6. 是否破坏缓存:不涉及——缓存键、重试、增量游标、去重键均未触碰。
  7. 是否改了设计方向:无架构转向;反而收紧了既有原则——决策路径只用 evidence-grade 基线,状态面才可用回退。抽取让共享证据查找成为可命名的单元。
  8. 是否引入了新的配置:无。

结论:可合(approve)。 唯一提醒:open PR #4040 改同一函数(block-activity 条件,正交)——若它先合入,本分支需一次琐碎 rebase;两者合起来才是该函数的完整修复面。

@ranxianglei

Copy link
Copy Markdown
Owner

此 PR 的内容已整体进入批量 PR #7107(逐 commit 原样 cherry-pick,作者与 commit message 保留,已合并)。

This PR's changes have been merged verbatim (commit-by-commit, authorship preserved) via the batch PR #7107. Closing this to avoid a duplicate merge. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex compaction falls through when an interrupted send leaves a high local estimate

2 participants