Honor `anthropic_disallows_sampling_settings` in `BedrockConverseModel`
This pull request was posted by Codex Desktop using gpt-5.6-sol on behalf of David.
- Closes #7791
Why we make these changes
BedrockConverseModel sent unified temperature, top_p, and top_k to Bedrock Anthropic models whose anthropic_disallows_sampling_settings profile flag marks them as rejected. Shared model_settings therefore failed with a Bedrock 400 instead of matching AnthropicModel's warning-and-drop behavior.
BedrockConverseModel.prepare_request() now drops those unified settings and warns before building the Bedrock request. Values in bedrock_additional_model_requests_fields remain untouched as Bedrock's raw escape hatch.
New public surface
none
User-visible behavior
agent = Agent(
'bedrock:eu.anthropic.claude-opus-5',
model_settings={'temperature': 0.2},
)
- await agent.run('...')
- # Bedrock returns a 400
+ await agent.run('...')
+ # Pydantic AI warns and sends no `temperature`
Verification
test_bedrock_anthropic_5_api_rejects_sampling_settingsrecords Bedrock's rejection.test_bedrock_anthropic_5_drops_sampling_settingsbody-matches the filtered request.test_bedrock_non_flagged_model_keeps_sampling_settingsbody-matches the unfiltered request.test_bedrock_anthropic_5_count_tokens_drops_sampling_settingscovers the sharedcount_tokens()path.
What changes for existing users
Affected Bedrock Anthropic models now warn and omit unified sampling settings instead of returning a Bedrock validation error; other profiles and raw Bedrock additional request fields retain their behavior.
Checklist
- Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
- PR title is fit for the release changelog.