Repository navigation
fix: track Claude Opus 5 as a 1M-context model - #81
Conversation
Claude Code writes the plain `claude-opus-5` id to its JSONL even when the session runs the 1M-context variant, so the existing `[1m]` marker never fired for it. `contextWindowFor` fell through to the generic opus/sonnet branch and returned 200K flagged as exact, making the reported context percentage five times too high with no `estimated` hint to soften it. The major-version branch now covers Opus 5+ as well as Sonnet 5+. Pre-4.6 Opus/Sonnet and dated 3.x snapshots keep their 200K window (the alternation still cannot match a date suffix such as `sonnet-20241022`). `claude-opus-5` also gets an explicit pricing entry. The family fallback already resolved it to the correct $5/$25 current-Opus tier, so no cost figure changes; the entry mirrors the existing `claude-sonnet-5` anchor and drops the spurious `Unknown model` line from the diagnostic output. Opus 5 pricing and context window verified 2026-07-28 against https://platform.claude.com/docs/en/about-claude/models/overview
|
🤖 Automated first-pass review TL;DR Analysis
Suggested next step(s)
🤖 Generated by DeepSeek as an automated first pass — not a maintainer decision. |
Problem
claude-opus-5is reported with a 200 000-token context window, flagged as exact. Because a real Opus 5 session routinely exceeds that, the context indicator doesn't just read high — it reads over 100%, andestimated: falsemeans the UI has no reason to soften it.Measured on my own logs (31 060 records, via
getCurrentContextInfo):mainRoot cause
contextWindowForhas a[1m]-suffix escape hatch and a major-version check, but the latter only matchedsonnet-:That comment is now out of date, and the
[1m]hatch doesn't cover the gap: Claude Code writes the bareclaude-opus-5id to its JSONL even when the session is running the 1M-context variant. Across three days of my logs:So
claude-opus-5falls through to the generic/haiku|opus|sonnet/branch and gets 200K.Fix
One alternation, covering Opus 5+ alongside Sonnet 5+:
Older models are unaffected — the
(?:-|\b)anchor still prevents a date suffix from matching, soclaude-3-5-sonnet-20241022,claude-sonnet-4-5-20250929andclaude-opus-4-20250514keep their 200K window. There's a regression test pinning that.claude-opus-5also gets an explicitMODEL_PRICINGentry. No cost figure changes —inferPricingByFamilyalready resolved it to the correct current-Opus tier. The entry mirrors the existingclaude-sonnet-5anchor and removes a spuriousUnknown model: claude-opus-5line from the diagnostic output, which seemed worth avoiding in an extension whose diagnostics users are asked to attach to bug reports.Opus 5 pricing ($5 / $25 per MTok) and context window verified 2026-07-28 against https://platform.claude.com/docs/en/about-claude/models/overview — for Opus 5, as for Sonnet 5, 1M is both the default and the maximum, with no smaller context variant.
Tests
Red first, then green. The failing run was
actual: 200000, expected: 1000000.getCurrentContextInfo reports a 1M window for Opus 5, with or without the [1m] markergetCurrentContextInfo keeps the 200K window for pre-4.6 Opus and Sonnet(regression guard)getModelPricing resolves Opus 5 from the exact table, long-context variant includednpm test→ 172 tests, 171 pass, 0 fail, 1 skipped (the skip is pre-existing).Also smoke-tested as an installed VSIX in VS Code 1.129.1 on Linux.
Notes for review
CHANGELOG.mdhas an entry under 2.2.1 → Fixed. I didn't touch the READMEs: 2.2.1 has no "what's new" section in any of the seven yet, so there was nowhere consistent to put it. Happy to add one if you'd rather it landed there too.speed: "fast"request parameter rather than a distinct model id, so I couldn't tell from my logs whether it's distinguishable in the JSONL at all. If it is, current pricing under-counts those turns.🤖 Generated with Claude Code