diff --git a/litellm/router_strategy/complexity_router/complexity_router.py b/litellm/router_strategy/complexity_router/complexity_router.py index d6f67120cef..ccded64c3a5 100644 --- a/litellm/router_strategy/complexity_router/complexity_router.py +++ b/litellm/router_strategy/complexity_router/complexity_router.py @@ -1156,18 +1156,12 @@ class ComplexityRouter(CustomLogger): def _pick_from_tier_value( model: str | list[str] | TierTarget, tier_key: str ) -> str: # mutable-ok: legacy pool inputs remain lists - if isinstance(model, TierTarget): - target_model: Final = model.model - if isinstance(target_model, str): - return target_model - if not target_model: - raise ValueError(f"Empty model pool for tier {tier_key}") - return random.choice(target_model) if isinstance(model, str): return model - if not model: + pool: Final = tier_pool(model) + if not pool: raise ValueError(f"Empty model pool for tier {tier_key}") - return random.choice(model) + return random.choice(pool) def _tier_pools(self) -> dict[str, list[str]]: # mutable-ok: adaptive router consumes mutable pools return { # mutable-ok: router consumers require mutable tier pool mappings diff --git a/tests/test_litellm/router_strategy/test_complexity_router.py b/tests/test_litellm/router_strategy/test_complexity_router.py index b37c574b5b0..7cb402969ab 100644 --- a/tests/test_litellm/router_strategy/test_complexity_router.py +++ b/tests/test_litellm/router_strategy/test_complexity_router.py @@ -913,7 +913,10 @@ class TestSingletonMutation: def test_default_config_not_mutated(self, mock_router_instance): """Test that creating routers without config doesn't mutate defaults.""" - from litellm.router_strategy.complexity_router.config import ComplexityRouterConfig + from litellm.router_strategy.complexity_router.config import ( + DEFAULT_CLASSIFIER_CONTEXT_WINDOW_SIZE, + ComplexityRouterConfig, + ) # Get original default original_default = ComplexityRouterConfig().default_model