Repository navigation
fix(#1841): preflight futility gate — skip doomed rounds, bail mid-walk - #1851
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2378-pr.1851.48d30aeThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1851.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 结论:方向正确,gate 实现通过审查;但全量 CI 在全部 4 个平台红——根因已定位并就地修好(仅测试迁移),已推 PR 分支( 验证过程(证据先行)
结构化七问
合并判定:等 |
[bot] 🏷 更新:CI 已绿,PR 可合。
最终判定:可合。 合并动作按规则由人来执行:#1851 (前一条回复的七问结论不变,此处仅补 CI 状态。) |
When the sum of all foldable range masses cannot close the gap between the payload estimate and the model window, no combination of folds can fit the payload; walking the ranges only burns summarization calls minutes at a time (incident 08cc0df7: ~9 calls over 5 min, net -5.5%). Two gates, both on local estimates only (zero network overhead, re-evaluated per request, no new config surface): - Pre-walk: if resolvable pool * FUTILITY_SLACK < payloadEstimate - limit, skip the whole round with zero summary calls and an honest quantified detail. If the normal-regime pool falls short but the relaxed soft-zone view would suffice, relax up front instead of burning calls first. - Mid-walk: as doomed ranges are consumed, stop before summarizing any range whose remaining potential cannot change the outcome; carry the per-range skip notes into the verdict (#1372 diagnosis contract). The deficit is measured on payloadEstimate (the floorless wire estimate the caller's forward decision uses), never on the floor-pinned currentTokens: the usage floor covers system prompt + tool definitions that folding cannot remove. Unresolvable nudge refs count as zero mass, matching the walk's dead-test, so an all-dead pool still walks call-free for its skip-note diagnosis.
… all four platforms The #1841 pre-walk gate correctly skips scenario C's round (image floor ~1.1M alone exceeds the ~999K window; the ~4.4K foldable filler pool cannot close the ~110K gap), so the old 'ranges were folded' assertion no longer holds — the same contract the two #574 assertions were already migrated to. Keep the 502/hatch-closed pins, pin the new zero-call behavior + 'futile round' verdict wording, and assert the baseline stays exactly untouched (it was never re-poisonable here: the armed 1,072,519 usage baseline sat above any text+overhead write-back value, so the old write-back assertion passed trivially even before this PR).
ee950f9 to
78abb43
Compare
|
已 rebase 到当前 master(818d24e+),冲突已解,本地全绿。 语义合并说明:
本地验证:tsc 干净; 与 #1818 的关系:两个 PR 都在 preflight 区域但不相互依赖(#1818 = net-shrink gate + budget + anchor;#1851 = round 级可行性预检 + mid-walk bail)。#1841 事故里 preflight 烧 5 分钟净 −5.5% 的场景,合并后由本 PR 在零 summary call 下止损;#2110 事故里 748s 只省 13K 的场景由两者共同覆盖。建议先合 #1818 再合本 PR(或反过来都行,冲突面小)。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.87-master.4245277 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Fixes #1841
What
#1841 is item 3 of #1819's suggested-fix list — the one left unimplemented: "Consider skipping the whole preflight round (or bailing early) when cumulative accepted folds cannot bring the payload under the target." The motivating incident (session 08cc0df7, weak local summarizer): preflight spent ~9 summary calls over ~5 minutes for a net −5.5%, because nothing ever asked "can this round possibly succeed?" before spending calls. The admission gate (#1819/A) only rejects an individual expanding fold after its summary call was already spent; this adds the missing round-level feasibility check.
How
Two gates inside
preflightCompress, both computed from local estimates only (zero network overhead, re-evaluated per request — no cross-request state, no new config):pool × FUTILITY_SLACK(1.2) < payloadEstimate − limit, skip the whole round with zero summary calls and an honest quantified detail ("futile round: maximum possible saving ~P tokens is below the required reduction ~D tokens"). If the normal-regime pool falls short but the relaxed soft-zone view would suffice, relax up front instead of burning calls first (preflight fail-fast × soft-protection livelock: over-window payload with nothing foldable outside the protected zone 502s forever #330 path preserved).Soundness notes:
payloadEstimate(the floorless wire estimate the caller's forward decision itself uses), never on floor-pinnedcurrentTokens: the usage floor covers system prompt + tool definitions that folding cannot remove, so a floor-pinned deficit would wrongly declare futility in tool-heavy sessions.FUTILITY_SLACK = 1.2absorbs estimator error + summary re-entry; fail-closed direction (only skips when clearly doomed).Behavior change disclosure (old → new)
preflight_compress_failed, retryable:false); the [Bug] Codex 额度中断后恢复长会话,preflight SSE 摘要为空并持续 502 #726 dead-end cooldown arms exactly as before (kind=exhausted && compressedRanges===0).Config surface
None added.
FUTILITY_SLACKis an internal constant, not user-facing. No env/CLI/config.json changes.Pre-flight evidence
npm run typecheck: cleantests/preflight-*.test.ts+ issue1372/issue1615/issue1841 suites — 105/105 pass, including 3 new tests (pre-walk skip with 0 calls / non-futile control / mid-walk bail)src/preflight.tsis not in ci-e2e.yml's auto-trigger path list, so the e2e workflow is dispatched manually on this head (request pipeline per AGENTS.md)Coordination note
Open PR #1818 also touches
src/preflight.ts(defects A/D/E). This change is additive around the round/walk control flow and does not intersect A's acceptance gate or D's length-budget code paths; whichever lands second rebases as a semantic union.