Most teams can set a number: 40 steps, 20 minutes, 15 dollars. The number is the easy half. The hard half is what the loop does in the two seconds after the number is reached.
There is a well-documented reason to care. Spend that arrives through an agent loop is not linear in the way a single API call is, because most chat and completion APIs are stateless and bill for the whole conversation on every call. A naive N-step loop re-sends prior context each turn, so billed input tokens grow quadratically, and a 20-step loop can consume over ten times what a per-step estimate suggests per this analysis of agent loop token costs. One write-up of multi-turn tool use puts the same point more bluntly: a ten-step run with a 9,000-token starting context reached roughly 472,000 tokens across all calls, about 43 times the single-call baseline in this token economy breakdown.
That math has a direct design consequence. Because the cost of a step rises as the run goes on, the last few steps before a cap are the most expensive ones you will ever buy. An agent that spends them on an unbounded retry, or on a polite essay explaining that it has run out of budget, wastes the most expensive tokens in the session. The stop path has to be cheap, short and deterministic.
The second consequence is that a cap enforced only at the provider account level almost never fires in time. Account-level caps are set at monthly ceilings and typically trip days after the damage; dashboards and Slack alerts are records, not controls, and an agent inside a tool-calling loop does not consult either before calling the endpoint again as argued in this budget enforcement write-up. A run-scoped decision, made before execution, is what actually stops the next call per the reserve, execute, commit pattern described here.
So the stop message is not a courtesy notification bolted onto the end of a run. It is the output of the only code path in the system that is guaranteed to execute at the boundary.



