Repository navigation
Conversation
A provider, deployment, or tag cap of 0 was skipped because the spend check used the dollar amount as a boolean. Compare against None instead, and keep checking deployment and tag caps when a provider entry has no dollar limit. Co-authored-by: abeed09 <abeed09@users.noreply.github.com>
The provider, deployment, and tag checks share one parametrized test, plus the case where an empty provider cap must still honor a deployment cap. Co-authored-by: abeed09 <abeed09@users.noreply.github.com>
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
A hand-built spend map never asks the router which deployment it would send. Route a mocked completion through Router and require the uncapped sibling, with the zero-cap provider weighted so it would win if the filter left it eligible. Co-authored-by: abeed09 <abeed09@users.noreply.github.com>
Each zero-budget case is built once and passed through. The router deployment uses DeploymentTypedDict, the model list entry type. Co-authored-by: abeed09 <abeed09@users.noreply.github.com>
The two helpers return the deployments the filter kept and the debug string. Name that as a sequence of model-list entries. Co-authored-by: abeed09 <abeed09@users.noreply.github.com>
|
The remaining Unit Tests failure is unrelated to this PR: duplicate |
TLDR
Problem this solves:
How it solves it:
Intentional product change: max_budget 0 now blocks spend on that provider, deployment, or tag. A provider budget entry with a time window and no dollar amount no longer removes its deployments
User Flow
Before: an admin who sets a provider budget of zero still sees that provider serve traffic
After: the same budget rejects the request before it is sent
Relevant issues
Fixes #43214
Pre-Submission checklist
uv run pytest tests/test_litellm/<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 more@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Python router,
mock_responseset so an allowed call does not leave the process. A blocked call errors before any provider request, so there is no provider charge. This is the same in-process router path as the issueBefore (1a58162)
Provider already spent $50 against a $0 cap
max_budget=0,budget_duration=1d, and recorded spend50.0routable=Trueanddebug=''Router completion with provider max_budget 0 and no recorded spend
Router.acompletionforopenai/gpt-4withmock_responsesetserved: servedRouter completion with provider max_budget 0.01 and no recorded spend
max_budget=0.01served: servedAfter (6214d5d)
Provider already spent $50 against a $0 cap
routable=Falseanddebug='Exceeded budget for provider openai: 50.0 >= 0.0\n'Router completion with provider max_budget 0 and no recorded spend
Router.acompletionas beforeValueError: No deployments available - crossed budget: Exceeded budget for provider openai: 0.0 >= 0.0Router completion with provider max_budget 0.01 and no recorded spend
max_budget=0.01served: servedDeployment max_budget 0
litellm_params.max_budget=0andbudget_duration=1d, then the same completionValueError: No deployments available - crossed budget: Exceeded budget for deployment model_name: gpt-4, litellm_params.model: openai/gpt-4, model_id: dep-1: 0.0 >= 0.0Mutation: putting the truthy
if config.max_budget and spend >= capcheck back fails 6 of the new cases: provider zero, deployment zero, tag zero, an unset provider cap, and the deployment message that used to print the time windowType
Bug Fix
Caveats
Low
Final Attestation