fix(budgets): prevent per-user allowance renewal on sync - #205
Merged
Conversation
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Renumber the personal organization budget cleanup migration to follow the current revision 147 head and update its regression-test import. Co-authored-by: openhands <openhands@all-hands.dev>
Persist each governed member's cumulative LiteLLM spend at cycle start and derive their absolute cap from that stable baseline instead of current spend on every sync. Co-authored-by: openhands <openhands@all-hands.dev>
|
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
Resolve merge conflict in enterprise/tests/unit/test_org_budget_service.py by combining both branches' new tests: - main's test_sync_litellm_budgets_skips_passive_disabled_team_org (from #167) - this PR's test_sync_litellm_budgets_keeps_member_cap_stable_across_sessions Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
Merge conflict resolvedResolved the conflict in The resolution keeps both tests:
Verified locally:
This comment was posted by an AI agent (OpenHands) on behalf of Saurya Velagapudi. |
tofarr
approved these changes
Aug 20, 2026
|
🚀 Released in 1.55.0. |
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.
Summary
max_budget_in_teamfrom the persisted baseline plus the effective monthly allowance instead of current spend plus allowance on every synchronizationIncident context
This fixes the per-user sliding-cap issue identified during the Fujitsu budget incident. LiteLLM compares cumulative membership spend to an absolute
max_budget_in_team; recalculating that cap from current spend every 15 minutes effectively renewed the member's full allowance on every maintenance run.After this change, a member observed at
$7cumulative spend with a$50allowance receives an absolute cap of$57. A later sync at$23spend keeps the cap at$57rather than moving it to$73.Stack
Rollout behavior
Existing deployments do not retain historical per-member cycle-start LiteLLM spend. Therefore the first successful synchronization after this migration bootstraps each current member's baseline from their current cumulative membership spend. This can grant one fresh configured allowance at rollout, but subsequent 15-minute synchronizations remain anchored and cannot renew it again. New members and newly capped members are similarly anchored when first governed during a cycle.
Validation
216 passedacross affected billing, LiteLLM, organization-budget, and organization-service unit suites15 passedin focused organization-budget service testspg8000andpsycopg2This pull request was created by an AI agent (OpenHands) on behalf of Saurya Velagapudi.
Enterprise server image for this PR: