“Do not stop until it is done” is a wonderful instruction until the bill arrives. Persistence is the point of Whiplash Driven Development, so cost control has to be designed in, not bolted on.
Where the money goes
With most providers you pay for the text the model reads (input) and writes (output). In an agent session, input dominates: every step re-reads the conversation, the files it opened and the command output so far. Long sessions get more expensive per step as they grow, which is one more reason to prefer fresh sessions per round with memory kept in NOTES.md and git.
A rough estimate: rounds × steps per round × context per step × price. You do not need precision; you need an order of magnitude before you start, and a limit.
Set three limits
- Rounds.
MAX_ROUNDSin the loop script, or the push budget in a Stop hook. This is the limit you control most directly. - Time. Decide when you will look at it, whatever happens. “Overnight” is a budget.
- Money. Set a spending limit or alert at your model provider. It is the backstop when the other two fail.
Spend less per goal
- Small rounds. One failure at a time keeps each round’s context small and makes progress visible.
- Fresh sessions. Start each round clean; carry state in files, not in an ever-growing conversation.
- Trim the output you send back. The last 40 to 80 lines of the verifier output, not the whole log.
- Mix models. A cheaper model for routine rounds, a stronger one to plan and to get unstuck.
- Stop stuck loops early. The same failure three times means change the approach, not keep paying for the same attempt.
- Make the verifier fast. A cheaper check means more rounds per hour and less waiting with an open session.
Judge by cost per goal
The price per token is the wrong number. A cheap model that needs three times the rounds, or games the check so the work has to be redone, costs more than an expensive one that reaches tempo first. Log every session (the session log does it in your browser): rounds, cost, outcome. After ten sessions, cost per goal met tells you which setup to use for which kind of task.
When the budget runs out
That is not failure; it is a checkpoint. Read NOTES.md and the last verifier output, then decide: split the goal, improve the verifier, change the model, or stop. The worst outcome is the one without a budget, where nobody decides at all.