Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(router): reference _model_group_with_consumed_request_tags directly for the router coverage gate

mateo-berri29c13c47d06c
diff --git a/tests/test_litellm/router_strategy/test_router_tag_routing.py b/tests/test_litellm/router_strategy/test_router_tag_routing.py
index f5651e383c5..0e870283015 100644
--- a/tests/test_litellm/router_strategy/test_router_tag_routing.py
+++ b/tests/test_litellm/router_strategy/test_router_tag_routing.py
@@ -2890,6 +2890,24 @@ async def test_router_selecting_tag_is_consumed_on_litellm_metadata_shaped_reque
assert deployment["model_info"]["id"] == "tier-gemini-flash"
+def test_model_group_with_consumed_request_tags_names_the_routed_group_only_on_a_tag_match():
+ from litellm.types.router import PreRoutingHookResponse
+
+ router = _tagged_marker_router()
+ strategy = router.auto_routers["gpt4o"][0]
+ rewrite = PreRoutingHookResponse(model="gemini-flash", messages=None)
+
+ consumed = router._model_group_with_consumed_request_tags(
+ selected_strategy=strategy, pre_routing_hook_response=rewrite, request_tags=["route"]
+ )
+ unmatched = router._model_group_with_consumed_request_tags(
+ selected_strategy=strategy, pre_routing_hook_response=rewrite, request_tags=["other"]
+ )
+
+ assert consumed == "gemini-flash"
+ assert unmatched is None
+
+
@pytest.mark.asyncio()
async def test_tagged_request_direct_to_plain_group_still_rejected():
# Sent straight to the tier, no router selection consumed the tag, so strict