Skip to content

fix: recognize Claude Sonnet 5 as a 1M-context model - #50

Merged
Carl723000 merged 1 commit into
ClaudeCodeUsage:mainfrom
UfukTanriverdi8:fix/sonnet-5-context-window
Jul 1, 2026
Merged

Carl723000 merged 1 commit into
ClaudeCodeUsage:mainfrom
UfukTanriverdi8:fix/sonnet-5-context-window

Conversation

@UfukTanriverdi8

Copy link
Copy Markdown
Contributor

Summary

contextWindowFor() only recognized the 1M context window via a "4.6+"
version pattern (e.g. sonnet-4-6), so claude-sonnet-5 — whose model ID
has no -4- segment — fell through to the legacy 200K default. This adds a
check for bare major-version-5+ Sonnet models, so the dashboard and
status-bar context bar correctly show a 1M window for Sonnet 5. Confirmed
against the official docs:
"Claude Sonnet 5 supports the 1M token context window by default (1M tokens
is both the default and the maximum; there is no smaller context variant)."

Linked issues

None.

Type of change

  • Bug fix (non-breaking) → fix (patch)
  • New feature (non-breaking) → feature (minor)
  • Breaking change (existing behaviour differs afterwards) → breaking (major)
  • Documentation / CI / chore → docs / ci / chore (patch)

How was this tested?

  • Added src/test/dataLoader.test.ts covering getCurrentContextInfo for
    claude-sonnet-5; confirmed it fails (200000) without the fix and passes
    (1000000) with it.
  • npm run compile clean; npm test — all 25 tests pass.
  • Manually checked the new regex against existing 4.x model IDs
    (claude-opus-4-8, claude-opus-4-1-20250805, claude-sonnet-4-5-20250929,
    claude-haiku-4-5-20251001, etc.) to confirm no regression to legacy
    classification.

Checklist

  • npm run compile is clean
  • User-facing strings go through I18n with all six languages filled
  • CHANGELOG.md updated (user-visible changes)
  • README.md updated if behaviour/settings changed — checked, no
    per-model context-window docs exist there to update
  • New settings default to existing behaviour (opt-in) — not applicable,
    no new settings
  • No new runtime dependencies

contextWindowFor() only matched the 1M window via a "4.6+" version
pattern (e.g. sonnet-4-6), so claude-sonnet-5 - which has no "-4-"
segment - fell through to the 200K legacy default. Add a check for
bare major-version-5+ Sonnet models.
@Carl723000

Copy link
Copy Markdown
Collaborator

Thanks @UfukTanriverdi8 — clean fix, and nice touch citing the official model page. The major-version regex is the right call. Merging.

@Carl723000
Carl723000 merged commit e2003b9 into ClaudeCodeUsage:main Jul 1, 2026
1 check passed
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.

2 participants