{"record":{"id":"faa993742428471d","repo":"BerriAI/litellm","slug":"cannot-resize-budget-reservation-against-inconsist","errorCode":null,"errorMessage":"Cannot resize budget reservation against inconsistent counter {counter_key}","messagePattern":"Cannot resize budget reservation against inconsistent counter (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/spend_tracking/budget_reservation.py","lineNumber":791,"sourceCode":"    ):\n        await _increment_spend_counter_cache(\n            counter_key=counter_key,\n            increment=adjustment,\n        )\n    elif reseed_on_inconsistent:\n        # Post-call reconcile / release: the counter was flushed or reseeded\n        # between reservation and reconcile (Redis restart / cross-pod reset),\n        # so the optimistic delta no longer applies. Recover by reseeding from\n        # the DB's lagging authoritative floor rather than deleting the counter\n        # and failing open — deleting it is what left budgets unenforced after a\n        # Redis reload.\n        await reseed_spend_counter_from_db(counter_key=counter_key)\n    else:\n        # Pre-call admission resize: the in-flight reservation cost is not yet\n        # persisted, so the DB floor would discard it. Keep the original\n        # fail-closed behavior (raise -> reserve_budget_for_request releases and\n        # denies) rather than admitting against an inconsistent counter.\n        raise RuntimeError(f\"Cannot resize budget reservation against inconsistent counter {counter_key}\")\n    entry[\"applied_adjustment\"] = target_adjustment\n\n\nasync def _counter_can_apply_adjustment(\n    counter_key: str,\n    adjustment: float,\n) -> bool:\n    from litellm.proxy.proxy_server import spend_counter_cache\n\n    current_value: Final = await spend_counter_cache.async_get_cache(key=counter_key)\n    if current_value is None:\n        return False\n\n    try:\n        current_float: Final = float(current_value)\n    except (TypeError, ValueError):\n        return False\n","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/spend_tracking/budget_reservation.py#L773-L809","documentation":"Error \"Cannot resize budget reservation against inconsistent counter {counter_key}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/spend_tracking/budget_reservation.py:791 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reset or repair the inconsistent spend counter (clear the Redis key or reconcile the DB counter), then retry the reservation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}