Add `Model._prepare_model_settings` hook
Draft
DS
2mo ago+87+87+01234567890123456789-45-45-01234567890123456789
This pull request was posted by Codex Desktop using gpt-5.6-sol on behalf of David.
- Follow-up to this review discussion.
Why we make these changes
The duplicated post-preparation settings work in AnthropicModel and BedrockConverseModel suggested a reusable adapter seam. This change adds the internal Model._prepare_model_settings hook so adapters can convert or filter merged settings without returning unchanged request parameters.
New public surface
None. Model._prepare_model_settings is an internal adapter hook.
User-visible behavior
pydantic_ai_slim/pydantic_ai/models/__init__.py :: Model.prepare_request()
└─ generic request preparation
+ └─ pydantic_ai_slim/pydantic_ai/models/__init__.py :: Model._prepare_model_settings()
+ └─ merged settings after adapter conversion or filtering
Verification
test_prepare_model_settings_hooktest_anthropic_opus_47_dedups_sampling_warning_across_settings_and_extra_bodytest_bedrock_anthropic_5_drops_sampling_settings
What changes for existing users
Nothing. Settings object identity, converter ordering, and provider warning attribution remain unchanged.
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. (Not applicable.)
- PR title is fit for the release changelog.