Repository navigation
fix: name the operator-shrunk window in preflight fail-fast errors - #737
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-737Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr737.tgz
npm install -g packageInstall instructions are refreshed on each push. |
… compare #737 review of the #736 operator-shrunk-window hint: the note was gated on `limit < resolvedNativeWindow`, but the per-request output-headroom reservation (reserveOutputHeadroom = window - max_tokens) ALSO lowers reqConfig.modelContextLimit below native for every non-Anthropic turn with a max_tokens — with no operator setting involved. Comparing alone therefore emitted "your compress.modelContextLimit setting overrides it" for a reduction the operator never made, contradicting the stated invariant that the hint "can never point at a setting that isn't the cause". Gate on windowShrinkReason (set ONLY by the operator-override and codex-align paths). Adds an OpenAI-chat regression test: an incompressible payload under a headroom-shrunk window must NOT carry the shrink note. Verified the old gate produced the false note and the new gate does not.
Reviewed PR #737. Diff is clean (single commit, 2 files, focused). I found one real correctness bug, reproduced it, and fixed it directly on the branch — please merge the follow-up commit, not just the original. Bug: the shrink note fires for output-headroom reductions the operator never madeThe note was gated on const shrinkNote = resolvedNativeWindow !== undefined && limit < resolvedNativeWindow
? ` Note: bili's effective window ${limit} is below the model's full window ${resolvedNativeWindow} — ... your compress.modelContextLimit setting overrides it ...`But Reproduced under the original gate (OpenAI-chat endpoint, model declared 10k, no override, The operator never set Root cause / layerThe window can fall below native through several independent mechanisms. Only two mean "bili deliberately told you this is your wall": the operator override and the codex align — and those are exactly what Fix (pushed — commit
|
… compare #737 review of the #736 operator-shrunk-window hint: the note was gated on `limit < resolvedNativeWindow`, but the per-request output-headroom reservation (reserveOutputHeadroom = window - max_tokens) ALSO lowers reqConfig.modelContextLimit below native for every non-Anthropic turn with a max_tokens — with no operator setting involved. Comparing alone therefore emitted "your compress.modelContextLimit setting overrides it" for a reduction the operator never made, contradicting the stated invariant that the hint "can never point at a setting that isn't the cause". Gate on windowShrinkReason (set ONLY by the operator-override and codex-align paths). Adds an OpenAI-chat regression test: an incompressible payload under a headroom-shrunk window must NOT carry the shrink note. Verified the old gate produced the false note and the new gate does not.
2da365b to
8db98fd
Compare
…e identified-fresh escape (#4185) The widened #3146 gate forwards zero-evidence identified sessions once for upstream arbitration when the exhaustion is DETERMINISTIC (nothing compressible left after maximum folding) — exactly the #4185 shape. Two preflight-fail-fast pins are that shape (#301 nothing-compressible 413, #737 headroom-shrunk nothing-compressible 413); they now seed a settled usage baseline so they keep pinning the evidence-driven verdict while tests/issue4185-identified-fresh-forward.test.ts owns the new contract. Relay-dependent failure pins (429'd / empty / truncated summaries, gateway 524) stay on the classic fail-fast path and need no seeding — verified per file. No source changes. Verified: full preflight family + issue2313/3846/3918 + context-overflow + anthropic-beta-window + issue4185 suites green except four pre-existing master failures tracked in #4194.
…ive input budget 7500', not 'model window 7500' The #3663 change (buildEffectiveWallClause) intentionally relabels a headroom-reserved wall from 'the model window N' to 'the effective input budget N (model window NATIVE, ... reserved ...)'. The pre-existing #737 e2e in tests/preflight-fail-fast.test.ts still asserted the old substring 'model window 7500', which no longer appears — the message now reads 'the effective input budget 7500 (model window 10000, 2500 tokens reserved ...)'. The test's intent (prove the headroom path was exercised: the cited wall is 7500, not the declared 10000) is preserved by asserting the new substring; the other #737 guards (no shrink note, no compress.modelContextLimit blame) are unchanged and still hold.
…rd, and let the upstream's own verdict be authoritative (ranxianglei#7537) Owner ruling 2026-11-22 (issue ranxianglei#7537, KDD ranxianglei#19/ranxianglei#20): every LOCAL estimate- based 413 refusal is a product of bili's local guess multiplied by a window value that is itself often wrong (fallback windows ranxianglei#7205). Their product silently killed requests that would have succeeded (the ranxianglei#7167/ranxianglei#7382/ranxianglei#2490/ ranxianglei#2847/ranxianglei#2847/ranxianglei#736/ranxianglei#737/ranxianglei#4079 family). - server.ts: the four local size-413 sites (probe doom gate, ranxianglei#1839 measured gate, post-fold measured/doom-bytes gates, deterministic-exhaustion mapping) now FORWARD with the local measurement logged as evidence. Relay-side refusals keep their status: summary relay down -> 502, relay 429 -> 503. The BILI_MAX_MESSAGES count gate and the 5GiB byte cap are exact resource guards and stay. - relay.ts: the egress window fuse's two size gates log a profile and forward; a NEW upstream size-verdict annotation (413 / size-keyword 400) logs bili's own measurement, marks the response x-bili-retryable: false and merges a bili_evidence block into JSON error bodies so status-driven hosts do not retry-loop an unchanged body. - server.ts: NEW evidence-backed loop guard — an outbound body that already drew an upstream size verdict (SHA-1 scoped, 10-min TTL) is refused locally as a byte-identical resend (ranxianglei#496 family); changed bodies and the identity fast path re-forward freely. - The window-shrink note now rides the forward warns (the 413 fail-fast it decorated is gone); the duplication profile moved onto the over-window forward. - AGENTS.md KDD ranxianglei#19 + reference/design-decisions.md ranxianglei#20 record the ruling. - Tests: NEW tests/issue7537-preflight-passthrough.test.ts (3); re-pinned issue1841/2490/2847/3645/4079/4185/preflight-fail-fast to passthrough semantics; tests/issue3846-local-refusal-evidence.test.ts deleted (the local refusal it pinned no longer exists — the loop guard replaces it). Supersedes PR ranxianglei#7507 (whose two new gates no longer need to exist under this ruling). Refs ranxianglei#7537 ranxianglei#7507 ranxianglei#7167 ranxianglei#7382 ranxianglei#2490 ranxianglei#2847 ranxianglei#736 ranxianglei#737 ranxianglei#4079 ranxianglei#4543 ranxianglei#1841 ranxianglei#3645 ranxianglei#496 ranxianglei#3846 ranxianglei#3461 ranxianglei#5000
What
When preflight compression cannot bring an over-window payload under the window, the fail-fast error ends with "Raise the model context window or restart the session to recover." — which sends operators to the upstream when the actual wall is bili's own
compress.modelContextLimitsetting.#736 is exactly that misdirection in the wild: the log shows
[window] source=table-or-registry native=128000 effective=16000— the model's registered window is 128K and the local upstream demonstrably served it (an earlier turn of the same session reported 82022 input tokens; a sibling session was billed at 16589) — yet every fail-fast only ever said "raise the model context window", while the ceiling was acompress.modelContextLimit: 16000-style override edited into the web UI minutes before the brick.This change threads the resolved native window + shrink reason (
operator/codex) from the per-request window-resolution block intopreflightCompressIfNeeded, and wheneffective < nativethe fail-fast message now adds:Also normalizes the doubled period at the detail seam (
...recover..→...recover.), visible verbatim in the #736 log.Why not just docs
The message is the only surface an operator sees at the moment of failure; the #736 thread shows how far "raise the model context window" leads when the registry already knows the true window. The hint is emitted only when bili itself shrank the window below the resolved native value, so it can never point at a setting that isn't the cause (output-headroom reservation and self-heal paths leave
windowShrinkReasonunset → no note).Tests
New e2e in
tests/preflight-fail-fast.test.ts: incompressible payload under an operator-shrunk 4k window (model declares 10k) → 502 message names both numbers andcompress.modelContextLimit; negative control without the override asserts no note. HarnessstartProxygained an optional compress-overrides param.Pre-flight:
npm run typecheckclean ·npm test1430 pass / 0 fail / 2 skipped (E2E-gated) ·npm run buildOK.Fixes #736