Cost Control (Agent)
A single model call has a price you can predict. An agent does not: it decides for itself how many calls to make, and a loop that keeps retrying a failing tool will happily spend fifty times what the task was worth. Cost control is the set of mechanisms that put a ceiling on that uncertainty before the invoice arrives.
Where the ceiling is enforced
Cost control is layered, because any single limit can be evaded by a loop that is expensive in a different dimension:
- Token budgets — a running total of input and output tokens for the task, checked before each call.
- Step limits — a hard maximum on iterations of the plan–act–observe loop, so an unproductive cycle ends.
- Model routing — a cheap model for classification and summarisation, the expensive one reserved for planning.
- Caching — reusing a prompt prefix or a repeated tool result instead of paying for it again.
- Per-run and per-tenant caps — the backstop that protects the account when one task misbehaves.
Why it matters
Autonomy and cost are the same variable seen from two sides: every extra degree of freedom you grant the loop is permission to spend. Frameworks expose this directly — LangGraph recursion limits, callback handlers that tally usage per node — because the alternative is discovering the number after the fact. Equally important is what happens at the ceiling: an agent cut off mid-task without checkpointing its state has spent the whole budget and delivered nothing, so a budget is only as useful as the graceful stop attached to it.
Cost control is the set of mechanisms that bound what an agent spends on a task — token budgets, step limits, cheaper models for routine sub-calls, prompt caching, and per-run caps. Because the loop decides for itself how many model calls to make, cost is not predictable from the request alone. Without a ceiling a retrying or looping agent can spend many times the value of the work it was given.
Imagine hiring someone by the hour and telling them to sort out a problem — however long it takes. Most of the time it is fine. But if they get stuck in a loop, trying the same thing over and over, the bill keeps climbing and nobody is watching.
Cost control is the agreement you make up front instead: a spending limit, a cap on how many attempts are allowed, and cheaper help for the simple parts of the job.
Software that works on its own decides for itself how much work to do, so the cost is not known in advance. These limits are what keep an unlucky run from turning into an expensive surprise.