Pattern 35 · Cost & limits

Agent budget & run limits

An agent stuck in a loop spends money and time faster than anyone notices, and the first signal is the invoice.

By Alex StepikinUpdated December 20264 min readLive demo
In short

Let users set separate caps for spend, steps and time, show live meters, warn at about 80%, and pause before the step that would exceed a cap. At the limit, show what is done and what is left, with three choices: raise the cap and resume, finish with what exists, or stop. Never overshoot and never discard the partial result.

Live demo · try it

An interactive mock built in plain HTML, CSS and JavaScript. Data is fictional; no model is called.

FitWhen to use it — and when not

Use it when

  • Agents that loop, browse or call paid tools for an unknown number of steps
  • Scheduled and background runs that nobody is watching
  • Team workspaces where one person’s agent spends a shared budget

Skip it when

  • Fixed-cost tasks with a known single model call
  • Products that already bill per task at a quoted price: show the price instead
  • Where a hard cutoff would leave data half-written and there is no safe stopping point

AnatomyThe parts of the pattern

  1. Limit setSpend, steps and time as separate caps, each with a sensible default and a visible value.
  2. Live metersUsed against each cap during the run, in the units people set them in.
  3. Soft warningA notice at about 80%, before anything stops.
  4. Hard stopThe agent pauses before the step that would exceed the cap. It never overshoots.
  5. Limit cardWhat is done, what is left, and the choices: raise the cap, finish with what exists, or stop.
  6. Scope levelsPer run, per day and per workspace, with the lowest one winning.

GuidelinesDo & don’t

Do

  • Pause at the limit instead of killing the run, and keep the partial result.
  • Show what the next increment buys: "Raising the cap by $2 covers about 8 more steps."
  • Default new agents to a low cap and let people raise it.
  • Count tool and sub-agent costs, not only model tokens.

Don’t

  • Fail silently and leave a half-finished result with no explanation.
  • Reset the run on a raised limit; resume from where it stopped.
  • Use only a monthly workspace cap: one run can burn it overnight.
  • Phrase the stop as an error. Hitting a limit you set is the feature working.

In the wildReal-world examples

OpenAI (project budgets and usage limits)Anthropic Console (spend limits)Cursor (usage and spend limits)AWS BudgetsClaude Code (--max-turns)

Products named for reference only — no affiliation, and the demo above is an original illustration, not a copy of their UI.

For engineersImplementation notes

  • Check the cap before each step with a projected cost for that step, not after it, so the stop is clean.
  • Keep a per-run ledger of cost, steps and elapsed time as the source for the meters and the limit card.
  • Make a stopped run resumable: persist state and the remaining plan, so raising a cap continues instead of restarting.
  • Enforce caps on the server. A client-side limit is a suggestion.

Q&ACommon questions

What should an AI agent do when it hits a budget limit?

Pause before the step that would exceed the cap, keep the partial result, and ask. Offer to raise the limit and resume, wrap up with what it has, or stop. Failing silently or restarting loses work and trust.

Which limits should an agent have?

Spend, number of steps and elapsed time, each separate, because different failures hit different ones. A loop trips steps, a slow tool trips time and an expensive model trips spend. Add per-run, per-day and per-workspace levels, with the lowest winning.

Should budget limits be enforced in the UI or on the server?

On the server. The client shows the meters and the limit card, but a cap that only the browser checks can be bypassed by a scheduled run or an API call.

See alsoRelated patterns

All 40 LLM UX patterns

Does this pattern work in your product?

The AI Trust Audit checks how your product handles this pattern and the other moments where people decide whether to trust the AI. You get 10+ fixes ranked by impact and effort, and your key flow redesigned. 5 working days, $990, credited to a build if we continue. Related case: Atlas, a control room for a fleet of AI agents.

Get the audit · $990Ask a question first

Create bold.
Deliver better.

See our workGet in touch