Skip to content

fix: remove runtime context-window learning entirely (#987) - #992

Merged
ranxianglei merged 2 commits into
masterfrom
2026-09-19_remove-learned-window
Sep 19, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-09-19_remove-learned-window

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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)

Kept (explicitly)

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 ✅

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.
@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-19_remove-learned-window (8955887)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-992

Each push to this PR publishes a new version under the pr-992 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr992.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewing now: fetching 2026-09-19_remove-learned-window, re-running typecheck/tests/build on the branch head and checking CI status before giving a verdict. Will follow up with findings.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[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 verified

Base freshness: single commit 721c4a5 sitting directly on current origin/master (ea2b33f) — no stale-base risk, no rebase needed.

Removals match the description (read the full diff, grepped for leftovers):

One gap found — fixed on the branch (commit 8955887)

The web UI still consumed the removed field: src/web/client.ts rendered fmtW(item.contextWindow)+"/"+fmtW(item.provenMaxInput) while the stats endpoint no longer sends provenMaxInput, so the column would permanently show window/—; the page.ts header tooltip ("相信窗口 / 近期成功最大输入(差距大 = provider 虚标)") was stale too. Fixed both (2 lines total, tooltips now say 声明窗口(不再从会话流量学习)). Re-ran the full pre-flight after the fix — all green. Per review discipline I committed it straight onto the PR branch rather than filing a separate round-trip.

Evidence

  • Local on final head 8955887: npm run typecheck ✅ · npm test 1950 pass / 0 fail / 2 skipped (E2E gates) ✅ · npm run build ✅
  • CI on 8955887: CI, e2e-fake-codex, PR Build Artifact, CI Windows codex overlay — all 4 workflows success.

Mergeability note

Per §7.4 this stays human-merge: it changes wire behavior in both compression modes and the session persistence format (metadata fields removed), both of which are outside the auto-merge gate. Nothing blocks merge; please merge when ready: #992

中文摘要:完整核对了移除窗口学习机制的 PR(基线最新、无残留引用、#857/#496 语义保留、e2e 三格覆盖到位),发现并直接在分支上修掉了 Web UI 仍在渲染已删除字段 provenMaxInput 的小遗漏(2 行改动,已补 commit 8955887),本地与 CI 全绿——可以合并。

@ranxianglei
ranxianglei merged commit 409b397 into master Sep 19, 2026
8 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-19_remove-learned-window branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

context window problem continues

1 participant