Repository navigation
fix(router): keep chat and other non-batch calls off Azure batch-only deployments in mixed groups - #53454
Conversation
… 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.
…s, 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.
…ly_deployments_for_chat # Conflicts: # litellm/rust/crates/router-core/src/select.rs
…ly_deployments_for_chat
[Medium impact] The PR appears safe to merge, with no new actionable issues found.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…atch 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
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.
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.
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
…ly 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.
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.
# Conflicts: # litellm/router_rust/core.py
… 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.
|
bugbot run |
| request.pass_through == Some(PassThrough::Listed) && !resolution.kind.is_single(); | ||
| if !resolution.kind.is_single() && !listed { | ||
| all = without_batch_only_deployments(skip_batch_only, all); | ||
| } |
There was a problem hiding this comment.
Pass-through still hits Azure batch-only
Medium Severity
The batch-only drop is skipped for PassThrough::Listed picks, so a sync pass-through chat (or other non-batch) call on a mixed Azure group can still land on the batch-only deployment and get Azure's 400. skips_batch_only is stored on the listed Candidates and the count_only path even filters healthy, but the listed pick itself never removes those deployments.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 73934cc. Configure here.
There was a problem hiding this comment.
A listed pass-through pick can't tell chat from batch or file calls, so it keeps the group as before, and only Vertex routes use it
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
1 issue from previous review remains unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 73934cc. Configure here.


Handwritten 1-3 sentence description
When a model group mixed a normal Azure deployment with an Azure batch-only one, about half the chat calls went to the batch one and got Azure's 400. Now every non-batch call stays on the normal deployments, while batch jobs and file uploads still use the batch one
Details
TLDR
Problem this solves:
How it solves it:
mode: batchdeployments, never other providers' ones, when the group has othersDecisions
mode: batchdeployments are skippedmode: batchdeploymentenforce_supported_endpointswith only/v1/batchon the batch deploymentorderfallback levels skip batch-only levels the same way, so a fallback never goes there eitherUser Flow
Before: about half the chat calls on a group mixing Azure chat and batch-only deployments get a 400
mode: chatand an Azuremode: batchdeployment under one model namex-litellm-model-idAfter: every chat call succeeds, and batch jobs still run on the batch deployment
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Each leg ran two proxies with two workers on real Azure, one shared Redis, no database, alternating requests. In
x-litellm-model-id,e10d08ef...is the chat deployment and4d993f7d...the batch-only one/v1/messagescallsProxy command and env vars
Env vars:
AZURE_FOUNDRY_API_BASE,AZURE_FOUNDRY_API_KEY,LITELLM_MASTER_KEY. Each leg startsredis-server --port <redis port> --save ''then this on two portsProxy and worker PIDs
Each leg printed both proxy PIDs and their two worker PIDs once both proxies answered
Why the command differs from the repo's QA command
--reloadis left out because uvicorn then runs one worker.--detailed_debugis left out to keep the logs short.--use_v2_migration_resolveris left out because the legs run without a database.general_settings.coordination_redisis left out because it carries spend, budget and rate-limit counters this PR does not touch, while router cooldowns go through therouter_settingsRedis both proxies share. The 300 s worker healthcheck lets workers take over a minute to boot on the loaded host, and this PR does not touch worker startupconfig.yaml and batch.jsonl
{"custom_id": "req-1", "method": "POST", "url": "/chat/completions", "body": {"model": "litellm-qa-batch-mix", "messages": [{"role": "user", "content": "Say hi"}], "max_completion_tokens": 20}}config-ctx.yaml
The too-long prompt case ran this config, where
415772d7...is batch-only and46fc47aa...the fallbackconfig-429.yaml
In
x-litellm-model-id,b1188214...is the chat deployment that takes one request a minute,e9310981...its batch-only peer,dd623ba0...the same chat deployment in a group of its own,177fdbf2...the embeddings deployment and1d5fbb63...its batch-only peer.config-ws.yaml
Both groups use the same chat deployment, which sets
supports_web_search: false.litellm-qa-ws-aloneis the control: its answer is what a web search call on the mixed group should get. Inx-litellm-model-id,494911ef...is the batch-only deploymentBefore (c345f50)
Chat completions
Streaming chat completions
Responses API
Anthropic /v1/messages
Batch upload, create and retrieve
Vector store create
Too-long prompt with a context window fallback
Embeddings on a mixed group
Rate-limited chat deployment beside the batch-only one
Rate-limited chat deployment alone
Unsupported web search
After (73934cc)
Chat completions
Streaming chat completions
Responses API
Anthropic /v1/messages
Batch upload, create and retrieve
Vector store create
Too-long prompt with a context window fallback
Embeddings on a mixed group
Rate-limited chat deployment beside the batch-only one
Rate-limited chat deployment alone
Unsupported web search
Router probes for rate-limited batch and file calls (not live)
Azure won't answer 429 on a batch or file call on demand, so these scripts run the router in-process and replay Azure's HTTP answers, with
num_retries0 unless noted andcooldown_time3600. At aac0943 a router test saw 9 of 20 refused batch creates, which this round fixesLive PR risk, base c345f50 against head 73934cc
Each side ran two proxy processes with two workers, one Postgres and one Redis, and a recorder in front of Azure logging every outbound request. Each mixed case has an alone control, the same chat deployment in a group by itself
/v1/messagesx4ordergroup x4, upstream callsrate_limit_errorall_deployments_in_cooldownall_deployments_in_cooldownBreaking. None. Every path where base answered 200 also answers 200 on head
Backward incompatible. None beyond the fix. Where the sides differ, head returns what the chat deployment returns alone, not the batch-only deployment's 400. A batch or file failure on a deployment that is alone for chat writes
deployment:<id>:batch-calls:cooldownin place ofdeployment:<id>:cooldown, so readers of the plain key no longer see itRegression risk. A mixed group's cooldown 429 says
rate_limit_errorbecause the error'smodel_idsstill lists the batch-only id, while the deployment alone saysall_deployments_in_cooldown. Vector store and container calls log a generic call type, so the fallback-hop cooldown with blocked failure callbacks and the public failure callback don't scope them to batch calls. Both are Low caveats belowDependency graph. Verified live on both sides: chat, streaming, Responses,
/v1/messages, embeddings,order, fallbacks, context window fallbacks, token counter, realtime pick, Azure pass-through, web search and Decisions filters, cooldowns from attempts, callbacks and pre-call refusals, health-check routing, allowed-fails safety net, tags, usage-based routing, weighted failover, batch, file, vector store and fine-tuning list calls, keys and spend logsNot verified. Azure won't 429 a batch or file call on demand, so 401s and a pre-call refusal stood in. Realtime past the pick, fine-tuning job create, container file calls, a listed pass-through and the latency, complexity and cache-aware strategies were not driven
Type
🐛 Bug Fix
Caveats (if any)
Low
model_info.modeinformational until a litellm-docs follow-uprate_limit_error, where the chat deployment alone saysall_deployments_in_cooldownFinal Attestation
Bugbot summary