litellm/tests/unit/test_router
drewv19 d8df91af89
fix(router): keep chat and other non-batch calls off Azure batch-only deployments in mixed groups (#53454)
* fix(router): keep chat and other non-batch calls off Azure batch-only deployments in mixed groups

A model group that mixes an Azure chat deployment with an Azure mode: batch deployment load balanced chat, responses and every other non-batch call onto the batch-only deployment, which Azure answers with 400. Selection now skips Azure and azure_ai mode: batch deployments for any call outside the batch and file APIs while the group has another deployment, in the healthy set, the retry count and the order walk. Batch creates, retrieves, cancels and file calls still pick them, and a group of only batch deployments is unchanged.

* fix(router): count only routable deployments for retries and cooldowns, keep fine-tuning on batch deployments

A chat call on a group with one chat deployment and an Azure batch-only one
counted both, so one 429 cooled down the lone chat deployment and skipped
its retry. Retries and cooldowns now count only the deployments the call
can use, and fine-tuning job calls keep the batch deployment like the other
batch and file calls.

* fix(router): keep pinned, vector store and container calls on Azure batch deployments

A call pinned to a batch-only deployment keeps it. Vector store and container calls count as resource-scoped calls the batch deployment also takes, like file and fine-tuning calls

Team and routing-group cooldown counts, host failure reports and the mock rate-limit path now count only the deployments the call can use, so a lone chat deployment beside a batch-only one keeps single-deployment rules everywhere

* fix(router): skip Azure batch-only deployments before pre-call checks

A too-long prompt on a mixed group now takes its context window fallback
instead of a "no deployments" 429. Pre-call rate-limit refusals report
whether the call is a batch API call, so a chat deployment's cooldown
counts its batch peer only for calls that peer serves. Adds a direct
test of is_batch_api_call_type for the router coverage check.

* fix(router): never cool a chat deployment because of a batch-only peer

A cooldown now counts only the deployments that could take every call the
failing deployment serves, whatever call failed. A batch-only Azure
deployment never stands in for a chat one, so a rate-limited file or batch
call no longer cools the lone chat deployment and leaves chat with no
deployment. Failure reports drop the batch_api flag, which no longer
reaches the decision.

* fix(router): cool a deployment for batch calls only when its batch-only peer can take them

A 429 on a batch or file call against a deployment that is alone for chat
but has an Azure batch-only peer now cools it under a separate key that
only batch and file calls read. Chat keeps its only deployment, while batch
and file calls move to the peer instead of hitting the rate-limited one
again. Failure reports carry the batch_api flag again so host reports and
pre-call refusals make the same decision as the call loop.

* fix(router): decide the batch-only skip before capability filters

A web search call the chat deployment cannot take used to leave only the
batch-only deployment, so it got Azure's 400. The skip is now decided on
the whole group first, so the call gets the same answer as the chat
deployment alone. Also marks three call loop tests with rstest and runs
cargo fmt.

* fix(router): treat the batch-only deployment as absent for every chat filter

Drop Azure batch-only deployments right where the skip is decided, so the
health check filter, the allowed-fails safety net, route fallback and the
pre-call, tag and usage pools see the group as if the chat deployment were
alone. Weighted failover no longer counts a batch-only deployment as one
left to try for a chat call, and a batch create refused by a pre-call check
counts as a batch call, so its cooldown stays scoped to batch and file calls.

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-23 01:59:52 +00:00
..
core test(router): seed the io token counter for both minutes a usage read can land in (#53518) 2026-11-22 02:54:44 +00:00
__init__.py test: add __init__.py to every tests/unit directory phase 16 touches 2026-09-20 11:52:38 +00:00
test_enforce_model_rate_limits.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_io_token_rate_limits.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_router.py fix(router): keep chat and other non-batch calls off Azure batch-only deployments in mixed groups (#53454) 2026-11-23 01:59:52 +00:00
test_router_callback_hook_sequence.py test: replace 61 live logging and otel tests with offline unit and integration coverage (#45362) 2026-10-08 15:55:57 -07:00
test_router_endpoints.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_entry_points.py feat(proxy): mixed Codex model picker and LiteLLM routing on native codex routes (#49408) 2026-11-06 11:14:47 -08:00
test_router_facade.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_fallbacks.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_fuzz_regressions_rust_only.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_router_get_deployments.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_helper_utils.py fix(bedrock): send native chat and Responses calls to aws_bedrock_runtime_endpoint like Converse (#50582) 2026-11-19 16:40:23 -08:00
test_router_host.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_router_max_parallel_requests.py feat(tts)!: stream audio from the provider as it arrives on /v1/audio/speech (#46222) 2026-11-17 15:03:12 +00:00
test_router_provider_endpoints.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_router_retries.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_surface_check.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_router_timeout.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
test_router_vector_store_endpoints.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00