1616from strands import _exception_notes
1717from strands .models import BedrockModel , CacheConfig
1818from strands .models .bedrock import (
19- _DEFAULT_BEDROCK_MODEL_ID ,
2019 DEFAULT_BEDROCK_MODEL_ID ,
2120 DEFAULT_BEDROCK_REGION ,
2221 DEFAULT_READ_TIMEOUT ,
2322)
2423from strands .types .exceptions import ContextWindowOverflowException , ModelThrottledException
2524from strands .types .tools import ToolSpec
2625
27- FORMATTED_DEFAULT_MODEL_ID = DEFAULT_BEDROCK_MODEL_ID . format ( "us" )
26+ FORMATTED_DEFAULT_MODEL_ID = DEFAULT_BEDROCK_MODEL_ID
2827
2928
3029@pytest .fixture
@@ -2213,43 +2212,24 @@ def test_tool_choice_none_no_warning(model, messages, captured_warnings):
22132212
22142213
22152214def test_get_default_model_with_warning_supported_regions_shows_no_warning (captured_warnings ):
2216- """Test get_model_prefix_with_warning doesn't warn for supported region prefixes ."""
2215+ """Test _get_default_model_with_warning doesn't warn for any region (global profile works everywhere) ."""
22172216 BedrockModel ._get_default_model_with_warning ("us-west-2" )
22182217 BedrockModel ._get_default_model_with_warning ("eu-west-2" )
22192218 assert all ("does not support" not in str (w .message ) for w in captured_warnings )
22202219
22212220
2222- def test_get_default_model_for_supported_eu_region_returns_correct_model_id (captured_warnings ):
2223- model_id = BedrockModel ._get_default_model_with_warning ("eu-west-1" )
2224- assert model_id == "eu.anthropic.claude-sonnet-4-20250514-v1:0"
2221+ def test_get_default_model_returns_global_inference_profile (captured_warnings ):
2222+ """Default model id is the global inference profile regardless of region."""
2223+ for region in ("us-east-1" , "eu-west-1" , "us-gov-west-1" , "ap-southeast-1" , "ca-central-1" ):
2224+ assert BedrockModel ._get_default_model_with_warning (region ) == DEFAULT_BEDROCK_MODEL_ID
22252225 assert all ("does not support" not in str (w .message ) for w in captured_warnings )
22262226
22272227
2228- def test_get_default_model_for_supported_us_region_returns_correct_model_id (captured_warnings ):
2229- model_id = BedrockModel ._get_default_model_with_warning ("us-east-1" )
2230- assert model_id == "us.anthropic.claude-sonnet-4-20250514-v1:0"
2231- assert all ("does not support" not in str (w .message ) for w in captured_warnings )
2232-
2233-
2234- def test_get_default_model_for_supported_gov_region_returns_correct_model_id (captured_warnings ):
2235- model_id = BedrockModel ._get_default_model_with_warning ("us-gov-west-1" )
2236- assert model_id == "us-gov.anthropic.claude-sonnet-4-20250514-v1:0"
2237- assert all ("does not support" not in str (w .message ) for w in captured_warnings )
2238-
2239-
2240- def test_get_model_prefix_for_ap_region_converts_to_apac_endpoint (captured_warnings ):
2241- """Test _get_default_model_with_warning warns for APAC regions since 'ap' is not in supported prefixes."""
2242- model_id = BedrockModel ._get_default_model_with_warning ("ap-southeast-1" )
2243- assert model_id == "apac.anthropic.claude-sonnet-4-20250514-v1:0"
2244-
2245-
2246- def test_get_default_model_with_warning_unsupported_region_warns (captured_warnings ):
2247- """Test _get_default_model_with_warning warns for unsupported regions."""
2228+ def test_get_default_model_with_warning_unsupported_region_does_not_warn (captured_warnings ):
2229+ """Global inference profile works across all regions, so no region-support warning is emitted."""
22482230 BedrockModel ._get_default_model_with_warning ("ca-central-1" )
22492231 region_warnings = [w for w in captured_warnings if "does not support" in str (w .message )]
2250- assert len (region_warnings ) == 1
2251- assert "This region ca-central-1 does not support" in str (region_warnings [0 ].message )
2252- assert "our default inference endpoint" in str (region_warnings [0 ].message )
2232+ assert len (region_warnings ) == 0
22532233
22542234
22552235def test_get_default_model_with_warning_no_warning_with_custom_model_id (captured_warnings ):
@@ -2261,13 +2241,12 @@ def test_get_default_model_with_warning_no_warning_with_custom_model_id(captured
22612241 assert len (captured_warnings ) == 0
22622242
22632243
2264- def test_init_with_unsupported_region_warns (session_cls , captured_warnings ):
2265- """Test BedrockModel initialization warns for unsupported regions."""
2244+ def test_init_with_unsupported_region_does_not_warn (session_cls , captured_warnings ):
2245+ """BedrockModel initialization does not warn for ' unsupported' regions when using the global profile ."""
22662246 BedrockModel (region_name = "ca-central-1" )
22672247
22682248 region_warnings = [w for w in captured_warnings if "does not support" in str (w .message )]
2269- assert len (region_warnings ) == 1
2270- assert "This region ca-central-1 does not support" in str (region_warnings [0 ].message )
2249+ assert len (region_warnings ) == 0
22712250
22722251
22732252def test_init_with_unsupported_region_custom_model_no_warning (session_cls , captured_warnings ):
@@ -2282,10 +2261,34 @@ def test_override_default_model_id_uses_the_overriden_value(captured_warnings):
22822261 assert model_id == "custom-overridden-model"
22832262
22842263
2285- def test_no_override_uses_formatted_default_model_id (captured_warnings ):
2264+ def test_default_model_sentinel_triggers_region_prefix_fallback (captured_warnings ):
2265+ """When DEFAULT_BEDROCK_MODEL_ID matches the sentinel template, the region-prefix fallback runs."""
2266+ sentinel = "us.anthropic.claude-sonnet-4-6"
2267+ with unittest .mock .patch ("strands.models.bedrock.DEFAULT_BEDROCK_MODEL_ID" , sentinel ):
2268+ model_id = BedrockModel ._get_default_model_with_warning ("eu-west-1" )
2269+ assert model_id == "eu.anthropic.claude-sonnet-4-6"
2270+
2271+
2272+ def test_caller_supplied_model_id_wins_over_global_default (captured_warnings ):
2273+ """Caller-supplied model_id in config takes precedence over the global default."""
2274+ model_config = {"model_id" : "caller-supplied-model" }
2275+ model_id = BedrockModel ._get_default_model_with_warning ("us-east-1" , model_config )
2276+ assert model_id == "caller-supplied-model"
2277+
2278+
2279+ def test_default_model_sentinel_with_unsupported_region_warns (captured_warnings ):
2280+ """When the sentinel matches and the region is unknown, the region-unsupported warning fires."""
2281+ sentinel = "us.anthropic.claude-sonnet-4-6"
2282+ with unittest .mock .patch ("strands.models.bedrock.DEFAULT_BEDROCK_MODEL_ID" , sentinel ):
2283+ BedrockModel ._get_default_model_with_warning ("ca-central-1" )
2284+ region_warnings = [w for w in captured_warnings if "does not support" in str (w .message )]
2285+ assert len (region_warnings ) == 1
2286+
2287+
2288+ def test_default_model_id_is_global_inference_profile (captured_warnings ):
22862289 model_id = BedrockModel ._get_default_model_with_warning ("us-east-1" )
2287- assert model_id == "us .anthropic.claude-sonnet-4-20250514-v1:0 "
2288- assert model_id != _DEFAULT_BEDROCK_MODEL_ID
2290+ assert model_id == "global .anthropic.claude-sonnet-4-6 "
2291+ assert model_id == DEFAULT_BEDROCK_MODEL_ID
22892292 assert all ("does not support" not in str (w .message ) for w in captured_warnings )
22902293
22912294
0 commit comments