fix(bedrock): correct Opus 4.7 model ID and add adaptive thinking support

- Rename model ID from "anthropic.claude-opus-4-7-v1" to "anthropic.claude-opus-4-7"
  to match the correct Bedrock model identifier (per PR #12288)
- Update BedrockAdditionalModelFields to support adaptive thinking type
- Add BEDROCK_ADAPTIVE_THINKING_ONLY_MODEL_IDS for Opus 4.7
- Opus 4.7 uses thinking.type: "adaptive" with output_config.effort
  instead of "enabled" with budget_tokens (which returns 400 error)
This commit is contained in:
Roo Code 2026-05-10 12:11:58 +00:00
parent 7747f6a10b
commit ba20c0d3d4
2 changed files with 37 additions and 11 deletions

View file

@ -167,7 +167,7 @@ export const bedrockModels = {
},
],
},
"anthropic.claude-opus-4-7-v1": {
"anthropic.claude-opus-4-7": {
maxTokens: 8192,
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
supportsImages: true,
@ -549,7 +549,7 @@ export const BEDROCK_1M_CONTEXT_MODEL_IDS = [
"anthropic.claude-sonnet-4-5-20250929-v1:0",
"anthropic.claude-sonnet-4-6",
"anthropic.claude-opus-4-6-v1",
"anthropic.claude-opus-4-7-v1",
"anthropic.claude-opus-4-7",
] as const
// Amazon Bedrock models that support Global Inference profiles
@ -568,7 +568,7 @@ export const BEDROCK_GLOBAL_INFERENCE_MODEL_IDS = [
"anthropic.claude-haiku-4-5-20251001-v1:0",
"anthropic.claude-opus-4-5-20251101-v1:0",
"anthropic.claude-opus-4-6-v1",
"anthropic.claude-opus-4-7-v1",
"anthropic.claude-opus-4-7",
] as const
// Amazon Bedrock Service Tier types

View file

@ -59,14 +59,24 @@ interface BedrockInferenceConfig {
// Define interface for Bedrock additional model request fields
// This includes thinking configuration, 1M context beta, and other model-specific parameters
interface BedrockAdditionalModelFields {
thinking?: {
type: "enabled"
budget_tokens: number
thinking?:
| {
type: "enabled"
budget_tokens: number
}
| {
type: "adaptive"
}
output_config?: {
effort?: "low" | "medium" | "high"
}
anthropic_beta?: string[]
[key: string]: any // Add index signature to be compatible with DocumentType
}
// Models that only support thinking.type: "adaptive" (not "enabled" with budget_tokens)
const BEDROCK_ADAPTIVE_THINKING_ONLY_MODEL_IDS = ["anthropic.claude-opus-4-7"] as const
// Define interface for Bedrock payload
interface BedrockPayload {
modelId: BedrockModelId | string
@ -390,12 +400,28 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
if ((isThinkingExplicitlyEnabled || isThinkingEnabledBySettings) && modelConfig.info.supportsReasoningBudget) {
thinkingEnabled = true
additionalModelRequestFields = {
thinking: {
type: "enabled",
budget_tokens: metadata?.thinking?.maxThinkingTokens || modelConfig.reasoningBudget || 4096,
},
// Opus 4.7 only supports thinking.type: "adaptive" with output_config.effort
// (NOT "enabled" with budget_tokens which returns a 400 error)
const baseId = this.parseBaseModelId(modelConfig.id)
if (BEDROCK_ADAPTIVE_THINKING_ONLY_MODEL_IDS.includes(baseId as any)) {
additionalModelRequestFields = {
thinking: {
type: "adaptive",
},
output_config: {
effort: "high",
},
}
} else {
additionalModelRequestFields = {
thinking: {
type: "enabled",
budget_tokens: metadata?.thinking?.maxThinkingTokens || modelConfig.reasoningBudget || 4096,
},
}
}
logger.info("Extended thinking enabled for Bedrock request", {
ctx: "bedrock",
modelId: modelConfig.id,