From a224dbb7773a194404d2b4eb395c425a6d6b96bf Mon Sep 17 00:00:00 2001 From: mubashir1osmani Date: Thu, 16 Jul 2026 15:50:11 -0700 Subject: [PATCH] fix(router): score complexity by difficulty not request length The LLM classifier prompt treated short wording as SIMPLE, so probes like "Is P equal to NP?" stayed on the SIMPLE backend even though the classifier ran. Judge intellectual difficulty so short hard questions route higher --- .../complexity_router/complexity_router.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/litellm/router_strategy/complexity_router/complexity_router.py b/litellm/router_strategy/complexity_router/complexity_router.py index e85987870e1..fa6f14e9b26 100644 --- a/litellm/router_strategy/complexity_router/complexity_router.py +++ b/litellm/router_strategy/complexity_router/complexity_router.py @@ -56,11 +56,13 @@ class TierClassification(BaseModel): _CLASSIFICATION_PROMPT_TEMPLATE = """Classify the complexity of the following user request into exactly one tier. +Judge the intellectual difficulty of answering correctly, not how short the request is. + Tiers: -- SIMPLE: factual lookups, greetings, short direct questions with no reasoning or code involved. -- MEDIUM: everyday requests needing some explanation or minor code/technical content. -- COMPLEX: requests involving non-trivial code, architecture, or multi-step technical work. -- REASONING: requests explicitly requiring step-by-step reasoning, analysis, or weighing tradeoffs. +- SIMPLE: greetings, chitchat, or factual lookups with a short known answer. Do not use SIMPLE for unsolved problems, proofs, deep theory, multi-step analysis, or non-trivial code, even if the request is only one sentence. +- MEDIUM: everyday requests that need some explanation, light reasoning, or minor code/technical content. +- COMPLEX: non-trivial code, architecture, multi-step technical work, or specialized domain depth. +- REASONING: open-ended analysis, proofs, famous hard problems, step-by-step reasoning, tradeoffs, or anything where a correct answer requires careful thought rather than a quick lookup. {system_context}Request: {prompt}"""