Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tmp/Roo-Code
Submodule Roo-Code added at 86debe
1 change: 1 addition & 0 deletions packages/types/src/providers/bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,4 @@ export const BEDROCK_REGIONS = [
].sort((a, b) => a.value.localeCompare(b.value))

export const BEDROCK_CLAUDE_SONNET_4_MODEL_ID = "anthropic.claude-sonnet-4-20250514-v1:0"
export const BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID = "anthropic.claude-sonnet-4-5-20250929-v1:0"
10 changes: 8 additions & 2 deletions src/api/providers/bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
BEDROCK_DEFAULT_CONTEXT,
AWS_INFERENCE_PROFILE_MAPPING,
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
} from "@roo-code/types"

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

// Add anthropic_beta for 1M context to additionalModelRequestFields
if (is1MContextEnabled) {
Expand Down Expand Up @@ -979,7 +982,10 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
// Check if 1M context is enabled for Claude Sonnet 4
// Use parseBaseModelId to handle cross-region inference prefixes
const baseModelId = this.parseBaseModelId(modelConfig.id)
if (baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && this.options.awsBedrock1MContext) {
if (
(baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID || baseModelId === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID) &&
this.options.awsBedrock1MContext
) {
// Update context window to 1M tokens when 1M context beta is enabled
modelConfig.info = {
...modelConfig.info,
Expand Down
7 changes: 5 additions & 2 deletions webview-ui/src/components/settings/providers/Bedrock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type ModelInfo,
BEDROCK_REGIONS,
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
} from "@roo-code/types"

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

// Check if the selected model supports 1M context (Claude Sonnet 4)
const supports1MContextBeta = apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID
// Check if the selected model supports 1M context (Claude Sonnet 4 or 4.5)
const supports1MContextBeta =
apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID ||
apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID

// Update the endpoint enabled state when the configuration changes
useEffect(() => {
Expand Down
9 changes: 7 additions & 2 deletions webview-ui/src/components/ui/hooks/useSelectedModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
qwenCodeModels,
vercelAiGatewayDefaultModelId,
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
deepInfraDefaultModelId,
} from "@roo-code/types"

Expand Down Expand Up @@ -200,8 +201,12 @@ function getSelectedModel({
}
}

// Apply 1M context for Claude Sonnet 4 when enabled
if (id === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && apiConfiguration.awsBedrock1MContext && baseInfo) {
// Apply 1M context for Claude Sonnet 4 or 4.5 when enabled
if (
(id === BEDROCK_CLAUDE_SONNET_4_MODEL_ID || id === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID) &&
apiConfiguration.awsBedrock1MContext &&
baseInfo
) {
// Create a new ModelInfo object with updated context window
const info: ModelInfo = {
...baseInfo,
Expand Down
Loading