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>
Owner
Author
|
Superseded by the upstream LiteLLM pull request at BerriAI#43277. This fork pull request was closed without merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 BerriAI#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