From a5f1460d1bfbdda2783ce3017fec5990d1912d35 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Sat, 21 Feb 2026 13:09:13 -0800 Subject: [PATCH] fix(complexity_router): align .get() fallbacks with config.py defaults, document system prompt scoring --- .../complexity_router/complexity_router.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/litellm/router_strategy/complexity_router/complexity_router.py b/litellm/router_strategy/complexity_router/complexity_router.py index ec51a263831..c4e0c55adc8 100644 --- a/litellm/router_strategy/complexity_router/complexity_router.py +++ b/litellm/router_strategy/complexity_router/complexity_router.py @@ -115,8 +115,8 @@ class ComplexityRouter(CustomLogger): def _score_token_count(self, estimated_tokens: int) -> DimensionScore: """Score based on token count.""" thresholds = self.config.token_thresholds - simple_threshold = thresholds.get("simple", 50) - complex_threshold = thresholds.get("complex", 500) + simple_threshold = thresholds.get("simple", 15) + complex_threshold = thresholds.get("complex", 400) if estimated_tokens < simple_threshold: return DimensionScore( @@ -221,7 +221,11 @@ class ComplexityRouter(CustomLogger): - score: The raw weighted score - signals: List of triggered signals for debugging """ - # Combine text for analysis + # Combine text for analysis. + # System prompt is intentionally included in code/technical/simple scoring + # because it provides deployment-level context (e.g., "You are a Python assistant" + # signals that code-capable models are appropriate). Reasoning markers use + # user_text only to prevent system prompts from forcing REASONING tier. full_text = f"{system_prompt or ''} {prompt}".lower() user_text = prompt.lower() @@ -273,9 +277,9 @@ class ComplexityRouter(CustomLogger): # Map score to tier boundaries = self.config.tier_boundaries - simple_medium = boundaries.get("simple_medium", 0.25) - medium_complex = boundaries.get("medium_complex", 0.50) - complex_reasoning = boundaries.get("complex_reasoning", 0.75) + simple_medium = boundaries.get("simple_medium", 0.15) + medium_complex = boundaries.get("medium_complex", 0.35) + complex_reasoning = boundaries.get("complex_reasoning", 0.60) if weighted_score < simple_medium: tier = ComplexityTier.SIMPLE