Fix Bedrock effort and regional routing (#61597)
Fixes Amazon Bedrock adaptive-thinking requests so the selected effort reaches Anthropic models, and routes Claude Opus 4.7 and 4.8 through their documented Japanese and Canadian inference profiles. Release Notes: - Fixed Amazon Bedrock effort selection and regional routing for Claude Opus 4.7 and 4.8.
This commit is contained in:
1 parent
1c244c194b
commit
1c2a643cde
2 files changed
+49
-6
No files matched your search
@@ -221,7 +221,7 @@ fn thinking_request_fields(thinking: &Thinking) -> HashMap<String, Document> {
|
||||
Thinking::Enabled {
|
||||
budget_tokens: None,
|
||||
} => {}
|
||||
Thinking::Adaptive { effort: _ } => {
|
||||
Thinking::Adaptive { effort } => {
|
||||
fields.insert(
|
||||
"thinking".to_string(),
|
||||
Document::from(HashMap::from([
|
||||
@@ -232,6 +232,13 @@ fn thinking_request_fields(thinking: &Thinking) -> HashMap<String, Document> {
|
||||
),
|
||||
])),
|
||||
);
|
||||
fields.insert(
|
||||
"output_config".to_string(),
|
||||
Document::from(HashMap::from([(
|
||||
"effort".to_string(),
|
||||
Document::String(effort.as_str().to_string()),
|
||||
)])),
|
||||
);
|
||||
}
|
||||
Thinking::Disabled => {
|
||||
// On Claude Opus 5 omitting the `thinking` field means adaptive
|
||||
@@ -306,6 +313,20 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_adaptive_thinking_serializes_effort_in_output_config() {
|
||||
let fields = thinking_request_fields(&Thinking::Adaptive {
|
||||
effort: BedrockAdaptiveThinkingEffort::XHigh,
|
||||
});
|
||||
|
||||
let thinking = fields.get("thinking").expect("thinking field");
|
||||
assert_eq!(string_field(thinking, "type"), Some("adaptive"));
|
||||
assert_eq!(string_field(thinking, "display"), Some("summarized"));
|
||||
|
||||
let output_config = fields.get("output_config").expect("output_config field");
|
||||
assert_eq!(string_field(output_config, "effort"), Some("xhigh"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_disabled_thinking_serializes_opt_out_without_effort() {
|
||||
let fields = thinking_request_fields(&Thinking::Disabled);
|
||||
|
||||
@@ -788,10 +788,14 @@ impl ConverseModel {
|
||||
|
||||
// Canada has no Claude-specific `ca.` profiles. AWS instead lists
|
||||
// ca-central-1 and ca-west-1 as source regions of the US geo
|
||||
// profile for these models, which keeps data within US and Canada
|
||||
// regions. See the per-model cards, e.g.
|
||||
// <https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-opus-5.html>.
|
||||
(Self::ClaudeOpus5, "ca") => Ok(format!("us.{}", model_id)),
|
||||
// profiles for these models, which keep data within US and Canada
|
||||
// regions:
|
||||
// <https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-opus-5.html>
|
||||
// <https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-opus-4-8.html>
|
||||
// <https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-opus-4-7.html>
|
||||
(Self::ClaudeOpus5 | Self::ClaudeOpus4_8 | Self::ClaudeOpus4_7, "ca") => {
|
||||
Ok(format!("us.{}", model_id))
|
||||
}
|
||||
|
||||
// EU region inference profiles
|
||||
(
|
||||
@@ -826,7 +830,9 @@ impl ConverseModel {
|
||||
// (plus `global.`):
|
||||
// <https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-opus-5.html>
|
||||
(
|
||||
Self::ClaudeSonnet4_6
|
||||
Self::ClaudeOpus4_8
|
||||
| Self::ClaudeOpus4_7
|
||||
| Self::ClaudeSonnet4_6
|
||||
| Self::ClaudeSonnet4_5
|
||||
| Self::ClaudeHaiku4_5
|
||||
| Self::Nova2Lite,
|
||||
@@ -1242,6 +1248,14 @@ mod tests {
|
||||
ConverseModel::ClaudeOpus5.cross_region_inference_id("ap-northeast-1", false)?,
|
||||
"anthropic.claude-opus-5"
|
||||
);
|
||||
assert_eq!(
|
||||
ConverseModel::ClaudeOpus4_8.cross_region_inference_id("ap-northeast-1", false)?,
|
||||
"jp.anthropic.claude-opus-4-8"
|
||||
);
|
||||
assert_eq!(
|
||||
ConverseModel::ClaudeOpus4_7.cross_region_inference_id("ap-northeast-3", false)?,
|
||||
"jp.anthropic.claude-opus-4-7"
|
||||
);
|
||||
assert_eq!(
|
||||
ConverseModel::ClaudeSonnet4_5.cross_region_inference_id("ap-northeast-3", false)?,
|
||||
"jp.anthropic.claude-sonnet-4-5-20250929-v1:0"
|
||||
@@ -1265,6 +1279,14 @@ mod tests {
|
||||
ConverseModel::ClaudeOpus5.cross_region_inference_id("ca-central-1", false)?,
|
||||
"us.anthropic.claude-opus-5"
|
||||
);
|
||||
assert_eq!(
|
||||
ConverseModel::ClaudeOpus4_8.cross_region_inference_id("ca-west-1", false)?,
|
||||
"us.anthropic.claude-opus-4-8"
|
||||
);
|
||||
assert_eq!(
|
||||
ConverseModel::ClaudeOpus4_7.cross_region_inference_id("ca-central-1", false)?,
|
||||
"us.anthropic.claude-opus-4-7"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user