feat: Add Claude Opus 4.7 adaptive thinking support#249
Open
bszadkowski wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
#248
Description of changes:
Adds support for Claude Opus 4.7's adaptive thinking API format, which differs from earlier Claude models in three ways (see linked issue for reproduction steps with exact error responses).
Key changes in
src/api/models/bedrock.py:ADAPTIVE_THINKING_MODELS— New model set for Opus 4.7+. Whenreasoning_effortis requested, sendsthinking.type=adaptive+output_config.effortviaadditionalModelRequestFieldsinstead ofreasoning_config.budget_tokens.NO_SAMPLING_PARAMS_MODELS— Stripstemperature/topPfrominferenceConfigfor models that reject sampling parameters.NO_ASSISTANT_PREFILL_MODELS— Added Opus 4.7 (like Opus 4.6, it doesn't support assistant message prefill).All changes are additive and backward-compatible — existing models are unaffected.
Tests (optional, can be omitted):
This PR includes
tests/conftest.pyandtests/test_opus47_properties.pycovering the following scenarios:reasoning_effortvalues (low/medium/high) onus.anthropic.claude-opus-4-7(cross-region inference profile), verifiesadditionalModelRequestFieldscontainsthinking.type=adaptive+output_config.effort, and thatreasoning_config/budget_tokensare absent.temperatureandtopPare removed frominferenceConfigacross a range of input combinations, whilemaxTokensis preserved.reasoning_config.budget_tokensformat unchanged.Since the upstream repo does not currently have a test suite, maintainers may choose to exclude these files if they prefer to keep the test infrastructure decision separate.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.