Skip to content

Commit 22113cd

Browse files
mrubensbrunobergher
authored andcommitted
A couple more sonnet 4.5 fixes (#8421)
1 parent e46eb8a commit 22113cd

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

packages/types/src/providers/bedrock.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ export const BEDROCK_REGIONS = [
457457
{ value: "us-gov-west-1", label: "us-gov-west-1" },
458458
].sort((a, b) => a.value.localeCompare(b.value))
459459

460-
export const BEDROCK_CLAUDE_SONNET_4_MODEL_ID = "anthropic.claude-sonnet-4-20250514-v1:0"
461460
export const BEDROCK_1M_CONTEXT_MODEL_IDS = [
462461
"anthropic.claude-sonnet-4-20250514-v1:0",
463462
"anthropic.claude-sonnet-4-5-20250929-v1:0",

src/api/providers/__tests__/bedrock.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ vi.mock("@aws-sdk/client-bedrock-runtime", () => {
2525

2626
import { AwsBedrockHandler } from "../bedrock"
2727
import { ConverseStreamCommand, BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime"
28-
import { BEDROCK_CLAUDE_SONNET_4_MODEL_ID } from "@roo-code/types"
28+
import { BEDROCK_1M_CONTEXT_MODEL_IDS } from "@roo-code/types"
2929

3030
import type { Anthropic } from "@anthropic-ai/sdk"
3131

@@ -569,7 +569,7 @@ describe("AwsBedrockHandler", () => {
569569
describe("1M context beta feature", () => {
570570
it("should enable 1M context window when awsBedrock1MContext is true for Claude Sonnet 4", () => {
571571
const handler = new AwsBedrockHandler({
572-
apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
572+
apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0],
573573
awsAccessKey: "test",
574574
awsSecretKey: "test",
575575
awsRegion: "us-east-1",
@@ -584,7 +584,7 @@ describe("AwsBedrockHandler", () => {
584584

585585
it("should use default context window when awsBedrock1MContext is false for Claude Sonnet 4", () => {
586586
const handler = new AwsBedrockHandler({
587-
apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
587+
apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0],
588588
awsAccessKey: "test",
589589
awsSecretKey: "test",
590590
awsRegion: "us-east-1",
@@ -614,7 +614,7 @@ describe("AwsBedrockHandler", () => {
614614

615615
it("should include anthropic_beta parameter when 1M context is enabled", async () => {
616616
const handler = new AwsBedrockHandler({
617-
apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
617+
apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0],
618618
awsAccessKey: "test",
619619
awsSecretKey: "test",
620620
awsRegion: "us-east-1",
@@ -644,7 +644,7 @@ describe("AwsBedrockHandler", () => {
644644

645645
it("should not include anthropic_beta parameter when 1M context is disabled", async () => {
646646
const handler = new AwsBedrockHandler({
647-
apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
647+
apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0],
648648
awsAccessKey: "test",
649649
awsSecretKey: "test",
650650
awsRegion: "us-east-1",
@@ -698,7 +698,7 @@ describe("AwsBedrockHandler", () => {
698698

699699
it("should enable 1M context window with cross-region inference for Claude Sonnet 4", () => {
700700
const handler = new AwsBedrockHandler({
701-
apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
701+
apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0],
702702
awsAccessKey: "test",
703703
awsSecretKey: "test",
704704
awsRegion: "us-east-1",
@@ -711,12 +711,12 @@ describe("AwsBedrockHandler", () => {
711711
// Should have 1M context window even with cross-region prefix
712712
expect(model.info.contextWindow).toBe(1_000_000)
713713
// Model ID should have cross-region prefix
714-
expect(model.id).toBe(`us.${BEDROCK_CLAUDE_SONNET_4_MODEL_ID}`)
714+
expect(model.id).toBe(`us.${BEDROCK_1M_CONTEXT_MODEL_IDS[0]}`)
715715
})
716716

717717
it("should include anthropic_beta parameter with cross-region inference for Claude Sonnet 4", async () => {
718718
const handler = new AwsBedrockHandler({
719-
apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
719+
apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0],
720720
awsAccessKey: "test",
721721
awsSecretKey: "test",
722722
awsRegion: "us-east-1",
@@ -746,7 +746,7 @@ describe("AwsBedrockHandler", () => {
746746
// Should not include anthropic_version since thinking is not enabled
747747
expect(commandArg.additionalModelRequestFields.anthropic_version).toBeUndefined()
748748
// Model ID should have cross-region prefix
749-
expect(commandArg.modelId).toBe(`us.${BEDROCK_CLAUDE_SONNET_4_MODEL_ID}`)
749+
expect(commandArg.modelId).toBe(`us.${BEDROCK_1M_CONTEXT_MODEL_IDS[0]}`)
750750
})
751751
})
752752
})

src/api/providers/bedrock.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
BEDROCK_MAX_TOKENS,
2222
BEDROCK_DEFAULT_CONTEXT,
2323
AWS_INFERENCE_PROFILE_MAPPING,
24-
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
2524
BEDROCK_1M_CONTEXT_MODEL_IDS,
2625
} from "@roo-code/types"
2726

@@ -373,7 +372,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
373372
maxTokens: modelConfig.maxTokens || (modelConfig.info.maxTokens as number),
374373
temperature: modelConfig.temperature ?? (this.options.modelTemperature as number),
375374
}
376-
375+
377376
// Check if 1M context is enabled for Claude Sonnet 4
378377
// Use parseBaseModelId to handle cross-region inference prefixes
379378
const baseModelId = this.parseBaseModelId(modelConfig.id)

webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
55
import { renderHook } from "@testing-library/react"
66
import type { Mock } from "vitest"
77

8-
import { ProviderSettings, ModelInfo, BEDROCK_CLAUDE_SONNET_4_MODEL_ID } from "@roo-code/types"
8+
import { ProviderSettings, ModelInfo, BEDROCK_1M_CONTEXT_MODEL_IDS } from "@roo-code/types"
99

1010
import { useSelectedModel } from "../useSelectedModel"
1111
import { useRouterModels } from "../useRouterModels"
@@ -474,28 +474,28 @@ describe("useSelectedModel", () => {
474474
it("should enable 1M context window for Bedrock Claude Sonnet 4 when awsBedrock1MContext is true", () => {
475475
const apiConfiguration: ProviderSettings = {
476476
apiProvider: "bedrock",
477-
apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
477+
apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0],
478478
awsBedrock1MContext: true,
479479
}
480480

481481
const wrapper = createWrapper()
482482
const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper })
483483

484-
expect(result.current.id).toBe(BEDROCK_CLAUDE_SONNET_4_MODEL_ID)
484+
expect(result.current.id).toBe(BEDROCK_1M_CONTEXT_MODEL_IDS[0])
485485
expect(result.current.info?.contextWindow).toBe(1_000_000)
486486
})
487487

488488
it("should use default context window for Bedrock Claude Sonnet 4 when awsBedrock1MContext is false", () => {
489489
const apiConfiguration: ProviderSettings = {
490490
apiProvider: "bedrock",
491-
apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
491+
apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0],
492492
awsBedrock1MContext: false,
493493
}
494494

495495
const wrapper = createWrapper()
496496
const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper })
497497

498-
expect(result.current.id).toBe(BEDROCK_CLAUDE_SONNET_4_MODEL_ID)
498+
expect(result.current.id).toBe(BEDROCK_1M_CONTEXT_MODEL_IDS[0])
499499
expect(result.current.info?.contextWindow).toBe(200_000)
500500
})
501501

webview-ui/src/components/ui/hooks/useSelectedModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ function getSelectedModel({
367367
// Apply 1M context beta tier pricing for Claude Sonnet 4
368368
if (
369369
provider === "anthropic" &&
370-
id === "claude-sonnet-4-20250514" &&
370+
(id === "claude-sonnet-4-20250514" || id === "claude-sonnet-4-5") &&
371371
apiConfiguration.anthropicBeta1MContext &&
372372
baseInfo
373373
) {
374-
// Type assertion since we know claude-sonnet-4-20250514 has tiers
374+
// Type assertion since we know claude-sonnet-4-20250514 and claude-sonnet-4-5 have tiers
375375
const modelWithTiers = baseInfo as typeof baseInfo & {
376376
tiers?: Array<{
377377
contextWindow: number

0 commit comments

Comments
 (0)