Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 00d91fa

Browse files
committed
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)
1 parent 97c79d4 commit 00d91fa

2 files changed

Lines changed: 37 additions & 11 deletions

File tree

packages/types/src/providers/bedrock.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const bedrockModels = {
167167
},
168168
],
169169
},
170-
"anthropic.claude-opus-4-7-v1": {
170+
"anthropic.claude-opus-4-7": {
171171
maxTokens: 8192,
172172
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
173173
supportsImages: true,
@@ -549,7 +549,7 @@ export const BEDROCK_1M_CONTEXT_MODEL_IDS = [
549549
"anthropic.claude-sonnet-4-5-20250929-v1:0",
550550
"anthropic.claude-sonnet-4-6",
551551
"anthropic.claude-opus-4-6-v1",
552-
"anthropic.claude-opus-4-7-v1",
552+
"anthropic.claude-opus-4-7",
553553
] as const
554554

555555
// Amazon Bedrock models that support Global Inference profiles
@@ -568,7 +568,7 @@ export const BEDROCK_GLOBAL_INFERENCE_MODEL_IDS = [
568568
"anthropic.claude-haiku-4-5-20251001-v1:0",
569569
"anthropic.claude-opus-4-5-20251101-v1:0",
570570
"anthropic.claude-opus-4-6-v1",
571-
"anthropic.claude-opus-4-7-v1",
571+
"anthropic.claude-opus-4-7",
572572
] as const
573573

574574
// Amazon Bedrock Service Tier types

src/api/providers/bedrock.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,24 @@ interface BedrockInferenceConfig {
6161
// Define interface for Bedrock additional model request fields
6262
// This includes thinking configuration, 1M context beta, and other model-specific parameters
6363
interface BedrockAdditionalModelFields {
64-
thinking?: {
65-
type: "enabled"
66-
budget_tokens: number
64+
thinking?:
65+
| {
66+
type: "enabled"
67+
budget_tokens: number
68+
}
69+
| {
70+
type: "adaptive"
71+
}
72+
output_config?: {
73+
effort?: "low" | "medium" | "high"
6774
}
6875
anthropic_beta?: string[]
6976
[key: string]: any // Add index signature to be compatible with DocumentType
7077
}
7178

79+
// Models that only support thinking.type: "adaptive" (not "enabled" with budget_tokens)
80+
const BEDROCK_ADAPTIVE_THINKING_ONLY_MODEL_IDS = ["anthropic.claude-opus-4-7"] as const
81+
7282
// Define interface for Bedrock payload
7383
interface BedrockPayload {
7484
modelId: BedrockModelId | string
@@ -392,12 +402,28 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
392402

393403
if ((isThinkingExplicitlyEnabled || isThinkingEnabledBySettings) && modelConfig.info.supportsReasoningBudget) {
394404
thinkingEnabled = true
395-
additionalModelRequestFields = {
396-
thinking: {
397-
type: "enabled",
398-
budget_tokens: metadata?.thinking?.maxThinkingTokens || modelConfig.reasoningBudget || 4096,
399-
},
405+
406+
// Opus 4.7 only supports thinking.type: "adaptive" with output_config.effort
407+
// (NOT "enabled" with budget_tokens which returns a 400 error)
408+
const baseId = this.parseBaseModelId(modelConfig.id)
409+
if (BEDROCK_ADAPTIVE_THINKING_ONLY_MODEL_IDS.includes(baseId as any)) {
410+
additionalModelRequestFields = {
411+
thinking: {
412+
type: "adaptive",
413+
},
414+
output_config: {
415+
effort: "high",
416+
},
417+
}
418+
} else {
419+
additionalModelRequestFields = {
420+
thinking: {
421+
type: "enabled",
422+
budget_tokens: metadata?.thinking?.maxThinkingTokens || modelConfig.reasoningBudget || 4096,
423+
},
424+
}
400425
}
426+
401427
logger.info("Extended thinking enabled for Bedrock request", {
402428
ctx: "bedrock",
403429
modelId: modelConfig.id,

0 commit comments

Comments
 (0)