Repository navigation
fix: cap tier-gated registry windows at the standard window without tier evidence (#1321) - #1325
Conversation
…ier evidence (#1321) models.dev advertises the MAX window a tier-gated model id can serve (anthropic/claude-opus-5-5 -> 1,000,000), but a plain subscription serves the standard 200K until the client negotiates otherwise. The warm registry peek outranks the built-in table by design (#344 fresher-source-wins), so a claude-native session without the context-1m beta header resolved to 1M and every nudge/emergency threshold sat up to 5x beyond the client's own wall (#1310 item 2). - recognize [Nm]-suffixed model names as tier evidence, alongside the context-Nm beta header (expandedContextSuffixWindow) - cap registry-derived windows at the built-in standard window for tier-gated families (claude-) when no tier evidence is present (capRegistryWindowByStandard); operator sources stay exempt, other families keep fresher-source-wins (#344/#852) - one info log line per capped model Behavior change: claude-* requests WITHOUT a context-Nm beta header or [Nm] suffix now resolve to the built-in standard window (200K) instead of the registry-advertised max when the latter is larger. WITH evidence, or for non-claude families, resolution is unchanged. Fixes #1321
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1325Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1325.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 收到。这是本账号已完成的 PR(分支 |
[bot] 🏷 Verification complete. This is the account's own completed PR, so per the own-PR rule I did NOT redo the work — I fetched branch ① Issue direction (#1321): verified. Without tier evidence, models.dev reports 1M for Claude tier-gated models (bundled snapshot: ② Regression audit — existing behavior of touched paths:
③ Code: single linear commit (+415/−26, 5 files). Cap logic is a pure function with pass-throughs for undefined / has-evidence / sub-standard inputs; per-model log dedup via module-level Set. Suffix parser anchored, case-insensitive, clamped to ④ Test validity: real teeth. E2E through the actual proxy: no-evidence claude → ⑤ Diff cleanliness: every line serves the fix; no unrelated churn, no lockfile/generated noise. Behavior change (old → new):
CI at head Verdict: ready to merge. I can't merge PRs — system rules forbid it. Please merge yourself: #1325 一句话中文摘要:修复了无 tier 证据时 claude-* 模型误用 models.dev 报告的 1M 窗口做压缩分母(标准窗口实为 200K,导致预算错位与 #1310 紧急压缩)的问题——现在无证据时回落到内置标准窗口,有 beta 头或 |
|
Coexistence verification on current master head: both this and the sibling claude-native estimation PR (#1325/#1326) cherry-picked cleanly onto today's master and pass the full gate together — typecheck ✓ / 2608 tests 0 fail (10 e2e-gated skips) / build ✓. Shared-file regions are disjoint (window resolution vs prepareAnthropic thinking projection), any merge order works. |
[bot] 🏷 收到,并独立复核了一遍——结论一致:两个 PR 可共存、任意顺序合并均可。 补充我这边的独立验证(你的 cherry-pick 报告之外):
无额外动作需要我做;PR 保持 open 等你合并(合并按系统规则只能由人执行):#1325 一句话中文摘要:master 前进后(新增 kernel 0.0.91 等)我用真实 merge 模拟重新验证了本 PR 与新 master 零冲突且全部门禁通过,确认与兄弟 PR 任意顺序可合并,无需我再改动,等你人工合并即可。 |
What & why
models.dev advertises the MAX window a tier-gated model id can serve (
anthropic/claude-opus-5-5→ 1,000,000), but a plain subscription serves the standard 200K until the client negotiates otherwise — Claude Code sends thecontext-1m-*beta header only when it actually negotiated 1M. The warm registry peek outranks the built-in table by design (#344 fresher-source-wins), so a claude-native session on a standard subscription resolved to 1M and every nudge/emergency threshold sat up to 5× beyond the client's own wall: unreachable while Claude Code enforced 200K locally (#1310 item 2 → #1321).Fix at the single decision point where all sources are adjudicated (
src/server.tsnative-window chain):expandedContextSuffixWindow(src/server/context-window.ts): an[Nm]-suffixed model name (claude-opus-5-5[1m]) is now recognized as tier evidence, alongside thecontext-Nmbeta header — same evidence class carried in the model id instead of a header. Resolved like the header: N × 1,000,000 clamped toMAX_ANTHROPIC_BETA_WINDOW.capRegistryWindowByStandard: for TIER-GATED families only (/^claude-/i, src/config.tsTIER_GATED_FAMILIES+tierGatedStandardWindow), a registry-derived window above the built-in standard is capped back to the standard when the request carries no tier evidence. One info log line per model.Scope deliberately narrow: a blanket table-over-registry flip would pin every family at its stale table value — qwen (table 200k vs real 1M–10M), future gpt-5.x growth — violating #344/#852 (a stale-low table entry must never pin a grown registry window). Only families whose larger tier requires per-request negotiation are capped; for those the error direction is safe: capped worst case = over-compression (self-heals), uncapped worst case = dead sessions (#1310 lockout).
claude-*, no beta header / no[Nm]suffix, registry > 200kclaude-*withcontext-Nm-*beta header or[Nm]suffixBoth compression modes reasoned: plugin-mode windows reported by the agent itself are exempt; proxy-mode claude-native (the reporter's posture) is the fixed path. The launcher-side chain (
resolveLauncherWindow) already ranks the table over the registry — unaffected.Tests
tests/issue1321-tier-window-cap.test.ts: unit (suffix parsing incl. clamp/case/anchor edges;tierGatedStandardWindowfamily scoping; cap pass-throughs) + e2e through the real proxy pipeline (no-evidence → 200K; beta header → 1M;[1m]suffix → 1M; non-tier-gated control gpt-5.4 → 1,050,000 uncapped; [bug] claude native: stitched-stream usage double count after in-stream compress locks session ('Prompt is too long') — #300 variant #1310 symptom pin: 261,206-token session fires EMERGENCY again at the 200K window).tests/issue-393-registry-window.test.ts: the no-evidence claude→1M expectation flips to 200K (this PR's intentional change, documented in the file header); Fix-1 hostless-lookup coverage re-anchored onopenai/gpt-5.4(1,050,000 — only the registry can produce it, so the assertion still proves the lookup runs in--upstreammode); wire-mode recording test likewise switched to gpt-5.4 so it still proves the recorded number is fully resolved, not a hardcoded/table fallback.Pre-flight (rebased head e8e1c05, master d4f630b)
npm run typecheck✅npm test✅ 2581 tests, 0 fail, 10 skipped (gated e2e)npm run build✅src/server.ts(hot-file trigger).Fixes #1321