Pre-call LLM spend reservations for autonomous agent runs
Platform engineers running LLM gateways can add a budget decision before every provider request in an agent run. The practical shape is a gateway hook, sidecar, or SDK middleware that estimates worst-case cost from current input tokens, the effective output cap, and a versioned price table, then reserves that amount atomically across scopes such as run, user, and key. After the call, it commits actual usage and releases the unused reserve.
This targets the cost pattern that ordinary monthly or per-key budgets miss: an agent loop that resends accumulated context and can cross 50K input tokens by step 20. The agent also needs machine-readable budget state. Headers and RFC 9457 problem-detail errors can tell the agent when to choose a cheaper model, cut context, or stop cleanly. A useful first test is to replay real agent traces with parallel branches, missing price metadata, and growing context, then measure added latency, blocked calls, and dollars reserved versus dollars spent.