Skip to content

[PR] fix(server): guard the #5974 probe and post-rebuild anchor against demoting the overflow-arm (#6865) - #6868

Open
sx4im wants to merge 1 commit into
ranxianglei:masterfrom
sx4im:fix-6865-probe-overflow-arm-guard
Open

sx4im wants to merge 1 commit into
ranxianglei:masterfrom
sx4im:fix-6865-probe-overflow-arm-guard

Conversation

@sx4im

@sx4im sx4im commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

The #5974 probe writes its local estimate onto the session baseline without an overflow-arm guard, so an armed session gets its tag demoted to "estimate" before the #5880 guard reads it. That re-opens the #5880 400-livelock on a different code path.

What changed: both unguarded writes in preflightCompressIfNeeded now skip the demotion while the arm is active, the probe write and the post-rebuild anchor. The anchor needed the same guard: the issue assumes it is guarded, but no applyPostRebuildBaselineAnchor exists on master and the probe guard alone does not hold the arm through the turn. The regression test proves it, the armed case fails on unfixed code.

Tests: new test pins both directions, 2/2 green, and it fails on unfixed code as expected. Neighbour tests green (issue2484, issue2313, issue1839, issue5191, issue5974-preflight-view-divergence, e2e-overflow-selfheal). Typecheck clean on the touched files. Full suite verdict is remote CI.

Fixes #6865

… against demoting the overflow-arm (ranxianglei#6865)

The ranxianglei#5974 corrective-second-pass probe writes its local estimate onto the
session baseline without an overflow-arm guard, demoting the active
overflow-arm tag to "estimate" before the ranxianglei#5880 guard reads it and
re-opening the ranxianglei#5880 400-livelock on a different code path. The same
unguarded write exists on the post-rebuild anchor in the same preflight
flow: the probe guard alone does not hold the arm through the turn (the
regression test proves it). Both writes now skip the demotion while the
arm is active, same doctrine as relay.ts ranxianglei#2484 armFailureShrink.

Regression test pins both directions: armed stays overflow-arm (tag plus
the separately recorded overflowArmTokens ceiling), unarmed still demotes
to estimate as before.
@ranxianglei ranxianglei changed the title fix(server): guard the #5974 probe and post-rebuild anchor against demoting the overflow-arm (#6865) [PR] fix(server): guard the #5974 probe and post-rebuild anchor against demoting the overflow-arm (#6865) Nov 15, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Dup check: PR #6868 is a parallel second PR closing #6865 — PR #6867 (opened ~1 min earlier) closes the same issue and guards the same overflow-arm demotion. The two overlap: #6867 guards the probe write (extracted to applyProbeBaselineAnchor in session.ts); #6868 guards the probe write AND the post-rebuild anchor write (both inline in server.ts).

Critical coordination problem (merge blocker): Three open PRs all rewrite the same two baseline-write sites in preflightCompressIfNeeded:

PR probe write (server.ts:4297-4301) post-rebuild anchor write (server.ts:4374-4378)
#5899 (the #5880 fix, open) — replaces with applyPostRebuildBaselineAnchor (session.ts)
#6867 (agent probe guard, open) replaces with applyProbeBaselineAnchor (session.ts) —
#6868 (this PR, open) adds inline && source !== "overflow-arm" adds inline && source !== "overflow-arm"

#6868 cannot merge alongside both #5899 and #6867. The owner must pick which approach to keep.

Technical assessment of #6868 (verified live):

8问 (PR review):

  1. 是什么问题: [Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 的 probe 把本地估算值写到会话基线时漏了 overflow-arm 守卫,已武装(armed)的会话在 Estimate-only fit decision ignores system prompt + tool definitions, and the output-budget clamp never fires → 400 CONTEXT_WINDOW_EXCEEDED on sessions that bili thinks fit #5880 守卫读取前被降级为 "estimate",在另一条代码路径上重开 Estimate-only fit decision ignores system prompt + tool definitions, and the output-budget clamp never fires → 400 CONTEXT_WINDOW_EXCEEDED on sessions that bili thinks fit #5880 的 400-livelock。
  2. 什么原因导致的: [Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 的修复("corrective second pass" probe, server.ts:4298)漏了守卫;post-rebuild anchor(server.ts:4375)同样漏了——master 上不存在 applyPostRebuildBaselineAnchor(decision request: #5974 preflight probe demotes the overflow-arm (unguarded estimate write, re-opens the #5880 400-livelock) #6865 的假设是错的)。
  3. 影响范围与严重程度: 仅影响已武装(overflow-arm 激活)的会话——这类会话依赖 arm 作为可信上限,若被 probe/anchor 降级为 estimate,会重触发 400 CONTEXT_WINDOW_EXCEEDED livelock。未武装会话不受影响。严重度:特定条件下有问题(armed 会话 + 大窗口 code-heavy 负载)。
  4. 怎么修复的: 在 preflightCompressIfNeeded 的两个未守卫写入点(probe + post-rebuild anchor)各加 lastInputTokensSource !== "overflow-arm" 守卫——armed 时跳过降级,保留 arm 标签。
  5. 是否有回归问题: 无。未武装会话的 usage→estimate 降级行为保持不变(test b 修复前后都通过);所有 3 个 "estimate" 降级点现在都有守卫。
  6. 是否破坏缓存: 不涉及(会话基线标签守卫,不影响缓存/重试/游标)。
  7. 是否改了设计方向: 不涉及(纯守卫,无架构变化)。
  8. 是否引入了新的配置: 不涉及。

结论: #6868 的代码本身正确、完整、无回归,测试有牙,CI 绿。但存在严重协调冲突——与 #5899 和 #6867 都改同一处代码,且 #6867 和 #6868 都关 #6865。需 owner 决策保留哪条路线。


🔶 需要决策

背景: 三个 PR 都在修 #5880/#6865 的 overflow-arm 降级问题,且都改 preflightCompressIfNeeded 的同一处代码,互相冲突。

待决问题: 保留哪条修复路线?

选项:

推荐: A——抽到 session.ts 跟现有 armFailureShrink 模式一致,更干净;两个方向都有测试覆盖。

不决定的默认行为: 三个 PR 都挂着、互相冲突、无法合并——#5880/#6865 的 livelock 修复被阻塞。


标签: 建议 bug / p1 / scope/kernel(本环境 label API 与 add-label.sh 均不可用,未能自动打标,请 owner 手动补)。

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decision request: #5974 preflight probe demotes the overflow-arm (unguarded estimate write, re-opens the #5880 400-livelock)

2 participants