diff --git a/packages/types/src/providers/bedrock.ts b/packages/types/src/providers/bedrock.ts index 6b804591187..d5d73831074 100644 --- a/packages/types/src/providers/bedrock.ts +++ b/packages/types/src/providers/bedrock.ts @@ -461,4 +461,6 @@ export const BEDROCK_CLAUDE_SONNET_4_MODEL_ID = "anthropic.claude-sonnet-4-20250 export const BEDROCK_1M_CONTEXT_MODEL_IDS = [ "anthropic.claude-sonnet-4-20250514-v1:0", "anthropic.claude-sonnet-4-5-20250929-v1:0", + "anthropic.claude-3-5-sonnet-20241022-v2:0", + "anthropic.claude-3-5-sonnet-20240620-v1:0", ] as const diff --git a/tmp-pr-8415/Roo-Code b/tmp-pr-8415/Roo-Code new file mode 160000 index 00000000000..2c31616e8ad --- /dev/null +++ b/tmp-pr-8415/Roo-Code @@ -0,0 +1 @@ +Subproject commit 2c31616e8ade2a3995c3beda2d32d82fac17bf93 diff --git a/tmp/pr-8380-Roo-Code b/tmp/pr-8380-Roo-Code new file mode 160000 index 00000000000..81544400050 --- /dev/null +++ b/tmp/pr-8380-Roo-Code @@ -0,0 +1 @@ +Subproject commit 815444000508f67c41ba51175f1d3061364ea0bc diff --git a/webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts b/webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts index 9d8c627b7fa..5f2b14bc8a7 100644 --- a/webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts +++ b/webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts @@ -499,7 +499,7 @@ describe("useSelectedModel", () => { expect(result.current.info?.contextWindow).toBe(200_000) }) - it("should not affect context window for non-Claude Sonnet 4 Bedrock models", () => { + it("should enable 1M context window for Bedrock Claude 3.5 Sonnet when awsBedrock1MContext is true", () => { const apiConfiguration: ProviderSettings = { apiProvider: "bedrock", apiModelId: "anthropic.claude-3-5-sonnet-20241022-v2:0", @@ -510,6 +510,99 @@ describe("useSelectedModel", () => { const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper }) expect(result.current.id).toBe("anthropic.claude-3-5-sonnet-20241022-v2:0") + expect(result.current.info?.contextWindow).toBe(1_000_000) + }) + + it("should enable 1M context window for older Bedrock Claude 3.5 Sonnet when awsBedrock1MContext is true", () => { + const apiConfiguration: ProviderSettings = { + apiProvider: "bedrock", + apiModelId: "anthropic.claude-3-5-sonnet-20240620-v1:0", + awsBedrock1MContext: true, + } + + const wrapper = createWrapper() + const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper }) + + expect(result.current.id).toBe("anthropic.claude-3-5-sonnet-20240620-v1:0") + expect(result.current.info?.contextWindow).toBe(1_000_000) + }) + + it("should not affect context window for non-Claude Sonnet models", () => { + const apiConfiguration: ProviderSettings = { + apiProvider: "bedrock", + apiModelId: "anthropic.claude-3-opus-20240229-v1:0", + awsBedrock1MContext: true, + } + + const wrapper = createWrapper() + const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper }) + + expect(result.current.id).toBe("anthropic.claude-3-opus-20240229-v1:0") + expect(result.current.info?.contextWindow).toBe(200_000) + }) + }) + + describe("anthropic provider with 1M context", () => { + beforeEach(() => { + mockUseRouterModels.mockReturnValue({ + data: { + openrouter: {}, + requesty: {}, + glama: {}, + unbound: {}, + litellm: {}, + "io-intelligence": {}, + }, + isLoading: false, + isError: false, + } as any) + + mockUseOpenRouterModelProviders.mockReturnValue({ + data: {}, + isLoading: false, + isError: false, + } as any) + }) + + it("should enable 1M context window for Claude Sonnet 4 when anthropicBeta1MContext is true", () => { + const apiConfiguration: ProviderSettings = { + apiProvider: "anthropic", + apiModelId: "claude-sonnet-4-20250514", + anthropicBeta1MContext: true, + } + + const wrapper = createWrapper() + const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper }) + + expect(result.current.id).toBe("claude-sonnet-4-20250514") + expect(result.current.info?.contextWindow).toBe(1_000_000) + }) + + it("should enable 1M context window for Claude 3.5 Sonnet (claude-sonnet-4-5) when anthropicBeta1MContext is true", () => { + const apiConfiguration: ProviderSettings = { + apiProvider: "anthropic", + apiModelId: "claude-sonnet-4-5", + anthropicBeta1MContext: true, + } + + const wrapper = createWrapper() + const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper }) + + expect(result.current.id).toBe("claude-sonnet-4-5") + expect(result.current.info?.contextWindow).toBe(1_000_000) + }) + + it("should use default context window when anthropicBeta1MContext is false", () => { + const apiConfiguration: ProviderSettings = { + apiProvider: "anthropic", + apiModelId: "claude-sonnet-4-5", + anthropicBeta1MContext: false, + } + + const wrapper = createWrapper() + const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper }) + + expect(result.current.id).toBe("claude-sonnet-4-5") expect(result.current.info?.contextWindow).toBe(200_000) }) }) diff --git a/webview-ui/src/components/ui/hooks/useSelectedModel.ts b/webview-ui/src/components/ui/hooks/useSelectedModel.ts index b68e4809f29..2f32ee8a36a 100644 --- a/webview-ui/src/components/ui/hooks/useSelectedModel.ts +++ b/webview-ui/src/components/ui/hooks/useSelectedModel.ts @@ -364,10 +364,10 @@ function getSelectedModel({ const id = apiConfiguration.apiModelId ?? anthropicDefaultModelId const baseInfo = anthropicModels[id as keyof typeof anthropicModels] - // Apply 1M context beta tier pricing for Claude Sonnet 4 + // Apply 1M context beta tier pricing for Claude Sonnet 4 and 4.5 if ( provider === "anthropic" && - id === "claude-sonnet-4-20250514" && + (id === "claude-sonnet-4-20250514" || id === "claude-sonnet-4-5") && apiConfiguration.anthropicBeta1MContext && baseInfo ) {