fix: recognize [1m] suffix on all models, not just Sonnet 4.5 (#172)

The getContextConfig function was hardcoded to only match
claude-sonnet-4-5 models with the [1m] suffix. Other models like
claude-opus-4-6[1m] also support 1M context but were falling back to
the 200k default, causing incorrect context percentage display.

The [1m] suffix itself is sufficient to indicate 1M context regardless
of model family.
This commit is contained in:
Ani Aggarwal authored and GitHub committed 2026-02-21 10:58:24 -05:00
1 parent d025c707e6
commit 7cf85dffb1
2 files changed
+11 -7

No files matched your search

+9 -2
View File
@@ -7,7 +7,7 @@ import {
import { getContextConfig } from '../model-context';
describe('getContextConfig', () => {
describe('Sonnet 4.5 models with [1m] suffix', () => {
describe('Models with [1m] suffix', () => {
it('should return 1M context window for claude-sonnet-4-5 with [1m] suffix', () => {
const config = getContextConfig('claude-sonnet-4-5-20250929[1m]');
@@ -15,6 +15,13 @@ describe('getContextConfig', () => {
expect(config.usableTokens).toBe(800000);
});
it('should return 1M context window for claude-opus-4-6 with [1m] suffix', () => {
const config = getContextConfig('claude-opus-4-6[1m]');
expect(config.maxTokens).toBe(1000000);
expect(config.usableTokens).toBe(800000);
});
it('should return 1M context window for AWS Bedrock format with [1m] suffix', () => {
const config = getContextConfig(
'us.anthropic.claude-sonnet-4-5-20250929-v1:0[1m]'
@@ -32,7 +39,7 @@ describe('getContextConfig', () => {
});
});
describe('Sonnet 4.5 models without [1m] suffix', () => {
describe('Models without [1m] suffix', () => {
it('should return 200k context window for claude-sonnet-4-5 without [1m] suffix', () => {
const config = getContextConfig('claude-sonnet-4-5-20250929');
+2 -5
View File
@@ -13,11 +13,8 @@ export function getContextConfig(modelId?: string): ModelContextConfig {
if (!modelId)
return defaultConfig;
// Sonnet 4.5 variants with 1M context (requires [1m] suffix for long context beta)
if (
modelId.includes('claude-sonnet-4-5')
&& modelId.toLowerCase().includes('[1m]')
) {
// Any model with [1m] suffix has 1M context
if (modelId.toLowerCase().includes('[1m]')) {
return {
maxTokens: 1000000,
usableTokens: 800000 // 80% of 1M