litellm/tests/test_litellm/router_strategy
Krrish Dholakia 397c84678b
feat(router): opt-in session affinity for complexity router (#33126)
* feat(router): opt-in session affinity for complexity router

Complexity router reclassified every turn, which could flip the routed
model group mid-session and break provider-side prompt caching. Add a
session_affinity config flag: when a session_id is resolvable, pin the
model chosen on the first turn and reuse it for the rest of the session,
skipping reclassification. Pinned turns still stamp the adaptive
bandit's chosen-model metadata so reward feedback keeps working when
adaptive=True.

* fix(router): refresh session-affinity TTL on hit, scope pin by API key

Two issues from review: the TTL was only set on the first classification,
so an active session outliving session_affinity_ttl_seconds silently lost
its pin instead of refreshing as documented. And the cache key was scoped
only by session_id, which is client-supplied and unauthenticated, so two
different callers reusing the same session_id could poison each other's
routing pin. Refresh the TTL on every cache hit, and namespace the cache
key by the proxy-derived API key hash when available.
2026-07-13 18:28:13 -07:00
..
adaptive_router feat(router): soft-floor adaptive mode for complexity router (#32947) 2026-07-11 21:56:33 -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(router): opt-in session affinity for complexity router (#33126) 2026-07-13 18:28:13 -07:00
test_lar1_routing.py chore: litellm oss staging (#31185) 2026-06-26 09:17:44 -07:00
test_quality_router.py Litellm krrish staging 04 20 2026 (#26138) 2026-04-20 16:22:12 -07:00
test_router_routing_groups.py feat: selectively apply routing strategy according to model name 2026-05-04 13:27:32 -07:00
test_router_routing_plugins.py feat(router): add Router(plugins=[...]) routing-plugin pipeline (#32972) 2026-07-11 21:38:18 -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 feat(router): tag routing denylist support via ! prefix (#31728) 2026-06-30 11:00:30 -07:00