fix(simple_shuffle): honor weights when first deployment has none#33539
fix(simple_shuffle): honor weights when first deployment has none#33539devin-ai-integration[bot] wants to merge 1 commit into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThis PR fixes a bug in
Confidence Score: 5/5Safe to merge — the change is minimal, targeted, and well-tested. The three-line logic change correctly expands the weighted-routing check from a single deployment to all deployments, and the existing No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/router_strategy/simple_shuffle.py | Fixes weighted-routing detection to inspect all deployments instead of only the first; missing weights are now treated as 0 rather than disabling weighting entirely. |
| tests/test_litellm/router_strategy/test_simple_shuffle.py | New regression test using only mocks (no real network calls); deterministically validates that a zero-weight deployment is never picked and that the higher-weight deployment dominates. |
Reviews (1): Last reviewed commit: "fix(simple_shuffle): honor weights when ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Relevant issues
Fixes #33329
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Config with two deployments in one model group where the first declares no
weightand the second hasweight: 99Sending 40 live
/v1/chat/completionsrequests and counting the picked deployment via thex-litellm-model-idresponse headerBefore the fix (commit
69a491e168); weights ignored, roughly uniform splitAfter the fix (commit
f77948b762); theweight: 99deployment is honored (the unset weight is treated as 0)Type
🐛 Bug Fix
Changes
simple_shuffledecided whether weighted routing was enabled by inspecting only the first healthy deploymentso when the first deployment in a group had no
weight/rpm/tpmfor the metric, the metric was skipped entirely and every other deployment's weight was silently ignored, falling through to a uniform random pick. Deployment ordering is not something the user controls, so this made weighted routing unreliableThe check now enables the weighted pick when any deployment declares the metric, and a missing value is treated as 0 for that deployment
Added
tests/test_litellm/router_strategy/test_simple_shuffle.pywith a regression test that puts a deployment without a weight first, followed by weighted deployments, and asserts the zero-weight one is never picked while the higher-weight one dominatesFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/23a58e873a094267bfbd2b3e2496eaf7