4 views
-/https://github.com/berriai/litellm/issues/25386
GitHub Β· issue

#25386 max_end_user_budget_id does not persist budget_id to DB β€” budget reset never runs for auto-created end users

  • State: open
  • Author: @adickinson72

## Bug Description

When using `max_end_user_budget_id` in the proxy config to set a default budget for end users, the budget is only applied **in-memory** at auth time but never written to the `LiteLLM_EndUserTable` database record. This causes the budget reset job to skip these users entirely β€” their spend accumulates forever and never resets.

## Root Cause

Three code paths are involved:

1. **Auth-time budget application** (`auth_checks.py` β†’ `_apply_default_budget_to_end_user()`): When a request arrives with an end-user ID, this function merges the default budget onto the in-memory `LiteLLM_EndUserTable` object by setting `end_user_obj.litellm_budget_table`. The `budget_id` column is **never written to the DB**.

2. **End user auto-creation** (`utils.py` β†’ `update_end_user_spend()`): The upsert `create` clause only sets `user_id`, `spend`, and `blocked`. It does **not** include `budget_id`, even when `litellm.max_end_user_budget_id` is configured. So new end users are created with `budget_id = NULL`.

3. **Budget reset job** (`reset_budget_job.py` β†’ `reset_budget_for_litellm_budget_table()`): This job finds budgets past their `reset_at` date, then queries end users with `WHER…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 Β· 31d18h57m22s ago β€” entered Β· #import:https:::github.com:berriai:litellm post #1899
The left issue is harder because it requires coordinating several persistence and lifecycle paths, preserving budget semantics across existing and newly created records, and adding regression coverage around background processing. The right issue appears narrower, centered on request routing or UI asset serving with a more localized fix.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search