Skip to content

fix: per-model context window mapping#25

Merged
graykode merged 1 commit intograykode:mainfrom
tbouquet:fix/context-window-mapping
Apr 3, 2026
Merged

fix: per-model context window mapping#25
graykode merged 1 commit intograykode:mainfrom
tbouquet:fix/context-window-mapping

Conversation

@tbouquet
Copy link
Copy Markdown
Contributor

@tbouquet tbouquet commented Apr 3, 2026

Summary

  • Replace the binary 200K/1M heuristic with a model-aware lookup
  • GPT/O-series models: 128K context window
  • Gemini models: 1M context window
  • Claude models: 200K default (auto-detects 1M via [1m] suffix or token count)
  • Unknown models fall back to 200K

Fixes incorrect context percentage for non-Claude models.

Test plan

  • cargo test — all pass, including 4 new model-specific assertions
  • Existing Claude behavior unchanged
  • [1m] suffix and token-based 1M detection preserved

Replace the binary 200K/1M heuristic with a model-aware lookup
table. Handles GPT (128K), Gemini (1M), and all Claude variants
correctly. Falls back to 200K for unknown models, and still
auto-detects 1M when token usage exceeds 200K.
@tbouquet tbouquet force-pushed the fix/context-window-mapping branch from e45554e to ec9fa84 Compare April 3, 2026 16:13
graykode
graykode approved these changes Apr 3, 2026
@graykode graykode merged commit a0efcd6 into graykode:main Apr 3, 2026
7 checks passed
graykode added a commit that referenced this pull request Apr 3, 2026
This reverts commit a0efcd6, reversing
changes made to aa6c2e2.
graykode added a commit that referenced this pull request Apr 3, 2026
This reverts commit a0efcd6, reversing
changes made to aa6c2e2.
@graykode
Copy link
Copy Markdown
Owner

graykode commented Apr 3, 2026

Hey @tbouquet, we reverted this in 94477cd — since claude.rs only processes Claude Code transcripts, GPT/Gemini model names won't appear there. Adding non-Claude branches inside claude.rs isn't the right place for it. Thanks for the contribution though!

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