Skip to content

[PR] fix(preflight): structurally doomed futile rounds answer 413/non-retryable instead of a 502 spin (#4563) - #6617

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-14_preflight-futile-round-deterministic
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-14_preflight-futile-round-deterministic

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #4563

Problem

A preflight round that walks the whole compression pool and still cannot fit the
payload — no foldable target left, net ~0 tokens saved — was answered 502 /
retryable
. Status-code-driven hosts (opencode, OMP) read a 502 as transient and
spun the full retry budget (~10 × ~84s) on a payload that can never fit. A second
field report (bili 0.1.212, OMP host) confirms the same spin even when bili logs
retryable=false
: the host keys on the 502 status code, not the flag. The log
also said "the distillation summary was unavailable" with 0 summary calls —
misleading, because no summary was even attempted (the fold projection resolved
the span to nothing; that is not a summarizer outage).

Root cause

preflightCompress has five exhausted verdict sites. Four of them set the
deterministic field; the tier-distillation-recovery-failed site — the one a
futile near-window round actually hits — omitted it. deterministic=undefined
(falsy) means the server never takes the 413 path, and progressContinues
(exhausted && !deterministic && compressedRanges>0, server.ts:4682) fires on the
fold count, not net shrink — so a net-0 round is advertised as "progress may
continue" and answered 502/retryable.

Fix (at the producer, not the server)

Track the structural termination cause inside attemptTierRecovery and carry it
into the verdict as the deterministic flag:

  • structural — doomed for the identical payload → deterministic=true: no
    candidate span survived the position/budget gates; the fold projection resolved
    the span to no target; the projection refused the apply; or a distill netted
    nothing with nothing saved before it.
  • relay-dependent — may still recover → deterministic=false: the summary
    call threw; the summary was unusable; the fold targets changed while awaiting
    the summary; or the bounded call-budget cap was hit.

server.ts already maps exhausted && deterministic && !payloadFitsWindow →
413 (server.ts:4675) and derives retryable from !deterministic via
progressContinues (server.ts:4682/4690) — so no server change is needed.
Structural futile rounds now answer 413 / non-retryable (a status hosts honor
as terminal); relay-dependent failures stay 502 / retryable (a recovered relay
can complete the distill, so retrying is legitimate).

Also disambiguate the "unavailable" why: each stop site now names the real cause
(a projection that resolved to no target is reported as such, not as a summarizer
outage).

Behavior change (disclosed)

  • Old: a structurally doomed tier-recovery round (no foldable target left,
    net ~0 saved) → 502, retryable true (via progressContinues) or false
    (via compressedRanges==0) — both spin status-code-driven hosts.
  • New: the same round → 413, retryable=false. Hosts treat 413 as
    terminal and stop retrying.
  • Unchanged: relay-dependent tier-recovery failures (summary-call error,
    unusable summary, racy target, budget cap) still → 502 / retryable — a
    recovered relay can complete the distill.

Tests

Two regression tests in tests/issue2952-preflight-tier-recovery.test.ts
(reusing that file's harness), asserting both directions (gate-test discipline):

  • a structurally exhausted round carries deterministic=true (→ 413);
  • a relay-dependent failure (summary upstream 500) carries deterministic=false
    (→ 502).

npm run typecheck clean; targeted suites green (issue2952-preflight-tier-recovery
6/6, preflight-empty-summary 9/9). Full-suite verdict is the remote CI test
lanes on the pushed head.

…nistic (#4563)

The tier-distillation-recovery-failed exhaustion site was the one site omitting the deterministic flag, so a futile round that walked the whole pool (no foldable target left, net ~0 saved) was answered 502/retryable and status-code-driven hosts spun on a payload that can never fit. Carry the recovery's own structural determination into the verdict: structural -> 413/non-retryable (server.ts maps exhausted+deterministic+!fitsWindow to 413), relay-dependent -> 502 (progress may continue on a smaller baseline). Also name WHY an unavailable stop happened (a projection that resolved to no target is not a summarizer outage).
@ranxianglei ranxianglei changed the title fix(preflight): structurally doomed futile rounds answer 413/non-retryable instead of a 502 spin (#4563) [PR] fix(preflight): structurally doomed futile rounds answer 413/non-retryable instead of a 502 spin (#4563) Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-14_preflight-futile-round-deterministic (e64728e)

Latest build — install this exact version

npm install -g billion-context@0.0.9668-pr.6617.18414f5

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
e64728e billion-context@0.0.9668-pr.6617.18414f5 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6617.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策

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

查重结论:本 PR 的修复与在途批量 PR #6435 的 #5764 修复同根因、同代码行、互相冲突——两者都给「结构性耗尽的 tier-recovery」补 deterministic 标志(→413),但改法不同,合入必撞。这是本轮 review 的关键发现,先说清楚。

审核结论(独立做过,非复读 issue):

关键冲突(拦合并):

待决问题:两个 PR 修同一根因,如何归并?

选项:

推荐 A,理由:先来后到(#6435 先开且是批量);#6617 判定是超集、更对,但必须吸收 overflowArmed 守卫;归并后一个根因一个 PR。

不决定的默认行为:停在「#6617 修复本身正确且已验证,但因与 #6435 同根因冲突而不可合并」;不擅自改任一 PR,等 owner 拍板归并方向。

结构化八问(针对 #6617 本身):

  1. 是什么问题:preflight 走完整池折叠后仍装不下 payload 的「徒劳轮次」(无可折叠目标、净收益 ~0)被答 502/retryable,按状态码判瞬时的宿主(opencode/OMP)对永远装不下的 payload 空转整轮重试(~84s×10);日志还说「summary unavailable」但 0 次 summary 调用,措辞误导。
  2. 什么原因导致的:根因在生产者(preflight)——preflightCompress 5 个 exhausted 判决点里唯独 tier-recovery 漏设 deterministic;undefined(falsy)→ server 永不走 413,而 progressContinues(server.ts:4682)按折叠数量(非净收缩)触发 → 净 0 轮次被标「可能还有进展」→ 502/retryable。
  3. 影响范围与严重程度:所有「近窗口徒劳轮次」(payload 超窗但折叠池已无净收益),正常长会话贴窗即触发;两种宿主表现(retryable=true 空转 / retryable=false 仍按 502 空转)。严重度=特定条件下明显问题(空转 ~14 分钟、耗尽重试预算),会话不丢、可绕行(调大窗口/重启)→ p2。
  4. 怎么修复的:在 attemptTierRecovery 内单独追踪结构性终止原因,作为 deterministic 带进判决——结构性(同 payload 注定失败)→ true(→413/不可重试);依赖 relay(可能恢复)→ false(→502/可重试)。server.ts 无需改。
  5. 是否有回归问题:审过 server.ts 既有判决(4675/4682/4690)与 preflight 其余 4 个 exhausted 出口——413 分支本就要求 deterministic,只是让 preflight 正确填这个字段;relay-dependent 失败保持 502/retryable 不变。高危模式逐项过:无 fail-fast 变吞错、无阈值/时序漂移;唯一行为变更=结构性徒劳轮次 502→413(已披露)。缺口:[PR] fix(preflight): structurally doomed futile rounds answer 413/non-retryable instead of a 502 spin (#4563) #6617 缺 overflowArmed 守卫,归并 [PR] fix: preflight-tier batch — deterministic tier-exhaustion verdict, repacked-tail reanchor, anthropic egress clamp #6435 时必须补。
  6. 是否破坏缓存:不涉及——改的是 preflight 判决字段,不动缓存/重试游标/去重键;413 路径本就会 noteLocalRefusal(既有行为)。
  7. 是否改了设计方向:不涉及——无架构/边界/数据流转向,修复在既有判决机制内(补漏掉的 deterministic 字段)。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。

标签(已按 PR 自身 diff 独立判定并打):bug / p2 / scope/kernel / opencode / omp / needs-decision。
CI:在跑,暂无失败(8 个 test 车道 pending);全局回归以推送 head 的 CI test 车道为准。

判定:修复本身正确、已验证、可合——但被 #6435 同根因冲突拦截,须先按上面选项归并(推荐 A)再合。此为决策请求,等 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

1 participant