From 7cf85dffb12ab08270101a71d385f01eb350a286 Mon Sep 17 00:00:00 2001 From: Ani Aggarwal <52252926+AniAggarwal@users.noreply.github.com> Date: Sat, 21 Feb 2026 07:58:24 -0800 Subject: [PATCH] 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. --- src/utils/__tests__/model-context.test.ts | 11 +++++++++-- src/utils/model-context.ts | 7 ++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/utils/__tests__/model-context.test.ts b/src/utils/__tests__/model-context.test.ts index 7d25099..a821419 100644 --- a/src/utils/__tests__/model-context.test.ts +++ b/src/utils/__tests__/model-context.test.ts @@ -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'); diff --git a/src/utils/model-context.ts b/src/utils/model-context.ts index a1efb20..5b6bb07 100644 --- a/src/utils/model-context.ts +++ b/src/utils/model-context.ts @@ -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