fix(proxy): use >= in _team_max_budget_check to match other budget checks - #28051
fix(proxy): use >= in _team_max_budget_check to match other budget checks#28051msxfXF wants to merge 6 commits into
Conversation
Squash-merged by litellm-agent from FabrizioCafolla's PR.
…erriAI#27927) Squash-merged by litellm-agent from Cyberfilo's PR.
Squash-merged by litellm-agent from tomdee's PR.
Squash-merged by litellm-agent from escon1004's PR.
Greptile SummaryThis PR fixes a one-character operator inconsistency in
Confidence Score: 5/5Safe to merge — the change is a minimal, well-targeted operator correction that aligns team budget enforcement with every other budget check in the file. The fix is isolated to a single comparison in No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/auth/auth_checks.py | Single-character operator fix: > changed to >= in _team_max_budget_check, bringing team budget enforcement in line with key, org, and window checks |
| tests/test_litellm/proxy/auth/test_auth_checks.py | New regression test test_team_budget_check_raises_when_spend_equals_max_budget added; uses mocks only, mirrors existing test pattern, correctly asserts BudgetExceededError when spend equals max_budget |
Reviews (2): Last reviewed commit: "fix(proxy): use >= in _team_max_budget_c..." | Re-trigger Greptile
Merging this PR will not alter performance
Comparing |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
🤖 litellm-agent: This PR is currently BLOCKED from merge. Score: 0/5 ❌ Why blocked:
Details: Score docked for: karpathy needs_human — The PR diff targets the context line Fix the issues above and push an update — the bot will re-review automatically.
|
8a25348 to
d278f59
Compare
|
Thanks for the reviews. Pushed an updated version:
Final one-line diff: - if math.isfinite(team_object.max_budget) and spend > team_object.max_budget:
+ if math.isfinite(team_object.max_budget) and spend >= team_object.max_budget:Regarding the Note: I have not signed the CLA yet — will do that. |
|
@greptileai Could you re-run on the rebased commit ( |
|
🤖 litellm-agent: Auto-merge skipped — the staging branch Please rebase your branch onto |
…conversations (BerriAI#28080) Squash-merged by litellm-agent from Divyansh8321's PR.
…ecks Fixes BerriAI#28020 _team_max_budget_check used `>` while every other budget enforcement path (key, organization, budget windows) uses `>=`. A team whose spend hit exactly `max_budget` was still allowed through. Change `>` to `>=` and add a regression test that asserts BudgetExceededError is raised when spend == max_budget. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
d278f59 to
4406bb3
Compare
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Relevant issues
Fixes #28020
Pre-Submission checklist
tests/test_litellm/directory — addedtest_team_budget_check_raises_when_spend_equals_max_budgetintests/test_litellm/proxy/auth/test_auth_checks.pymake test-unit(could not run the full suite locally; the new test follows the same pattern as the existingtest_team_budget_check_reads_from_spend_counterdirectly above it)Type
🐛 Bug Fix
Changes
_team_max_budget_checkused>while every other budget enforcement path in the same file uses>=:_virtual_key_max_budget_check(key)>=>=_team_max_budget_check(team)>← bug>=_organization_max_budget_check(org)>=A team whose spend equals exactly
max_budgetwas therefore still allowed through, e.g.10.0 > 10.0is False. This is inconsistent with key/org/window enforcement and contradicts the natural meaning of "max budget".Diff
Test
Added
test_team_budget_check_raises_when_spend_equals_max_budgetthat constructs a team withmax_budget=10.0, mocksget_current_spendto return exactly10.0, and assertsBudgetExceededErroris raised withcurrent_cost == 10.0andmax_budget == 10.0. Mirrors the existingtest_team_budget_check_reads_from_spend_countertest pattern.Scope note
This PR intentionally does not touch the other
>-using sites (global_proxy_spend > litellm.max_budgetat line 331,project_object.spend > max_budgetat line 3815) — those are separate decisions and out of scope for #28020.Disclosure: this PR was prepared with assistance from Claude (Anthropic). The bug location and proposed fix were both pre-specified in the linked issue; I verified the surrounding code matches the issue's description and added the regression test.