Repository navigation
fix: remove runtime context-window learning entirely (#987) - #992
Conversation
The window is a deployment property, owned by declarations (config / registry / runtime-info), never adjusted from session traffic. The learned-window channel (confirmedContextLimit/confirmedContextLimits, retraction, weak-overflow arming) accumulated patch-on-patch fixes (#570, #572, #857, #969) and still mis-sized windows in the field (#987: a session window silently re-centered to 16898). Removed: - src/weak-overflow.ts (armFailureShrink/armedAtLeast ladder) and its tests; an upstream rejection now arms the one-shot emergency shrink directly at the stated window, or min(declared, payload-estimate) when no number is parseable (source=usage). - The self-heal application ladder in server.ts (learnedLimit / operatorOwnsWindow / nativeFromFallback learn paths) — the declared window resolves once and keeps governing. - confirmedContextLimit(s) session metadata fields. - sideRequestGuard's learnedLimit param; the guard now intersects the declared window with the usage-grounded arm only. Kept: the one-shot emergency shrink (per #969/#987 decisions), #496 forward-once gate (now keyed on the rejection arm), #857 usage-grade provenance, #570 no-retraction guarantees (trivially — nothing to retract). Tests rewritten to the new semantics; exit-matrix updated.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-992Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr992.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Reviewing now: fetching |
[bot] 🏷 Review complete — code verified, one small leftover found and fixed directly on the branch, all checks green. Ready for you to merge (human-only per repo rules). What I verifiedBase freshness: single commit Removals match the description (read the full diff, grepped for leftovers):
One gap found — fixed on the branch (commit
|
Fixes #987
What
The context window is a deployment property — owned by declarations (config / routes / registry / runtime-info), never adjusted from session traffic. This removes the runtime window-learning mechanism entirely, along with the accumulated patch-on-patch machinery that grew around it (#570 retraction guards, #572 confirmed-channel, #857 provenance tiers, #969 operator-owns-window — each a fix for the previous fix).
Removed (~1,700 lines gross)
src/weak-overflow.ts— the whole file (armFailureShrink/armedAtLeastladder). An upstream overflow now arms the one-shot emergency shrink directly:source=usage, [Question] 非白名单上游(如 DeepSeek)图片按 b64/4 估算,实测高估约 100×;且该估算被写回 lastInputTokens 并自愈成 confirmed 窗口,使 #496 逃生门永久失效 #857 semantics kept)min(declared, payload-estimate)— the rejection is evidence at the size actually sent, so the PR #489 后续: 默认图片计费 b64/4 在像素 tile 计费上游(官方 Anthropic/OpenAI)会硬 502 误杀多模态会话 #496 forward-once gate still breaks the 多模态会话上下文控制失效 + preflight 救援 502(codex responses store:false) #488 400 loop after one rejected forward, without ever re-centering the declared windowserver.tsself-heal application ladder —learnedLimit/operatorOwnsWindow/nativeFromFallbacklearn paths. The declared window resolves once per request and keeps governing; a wrong declaration self-heals only through the one-shot emergency (next turn compresses below the failing size).confirmedContextLimit/confirmedContextLimitssession metadata fields — gone fromsession.tsand all call sites.sideRequestGuardlearnedLimit parameter — the guard now intersects the declared window with the usage-grounded arm (lastInputTokensSource === "usage") only.tests/weak-overflow.test.ts+tests/plugin-truncation-weak-overflow.test.tsdeleted;tests/e2e-overflow-selfheal.test.tsrewritten to three context window problem continues #987 cells (T1 stated → arms, learns nothing; T2 no number → arms at payload size, no fold; T3 correct declaration still recovers); exit-matrix references updated.Kept (explicitly)
source=usage, overwritten by the next real usage report.Why not keep the learner
Field evidence (#987): a session window silently re-centered to 16898 tokens and the session was stuck compressing forever. Every learned value was a guess from one error body; wrong guesses compound (the #969 incident chain). Declarations are explicit, inspectable, and owned by the operator — the upstream's own overflow 400 is still surfaced verbatim so misconfigurations are visible immediately.
Pre-flight
npm run typecheck✅npm test— 1950 pass / 0 fail / 2 skipped (E2E gates) ✅npm run build✅