Repository navigation
fix: preflight tries all viable ranges before declaring exhaustion - #575
Conversation
a950caf to
8ecca23
Compare
[bot] 🏷 Review complete — verified, rebased onto master, ready for your merge. What I verified (all on the rebased head, not just the PR's self-report):
Design review (beyond running the tests):
Duplicate handling: I closed PR #574 as a duplicate/superseded (labelled E2E note: Merge is yours — agents don't merge: #575 |
|
语义合并完成(1f89386) — master 在 15:01 合入了 #544(dsh phase4),给
验证: 已推送到本分支,对 master 应为干净合并。@ranxianglei 人工合并即可。 |
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-575Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr575.tgz
npm install -g packageThis comment is automatically updated on each push. |
Multi-range walk merged with the relaxed-mode preflight (dsh phase4): skipSet/budget walk semantics kept; the soft-protection relaxation resets the summarization budget per regime so bad summaries under normal protection cannot starve the relaxed walk (#330 stall); the applyRanges ctx follows activeConfig; exhaustion reporting distinguishes budget / relaxed / all-ranges-bad / rounds.
1f89386 to
c1daf6a
Compare
[bot] 🏷 语义合并已独立复核 — 全部通过,可以人工合并。 我没有只信报告,在 分支结构(已核实)
五个整合点逐一对照 diff,全部属实:
独立运行结果(
结论:语义合并正确、验证齐备、对 master 干净(GitHub clean)。@ranxianglei 合并即可:#575 |
#553) Semantic merge onto current master. The fork-predate relax walk (#544/ #575), wire overhead (#470), image floors (#488), side-request isolation (#388) and pi host-usage (#590) all landed after this PR's fork point (09ef208). Resolution: - preflight.ts: char regime (unknownBaseline / estimateCoreMessagesUpper / char-based splitChunks + netting / fitsWindow) grafted onto the multi- range walk; the upper bound also carries the image+wire floors. - server.ts: effectiveTokenCount feeds all three prepare branches; the trigger's tokenCount uses upper+floors only for anonymous zero-baseline sessions; unknown-baseline keeps the loop's fitsWindow judgment, known keeps master's rebuilt-payload re-estimate (#330). - unknown-baseline + nothing-compressible fails fast (PR semantics); known-baseline falls through to preflightCompress so the #330 relax path still runs. - Tests adapted to current master/kernel: fork conversation reshaped for the kernel's minPressureBenefit (5k) band and main-request shape (max_tokens>200) since #388 now routes the old shape to passthrough.
What
Preflight fail-fast returned
502 retryable=false("no range could be compressed") while later spans of the same history were still compressible — minutes later the session owner's in-band compress shrank it 88% (#569).Root cause
preflightCompress(src/preflight.ts) picked exactly one range per round — the oldest viable one — and when that single range yielded no applied chunk (sub-minCompressRangechunk, empty content, unusable summary, or kernel apply rejection) it declared global exhaustion and broke out of the round loop. Remaining viable ranges were never tried, so one bad leading edge produced a false terminal verdict on a still-recoverable session. In block-dense histories this is likely: the kernel's min-gate sums only non-summary message text, while preflight's char precheck counts all view text including block summaries — so a leading range can pass preflight yet be rejected at apply time.Fix (
src/preflight.ts)exhaustedonly after every range has been tried and nothing applied.MAX_SUMMARY_CALLS_PER_PREFLIGHT = 8bounds summarization calls per invocation (legacy worst case was also 8); hitting it reports a distinct budget-exhausted detail instead of the generic one.Tests (
tests/preflight-multi-range.test.ts, new)E2E through the real proxy with a mock Anthropic upstream whose summarization responses are usable/unusable per call:
summaryCalls ≥ 2; legacy made exactly 1), no forward, no blocks.MAX_SUMMARY_CALLS_PER_PREFLIGHTsummarization calls, budget variant in the error.Pre-flight
npm run typecheck: passsummaryCalls ≥ 2; test 3: budget variant + exact count)npm test: 1050/1051 — the single failure (launcher.test.tsresolveClientCommandcodex) is pre-existing and environment-specific (this sandbox resolvescodexto/usr/bin/codex); unrelated to this changenpm run build: successFixes #574. Source incident: #569.