Skip to content

Conversation

afarntrog
Copy link
Contributor

Description

  • Format default model ID to use the inference for the region the user is using. If the region does not support inference endpoint then we show a helpful warning and allow the bedrock to throw an exception.
  • Update tests to handle formatted default model ID

Related Issues

#732 #804 #770

Documentation PR

Will create a separate pr for docs in the getting started example.

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

- Format default model ID with region prefix (us/eu/apac)
- Add warning for unsupported regions when using default model
- Preserve custom model_id without region formatting
- Map 'ap' region prefix to 'apac' for inference endpoints
- Update tests to handle formatted default model ID
- Rename get_model_prefix_with_warning to _get_default_model_with_warning for clarity
- Add support for us-gov regions in default model selection
- Implement override detection for DEFAULT_BEDROCK_MODEL_ID constant
- Return early when custom model_id is provided in config
- Fix typo: 'then' -> 'than' in comment
- Add comprehensive test coverage for new functionality
- Update existing tests to match new method signature
to some custom `model_id` thinking it'll be used automatically in the Bedrock init.
Therefore, we should not modify/format it if it was changed.

Use case 2) Customers are used to `DEFAULT_BEDROCK_MODEL_ID` being set to a valid model.
And it's possibly they are therefore using
It in their code to do things like dynamically set the model: `agent.model.set_config(model_id=DEFAULT_BEDROCK_MODEL_ID)`
We therefore need to handle that assumption and keep the `DEFAULT_BEDROCK_MODEL_ID`
as is: `"us.anthropic.claude-sonnet-4-20250514-v1:0"`
@afarntrog afarntrog enabled auto-merge (squash) September 10, 2025 18:45
@afarntrog afarntrog merged commit 64d61e0 into strands-agents:main Sep 10, 2025
11 of 12 checks passed
This was referenced Sep 17, 2025
Unshure pushed a commit to Unshure/sdk-python that referenced this pull request Sep 24, 2025
These changes introduce region-aware default model ID functionality for Bedrock, formatting based on region prefixes, warnings for unsupported regions, and preservation of custom model IDs. Comprehensive test coverage was added, and existing tests were updated. We also maintain compatibility for two key use cases: preserving customer-overridden model IDs and maintaining compatibility with existing DEFAULT_BEDROCK_MODEL_ID usage patterns.
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.

4 participants