Skip to content

Commit 5d5182b

Browse files
committed
fix: add 1M context window checkbox for Claude 3.5 Sonnet v2 in Bedrock provider
- Added BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID constant for the newer model - Updated Bedrock.tsx UI component to show 1M context checkbox for both Sonnet models - Updated bedrock.ts provider to handle 1M context for both models - Updated useSelectedModel hook to apply 1M context for both models Fixes #8381
1 parent f3b3751 commit 5d5182b

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

.tmp/Roo-Code

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 86debeef43acbea9bdc1aa4b38d514541e164c91

packages/types/src/providers/bedrock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,4 @@ export const BEDROCK_REGIONS = [
458458
].sort((a, b) => a.value.localeCompare(b.value))
459459

460460
export const BEDROCK_CLAUDE_SONNET_4_MODEL_ID = "anthropic.claude-sonnet-4-20250514-v1:0"
461+
export const BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID = "anthropic.claude-sonnet-4-5-20250929-v1:0"

src/api/providers/bedrock.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
BEDROCK_DEFAULT_CONTEXT,
2323
AWS_INFERENCE_PROFILE_MAPPING,
2424
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
25+
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
2526
} from "@roo-code/types"
2627

2728
import { ApiStream } from "../transform/stream"
@@ -381,7 +382,9 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
381382
// Check if 1M context is enabled for Claude Sonnet 4
382383
// Use parseBaseModelId to handle cross-region inference prefixes
383384
const baseModelId = this.parseBaseModelId(modelConfig.id)
384-
const is1MContextEnabled = baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && this.options.awsBedrock1MContext
385+
const is1MContextEnabled =
386+
(baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID || baseModelId === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID) &&
387+
this.options.awsBedrock1MContext
385388

386389
// Add anthropic_beta for 1M context to additionalModelRequestFields
387390
if (is1MContextEnabled) {
@@ -979,7 +982,10 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
979982
// Check if 1M context is enabled for Claude Sonnet 4
980983
// Use parseBaseModelId to handle cross-region inference prefixes
981984
const baseModelId = this.parseBaseModelId(modelConfig.id)
982-
if (baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && this.options.awsBedrock1MContext) {
985+
if (
986+
(baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID || baseModelId === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID) &&
987+
this.options.awsBedrock1MContext
988+
) {
983989
// Update context window to 1M tokens when 1M context beta is enabled
984990
modelConfig.info = {
985991
...modelConfig.info,

webview-ui/src/components/settings/providers/Bedrock.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
type ModelInfo,
88
BEDROCK_REGIONS,
99
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
10+
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
1011
} from "@roo-code/types"
1112

1213
import { useAppTranslation } from "@src/i18n/TranslationContext"
@@ -24,8 +25,10 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo
2425
const { t } = useAppTranslation()
2526
const [awsEndpointSelected, setAwsEndpointSelected] = useState(!!apiConfiguration?.awsBedrockEndpointEnabled)
2627

27-
// Check if the selected model supports 1M context (Claude Sonnet 4)
28-
const supports1MContextBeta = apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID
28+
// Check if the selected model supports 1M context (Claude Sonnet 4 or 4.5)
29+
const supports1MContextBeta =
30+
apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID ||
31+
apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID
2932

3033
// Update the endpoint enabled state when the configuration changes
3134
useEffect(() => {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
qwenCodeModels,
5757
vercelAiGatewayDefaultModelId,
5858
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
59+
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
5960
deepInfraDefaultModelId,
6061
} from "@roo-code/types"
6162

@@ -200,8 +201,12 @@ function getSelectedModel({
200201
}
201202
}
202203

203-
// Apply 1M context for Claude Sonnet 4 when enabled
204-
if (id === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && apiConfiguration.awsBedrock1MContext && baseInfo) {
204+
// Apply 1M context for Claude Sonnet 4 or 4.5 when enabled
205+
if (
206+
(id === BEDROCK_CLAUDE_SONNET_4_MODEL_ID || id === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID) &&
207+
apiConfiguration.awsBedrock1MContext &&
208+
baseInfo
209+
) {
205210
// Create a new ModelInfo object with updated context window
206211
const info: ModelInfo = {
207212
...baseInfo,

0 commit comments

Comments
 (0)