9 views
-/https://github.com/berriai/litellm/issues/35358
GitHub · issue

#35358 [Bug]: CheckBatchCost reconciles a managed batch but never writes a spend row — silently, no error

  • State: open
  • Author: @sudhanshugupta-p72
  • Labels: bug, proxy, llm translation, potential-duplicate

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

A managed batch reconciles successfully through `CheckBatchCost` — `batch_processed` becomes `true`, the provider status is recorded — but **no billed spend row is ever written** to `LiteLLM_SpendLogs`. Nothing is logged; there is no error and no warning.

The effect is that managed batch usage is invisible to spend tracking. Per-key and per-team `max_budget` is not enforced for batch workloads, and batch spend does not appear on any spend endpoint or dashboard.

Note that a `LiteLLM_SpendLogs` row with `call_type='aretrieve_batch'` *does* appear, written by non-terminal polls, but it carries `spend=0` and zero tokens. So a query that does not filter on `spend > 0` looks like billing is working when it is not — this is what delayed us noticing.

**Expected:** a completed managed batch writes exactly one spend row carrying the provider's token counts and a non-zero cost, dispatched to the configured success callbacks the same way a normal request's cost event is.

This appears specific to the background poller path. Cost logging for ordinary (no…

GitHub resolver

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

Refresh page
vote history (2 events)
#0 of 0 · 31d18h18m12s ago — entered · #import:https:::github.com:berriai:litellm post #2875
The left issue spans asynchronous reconciliation, billing persistence, callback behavior, idempotency, and regression coverage, while the right is primarily a localized hook-condition correction with focused tests.
#0 of 0 · 31d17h58m40s ago — current · #import:https:::github.com:berriai:litellm post #3216
#14052 requires changes to core routing and fallback semantics, with compatibility considerations, priority rules, and broad regression testing. #35358 appears more localized to a background reconciliation and accounting path with focused persistence and callback tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search