Repository navigation
fix: preflight tries all viable ranges before declaring exhaustion (#569) - #574
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-574Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr574.tgz
npm install -g packageThis comment is automatically updated on each push. |
Implemented, verified, and opened a PR: #575 Triage (validated before writing code). Reproduced the defect against the actual code, not just the report: in Fix (
Tests (
Verification. RED confirmed on legacy by stashing the fix: test 1 expected 200 got 502, test 2 failed on Content branch only — |
) Preflight fail-fast returned a global exhaustion verdict when its single picked range (the oldest) yielded no applied chunk — one bad leading edge (unusable summary / sub-min chunk / apply rejection) produced a false 502 on a still-recoverable session while later spans were compressible (#569). - Walk every viable range oldest-first until one folds; declare exhausted only after all have been tried. - Skip-set for ranges found unusable (refs are content-fingerprinted, stable across folds) so they are never retried within an invocation. - New cost cap MAX_SUMMARY_CALLS_PER_PREFLIGHT=8 bounds summarization calls; hitting it reports a distinct budget-exhausted detail. - Exhaustion detail names how many ranges were tried. Upstream/abort/credit semantics unchanged; mode-agnostic core only.
|
Closing as duplicate of #575 — superseded. Same fix (preflight walks every viable range before declaring exhaustion), but #575 ships the refined implementation: skip-set keyed on #575 was just rebased onto current master ( If you'd rather keep this iteration, reopen it and say which variant you prefer. |
… 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).
… 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).
…istic (ranxianglei#2832) - diagnoseEmptySummary gains per-wire block fingerprints (text_chars / text_blocks / thinking_blocks / reasoning_chars / text_parts) so a thinking-only answer is distinguishable from relay-stripped text in logs and fail-fast details - new isDeterministicEmptyCompletion: a normal stop (end_turn / stop / completed) carrying zero answer text is deterministic for that (model, host) pair — it earns neither ranxianglei#1767's same-span retries nor ranxianglei#726's halving recovery, because re-sending the identical payload returns the identical empty answer and a normal stop is not a size signal - three consecutive deterministic empties on the same (host, model) arm a session-persisted dead-probe verdict (session.metadata deterministicEmptyProbe); while dead, at most ONE canary probe per preflight invocation bills the wall, and a successful canary clears the verdict so folding resumes on a self-healed relay - fail-fast detail names the actionable exits: configure compress.externalSummary, switch the session's model, or fix the relay's thinking/text handling - tests: classifier matrix + fingerprint pins (unit), systemic e2e (bounded strikes, sticky verdict, exactly-one-canary contract, nothing forwarded), recovery e2e (canary clears, fold proceeds, 200); ranxianglei#574 multi-range fixture moves to max_tokens so that file keeps pinning the walk/budget mechanics on the size-driven path independent of this reclassification
What
Preflight fail-fast returned
502 retryable=falsewith "no range could be compressed" while later spans of the same history were 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 startRef — and when that single range yielded no applied chunk (sub-minCompressRange chunk, 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 per spec, while preflight's char precheck counts all view text including block summaries — so a leading range can pass preflight's check yet be rejected at apply time, or simply sit below
minCompressRangeafter its blocks were folded.Fix (src/preflight.ts)
exhaustedonly after every range has been tried and nothing applied.MAX_SUMMARY_CALLS_PER_PREFLIGHT = 8bounds summarization calls per preflight invocation (legacy worst case was also 8×1); 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:
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: passnpm test: 1050/1051 — the single failure (launcher.test.tsresolveClientCommand codex) is pre-existing and environment-specific (sandbox resolvescodexto/usr/bin/codex); fails identically on pristine master, unrelated to this changenpm run build: success