Genuine question for people running agents in production: if one of your agents got stuck in a retry loop overnight, what actually stops it before morning? Most cost tools I’ve looked at (Langfuse, LangSmith, Portkey, Helicone) are great at showing you what you spent — but that’s a dashboard you read the next day, after the money’s gone. I kept wanting the thing one layer earlier: something that vetoes the call before it hits Anthropic/OpenAI once a budget’s blown. So I built it — a circuit breaker with budgets scoped globally, per-provider, per-agent, or per-session, on either dollar cost or call count. Provider-agnostic adapter pattern, spend ledger, forecasting dashboard. Curious what everyone else is doing here — rolling your own caps? Trusting provider-side limits? Just eating the occasional surprise bill? What’s worked? (Happy to share what I built if it’s useful — don’t want to turn this into an ad, so just say the word.)
The check-then-veto step has a race in it: ten retries in flight can all pass the budget check before any of them lands in the ledger, so the cap leaks exactly in the loop it is built for. Make the pre-call step a reservation instead — atomically hold the call’s worst-case cost (max tokens at the model’s price) against the budget before it fires, then settle to the actual cost or release it on failure — and fail closed when the ledger itself is unreachable. Test it by firing 50 parallel calls at a nearly-exhausted budget: a hard cap lets through only the ones the remaining budget can fully reserve.