litellm/tests/test_litellm/router_strategy
tin-berri 2dbcb9a999
feat(spend-logs): record when a spend log row is the auto-router's own classifier call (#35300)
The complexity router's classifier sub-call copies the parent request's metadata
verbatim, so its spend log row carries the caller's key, team and user and is
indistinguishable from traffic the caller actually sent. Nothing on the row says
otherwise: call_type is "acompletion" either way, model_group is overwritten to the
classifier's own model group so the row never looks auto-routed, and routing_decision
is absent exactly as it is on an ordinary request.

Record the fact the system already knows at call time. internal_call_origin is
declared on SpendLogsMetadata, which is the allowlist _get_spend_logs_metadata
projects onto, and stamped in _classifier_call_metadata; both classifier paths
already route through that one function and it feeds the metadata and
litellm_metadata buckets alike, so every request surface is covered at one site.
The key is reserved rather than caller-supplied, so it joins routing_decision in the
untrusted-metadata strip and a caller cannot label their own traffic as router
overhead.

The classifier call also inherited no session identity, so the router minted a fresh
trace id and the row landed in a session of its own. Forwarding the parent's session
puts it in the trace of the request that triggered it, which is where an operator
looks for what the routing cost.
2026-07-30 19:26:42 -07:00
..
adaptive_router feat(router): record why the auto-router picked a tier and show it in the logs (#35016) 2026-07-30 11:55:10 -07:00
test_auto_router.py Litellm krrish staging 04 20 2026 (#26138) 2026-04-20 16:22:12 -07:00
test_base_routing_strategy.py [Fix] Fix test failures and Docker build from pinned dependency upgrade 2026-04-01 09:43:33 -07:00
test_budget_limiter_hotpath.py fix(router): enforce deployment budgets for dynamically added models (#29273) 2026-05-29 19:43:14 -07:00
test_complexity_router.py feat(spend-logs): record when a spend log row is the auto-router's own classifier call (#35300) 2026-07-30 19:26:42 -07:00
test_lar1_routing.py chore: litellm oss staging (#31185) 2026-06-26 09:17:44 -07:00
test_lowest_latency.py test(router_strategy): cover chat-path normalization branches in both handlers 2026-07-23 08:36:48 +10:00
test_quality_router.py feat(router): record why the auto-router picked a tier and show it in the logs (#35016) 2026-07-30 11:55:10 -07:00
test_router_routing_groups.py fix(router): honor per-request routing_strategy from key/team router_settings (#33429) 2026-07-16 13:36:03 -07:00
test_router_routing_plugins.py feat(router): resolve auto-router routing plugins from proxy YAML config (#33251) 2026-07-14 21:27:14 -07:00
test_router_tag_regex_routing.py Litellm ishaan march30 (#24887) (#25151) 2026-04-04 14:44:07 -07:00
test_router_tag_routing.py fix(router): apply team/key enable_tag_filtering to tag routing (#33436) 2026-07-16 14:41:24 -07:00