From fa9cd8fed386d42caf523073d9624c40fdfbce15 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 18:20:54 -0700 Subject: [PATCH] fix(bedrock): treat a region path like the bare id when the cost map does not list it A deployment like bedrock/us-east-1/ now gets the same tools, reasoning_effort and typo 404 as bedrock/, so Claude Code works on it and a mistyped one still answers 404. --- litellm/llms/bedrock/common_utils.py | 4 +++- .../llms/bedrock/chat/test_converse_transformation.py | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/litellm/llms/bedrock/common_utils.py b/litellm/llms/bedrock/common_utils.py index 1e9b3ca2d0a..c744b6eff37 100644 --- a/litellm/llms/bedrock/common_utils.py +++ b/litellm/llms/bedrock/common_utils.py @@ -1600,7 +1600,9 @@ def bedrock_model_supports_regex_lookaround(model: str, litellm_params: Mapping[ def bedrock_model_is_unknown(model: str) -> bool: - model_id: Final = model.removeprefix("bedrock/") + routed_id: Final = model.removeprefix("bedrock/") + region, separator, regional_id = routed_id.partition("/") + model_id: Final = regional_id if separator and region in get_all_bedrock_regions() else routed_id if "/" in model_id: return False base: Final = get_bedrock_base_model(model_id) diff --git a/tests/unit/llms/bedrock/chat/test_converse_transformation.py b/tests/unit/llms/bedrock/chat/test_converse_transformation.py index 5a6f9422362..7d47ca8bcdc 100644 --- a/tests/unit/llms/bedrock/chat/test_converse_transformation.py +++ b/tests/unit/llms/bedrock/chat/test_converse_transformation.py @@ -9292,12 +9292,13 @@ def _invalid_model_identifier_reply(sent: list[httpx.Request]): return respond -def test_not_found_error(): +@pytest.mark.parametrize("model", ["bedrock/bad_model", "bedrock/us-east-1/bad_model"]) +def test_not_found_error(model): sent: Final[list[httpx.Request]] = [] with pytest.raises(litellm.NotFoundError) as exc_info: completion( - model="bedrock/bad_model", + model=model, messages=[{"role": "user", "content": "What is the meaning of life"}], client=HTTPHandler( client=httpx.Client(transport=httpx.MockTransport(_invalid_model_identifier_reply(sent))) @@ -9371,8 +9372,8 @@ def _converse_tool_call_reply(sent: list[httpx.Request]): return respond -def test_model_missing_from_cost_map_sends_tools_to_converse(): - model: Final = "bedrock/us.newvendor.model-1" +@pytest.mark.parametrize("model", ["bedrock/us.newvendor.model-1", "bedrock/us-east-1/us.newvendor.model-1"]) +def test_model_missing_from_cost_map_sends_tools_to_converse(model): assert "us.newvendor.model-1" not in litellm.model_cost sent: Final[list[httpx.Request]] = []