fix(admission): resolve the per-model window the way the catalog does - #2085
Conversation
resolveInputCeiling read modelContextWindows and modelMaxInputTokens with
a bare lookup, while the catalog resolves the same two maps through
modelRecordValue, which also accepts a family entry for a tagged id.
With contextWindow 8_000 and modelContextWindows {"gpt-oss": 131_072}:
catalog advertises 131_072 provider-fetch.ts:612
admission ceiling 8_000 before this change
So the gate refused turns the model can plainly hold, using a window that
belongs to a different model. That is the opposite of what this module
documents about itself -- "every uncertainty resolves toward admitting".
modelMaxInputTokens had the mirror of it: a family cap never applied to
the tagged sibling it was written for.
Three tests, all red without the src change and green with it. The first
asserts the catalog's value first so the two can never drift apart again.
No behavior changes for ids that already resolved exactly.
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesModel limit resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change aligns per-model admission limits with catalog resolution for tagged model IDs, with the supplied tests and type checks passing; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
|
Reviewed as part of a four-PR batch (#2077, #2085, #2086, #2100) applying the same The "definite wrong answer" framing is verified: a missed Both per-model reads in the file are migrated; nothing was missed. The family assertions are real oracles — they fail against the unfixed code. Two of the surrounding assertions are controls that pass either way (the direct |
|
Reviewed as part of a four-PR batch with #2077, #2086, and #2100 — same idea (bare Verdict: merge. The "definite wrong answer" framing checks out, and it is the part worth stating plainly: a missed Both per-model reads in the file are migrated; nothing was left raw. One note for future tests rather than a change request: the assertions that call |
Summary
resolveInputCeilingreads two per-model maps with a bare lookup:The catalog resolves those same two maps through
modelRecordValue(src/codex/catalog/provider-fetch.ts:612), which also accepts a family entry for a tagged id — the documented behaviour forgpt-osscoveringgpt-oss:120b.Why it bites
Config:
{ "contextWindow": 8000, "modelContextWindows": { "gpt-oss": 131072 } }Request to
gpt-oss:120b:The bare lookup misses
gpt-oss:120b, soconfiguredfalls through to the provider-widecontextWindow— a window that belongs to a different model — and the gate refuses turns the routed model can plainly hold. A ~50k-token turn is rejected pre-dispatch against a 131k model.That inverts this module's own stated contract:
modelMaxInputTokenshas the mirror of the same bug: a family cap silently never applies to the tagged sibling it was written for. That one fails open, so it is a missed cap rather than a wrong refusal — but it is the same divergence.Fix
Both lookups go through
modelRecordValue. Nothing else changes; an id that already resolved exactly resolves to the same value, andmodelRecordValueis pure, so the module stays free of filesystem, catalog and registry reads (the existing "touches no filesystem" test still passes).Verification
Three new tests in
tests/input-admission.test.ts. Reverting only thesrcchange turns exactly those three red and nothing else:with the fix:
22 pass, 0 fail.The first test asserts
modelRecordValue(...)— the catalog's own answer — before asserting the ceiling, so the two cannot drift apart again without the test noticing.Blast radius, run locally:
npx tsc --noEmit— no errors.Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit