Most agent failures are not reasoning failures. They are accounting failures.
A loop that can run forever will eventually run too long. It will retry a broken tool, re-read the same file, or wander through a task that should have been abandoned six steps earlier. The model is not being careless; nothing in the system told it that stopping was an option with a known cost.
Three budgets, not one
Separate the limits, because they fail for different reasons:
- Steps. Caps runaway planning. A step is a model turn plus the tool calls it requested.
- Tokens. Caps context growth. Long loops fail when the window fills with stale observations, not when the step count is exceeded.
- Wall-clock time. Caps user-facing latency, which is often the limit that actually matters.
When any budget is exhausted, the agent should stop with a partial result and a clear explanation, not a stack trace.
Make the budget visible
A budget the model cannot see is a trap. Put the remaining allowance in the context and state the rule plainly: you have N steps left; return the best answer you can with what you know. Agents handle this well. They summarize, prioritize, and drop low-value checks.
Measure cost per resolved task
Step counts and token counts are not the useful metric on their own. Track cost per task that a human accepted. That number makes tradeoffs obvious: a loop that solves more tasks for triple the cost may still be the right product decision, but only if you can see it.
Start with a hard step cap, a token budget that forces summarization, and a timeout. You can loosen them later with evidence. Starting without them means your first production incident will be a bill.