Skip to content

fix(intercept/messages): convert enabled thinking to adaptive for Bedrock Opus 4.7+#281

Closed
dannykopping wants to merge 1 commit into
mainfrom
dk/issue-280-bedrock-opus-4-7-adaptive-only-thinking
Closed

fix(intercept/messages): convert enabled thinking to adaptive for Bedrock Opus 4.7+#281
dannykopping wants to merge 1 commit into
mainfrom
dk/issue-280-bedrock-opus-4-7-adaptive-only-thinking

Conversation

@dannykopping
Copy link
Copy Markdown
Collaborator

@dannykopping dannykopping commented May 14, 2026

Disclaimer: implemented by a Coder Agent using Claude Opus 4.6

Fixes #280.


Closing in favour of the same change against coder/coder, since aibridge is now vendored there.

…rock Opus 4.7+

Claude Opus 4.7 (and future adaptive-only Bedrock models) reject the legacy
thinking.type "enabled" + budget_tokens shape with a 400. Claude Code falls
back to that shape when it cannot read the upstream model's capability
metadata, which is exactly the case when AI Bridge sits between the client
and Bedrock.

This is the symmetric counterpart to the adaptive -> enabled conversion
added in #225 for older Bedrock models. The new conversion is gated on a
bedrockModelRequiresAdaptiveThinking helper that matches Opus 4.7 model IDs
(and ARN-style application inference profile names).

The effort level is derived from the original budget_tokens / max_tokens
ratio using the midpoints of the forward mapping's anchor ratios, so a
payload that round-trips through both conversions lands on the same effort
level it started with. An explicit output_config.effort already present in
the request is preserved.

Adaptive-only models support output_config natively (no beta flag), so the
field-strip pass is updated to exempt output_config for those models.

Fixes #280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Bedrock models that only support adaptive thinking (Opus 4.7+) reject thinking.type: "enabled" requests

1 participant