fix(aibridge): support Bedrock Opus 4.8 adaptive thinking (#26691)

Bedrock rejects legacy `thinking.type=enabled` requests for Claude Opus
4.8 because the model requires adaptive thinking. The AI Bridge Bedrock
shim only recognized Opus 4.7 as adaptive-only, so Opus 4.8 requests
could fall through and produce Bedrock 400 responses.

Add Opus 4.8 to the adaptive-only model detection and cover the regional
Bedrock model ID form with a regression test.

<details>
<summary>Coder Agents disclosure</summary>

This PR was generated by Coder Agents on behalf of @ericpaulsen.

</details>
This commit is contained in:
Eric Paulsen
2026-06-25 16:50:25 +02:00
committed by GitHub
parent 1efdc56cbb
commit 96aecd83fa
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -417,7 +417,8 @@ func bedrockModelSupportsAdaptiveThinking(model string) bool {
//
// See https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-opus-4-7.html
func bedrockModelRequiresAdaptiveThinking(model string) bool {
return strings.Contains(model, "anthropic.claude-opus-4-7")
return strings.Contains(model, "anthropic.claude-opus-4-7") ||
strings.Contains(model, "anthropic.claude-opus-4-8")
}
// filterBedrockBetaFlags removes unsupported beta flags from the Anthropic-Beta
@@ -759,6 +759,12 @@ func TestAugmentRequestForBedrock_AdaptiveThinking(t *testing.T) {
requestBody: `{"max_tokens":10000,"thinking":{"type":"enabled","budget_tokens":8000}}`,
expectThinkingType: "adaptive",
},
{
name: "opus_4_8_model_with_enabled_thinking_is_converted_to_adaptive_and_drops_budget",
bedrockModel: "eu.anthropic.claude-opus-4-8",
requestBody: `{"max_tokens":10000,"thinking":{"type":"enabled","budget_tokens":5000}}`,
expectThinkingType: "adaptive",
},
{
// Opus 4.7 on Bedrock rejects output_config.format (structured
// outputs) with a 400 even though it accepts output_config.effort.