Honor `anthropic_disallows_sampling_settings` in `BedrockConverseModel`

Merged
RS
3mo ago
+307-9

This pull request was posted by Codex Desktop using gpt-5.6-sol on behalf of David.

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

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.