The short version
- Run the agent under watch and record what a normal run costs.
- Set a stop limit at a multiple of normal, and a warning below it.
- Give each agent or client its own key, so a limit lands on one of them and not all of them.
- Put a monthly ceiling over everything as the last line of defense.
- Check before each call, and refuse the call if the check itself can't run.
Measure before you choose a number
A budget picked from thin air is either so tight it interrupts real work, in which case people turn it off, or so loose it stops nothing. A few days of real runs gives you what you need: the cost of a typical run, the cost of an expensive but legitimate run, and how many runs happen in a day.
Look at the spread as well as the average. An agent that usually costs ten cents a run and occasionally costs two dollars has a different safe limit from one that always costs fifty cents. Set the limit above your expensive legitimate run, not above your average.
Choose the limit and the warning
Work out the daily stop as runs per day, times the cost of an expensive run, with some headroom. If an agent does 40 runs a day and a heavy run costs $0.50, a day of all heavy runs is $20, so a $25 daily stop leaves room for a busy day and still catches a loop within hours.
Then set a warning. 80% is a common default, and the reason to have one is time: it gives a person the chance to look before work stops. A warning alone isn't a limit, as spend alerts vs hard limits explains.
Choose the window to match the risk. A monthly limit answers "what will this cost me?". A daily limit answers "how much can go wrong overnight?", because a loop can use a whole month's allowance in one night. Most agents want both.
Layer limits so one failure stays small
Provider limits generally apply to a whole organization or project. That matters because when an organization limit trips, everything stops, including the agents that were behaving. Separate limits let the broken agent stop alone.
| Level | What it protects against |
|---|---|
| Each agent or workflow | One agent looping. This is the limit that fires most often. |
| Each key | One app or client spending past what you agreed. |
| Each person or team | One person's work crowding out everyone else's. |
| Everything | All of the above failing at once. Set this high, and treat it as the last line. |
Decide what happens at the limit
Plan this before it happens. A stopped call needs to reach the agent as a clear refusal it can't mistake for a temporary fault, or it will retry. The agent should end its run and report that the budget was reached, and a person should find out.
Also decide what happens when the check can't run at all, say because the service holding the budget is down. A limit that lets calls through whenever it's unavailable is off at the moment you can least see what's happening. For anything that can spend without a person watching, the check should fail closed: no answer means no call.
Count everything that costs money
- Retries, which repeat the whole request.
- Sub-agents and tool calls that make their own model calls.
- Summarizing and compaction steps that frameworks add quietly.
- Embeddings, which are cheap per call and easy to run at high volume.
Review the limits
Agents change. A new tool or a longer prompt moves the cost of every run. Look at limits when you change an agent, and any time one fires, ask whether it caught a fault or whether real usage has outgrown it. Raising a limit should take a deliberate second step, because it's the one change that lets more money go out.
Spend is in early access: you can set budgets and see what each call cost today, and budgets that stop calls are being switched on across the platform. See how Spend handles budgets.
Questions
- How much should I budget for an AI agent?
- Measure it first. Run the agent for a few days, find the cost of an expensive legitimate run, multiply by runs per day, and add headroom. That gives you a daily stop that allows real work and still catches a loop.
- Should an AI agent have a daily or a monthly budget?
- Usually both. A monthly budget controls the overall bill. A daily budget limits how much can go wrong overnight, since a loop can use a month's allowance in one night.
- What should an agent do when it reaches its budget?
- End the run and report it. The refusal has to be clear enough that the agent doesn't treat it as a temporary fault and retry, and a person should be told.