litellm/tests/test_litellm/router_strategy/adaptive_router
Krrish Dholakia 26ab730bfa
feat(router): soft-floor adaptive mode for complexity router (#32947)
* feat(router): soft-floor adaptive mode for complexity router

Let complexity_router_config.adaptive=true Thompson-sample across the
union of tier pools with a tier-distance penalty, and wire the existing
adaptive post-call bandit so mis-tiered requests can still recover.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(router): reattach adaptive hooks for hybrid complexity

Finalize was wiping every AdaptiveRouterPostCallHook and only
re-registering standalone auto_router/adaptive_router deployments,
so complexity adaptive=true never received bandit updates.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore(router): drop unnecessary hybrid docstrings

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(router): attribute adaptive feedback

Credit user reactions to the model that produced the previous response while keeping current-response signals on the serving model

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(router): tune hybrid cold defaults

Use the cost-weighted policy that beat equal-pool complexity in the full bakeoff, and make the committed harness compare identical tier pools

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(router): preserve hybrid cold quality floor

Sample only unobserved models in the classified tier until feedback exists, then apply adaptive scoring without mis-penalizing models shared across tiers

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(router): bound feedback context cache

Cap retained session feedback so unique session IDs cannot exhaust router memory

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(router): preserve exhaustion signals

Include tool-result exhaustion in adaptive feedback and clear strict lint regressions blocking CI

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor(router): remove stale owner cache

Remove obsolete attribution state, tighten the embedded router type, and keep the test diff focused on adaptive behavior

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor(router): centralize hook cleanup

Use the callback manager to discover and remove adaptive hooks across every registered callback list

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 21:56:33 -07:00
..
fixtures
__init__.py
test_adaptive_router.py feat(router): soft-floor adaptive mode for complexity router (#32947) 2026-07-11 21:56:33 -07:00
test_async_pre_routing.py fix(adaptive_router): 3 P1 review defects 2026-04-20 15:22:18 -07:00
test_bandit.py
test_classifier.py
test_config.py
test_e2e_adaptive_router.py feat(router): soft-floor adaptive mode for complexity router (#32947) 2026-07-11 21:56:33 -07:00
test_hooks.py feat(router): soft-floor adaptive mode for complexity router (#32947) 2026-07-11 21:56:33 -07:00
test_router_dispatch.py fix(adaptive_router): P1 flusher hot-reload + P2 hook accumulation + CI 2026-04-21 17:49:38 -07:00
test_signals.py fix(adaptive_router): enforce satisfaction gate, stop false-flagging empty tool output 2026-04-20 17:47:25 -07:00
test_state_endpoint.py feat(router): soft-floor adaptive mode for complexity router (#32947) 2026-07-11 21:56:33 -07:00
test_update_queue.py refactor(adaptive_router): move update_queue out of litellm.proxy 2026-04-21 18:02:44 -07:00