Why agents cost more than you expect
A chatbot answers once and stops. An agent works in a loop: it reads the task, calls a tool, reads the result, decides what to do next and calls another tool, until it thinks the job is done. Every one of those steps is a separate request to the model, and every request carries the whole conversation so far.
That last part is what surprises people. Step one sends the system prompt, the tool definitions and the task. Step two sends all of that again, plus the first tool result and the model's first reply. By step twenty the agent is paying to re-read everything it has seen and written in the previous nineteen. The bill does not grow in a straight line with the number of steps; it grows with the area under a rising line.
Input for step i = starting context + (i − 1) × (tokens added + output per step)Cost per run = cost of all steps × (1 + retry rate) × parallel agents
The calculator applies each model's published price per million tokens to every step, bills the cached share of input at the cached price, multiplies by retries and parallel agents, and then by runs per day and 30 days a month.
A worked example
The page opens on a mid-sized agent running on Claude Sonnet 5.5, priced at $2 per million input tokens, $0.10 per million cached input tokens and $10 per million output tokens. It starts with 8,000 tokens of instructions and tools, each step adds 1,500 tokens of tool results and writes 600 tokens, and a run takes 25 steps.
- Step 1 sends 8,000 input tokens. Step 25 sends 58,400.
- Across the 25 steps, one agent reads 830,000 input tokens and writes 15,000.
- With half the input cached, that is about $0.87 of input and $0.15 of output: $1.02 per agent.
- A 10% retry rate and four agents working in parallel make it $4.49 per run.
- At 200 runs a day that is about $899 a day and $26,968 a month.
Notice where the money goes. Output is under 2% of the tokens but about 15% of the cost, and the rest is input: the agent re-reading its own history. That is the opposite of a chatbot, where output usually dominates, and it is why the levers that matter for agents are different.
Why the worst case is so much bigger
Agents do not stop on schedule. A tool returns an error and the agent tries again, a search comes back empty and it rephrases, or it never becomes confident the task is done and keeps checking. The worst case here assumes three things go wrong at once:
- Twice the steps. Because late steps carry everything before them, 50 steps read 2,972,500 input tokens, about 3.6 times as much as 25 steps, not twice.
- Twice the retry rate, up to 100%. Failures cluster: the same flaky tool that caused one retry tends to cause the next.
- No cache hits. Caches expire after a few minutes without use, and any change near the start of the prompt invalidates what follows. A long tool call or an edited instruction can wipe out the discount.
For the default agent that is $29.98 per run, almost seven times the typical run, and about $5,995 for a day where every run goes badly. Nobody expects every run to hit the worst case, but a budget that cannot survive a bad day is a budget that will be broken by one.
Caps that hold
A cost estimate helps you plan; a cap is what protects you when the plan is wrong. The calculator suggests three, and you can copy them as YAML:
- max_steps is 1.2 times your typical steps, rounded up. That leaves room for a harder-than-usual task while stopping a loop long before it doubles. Most agent frameworks have a step or turn limit; set it to this number.
- max_tokens_per_run is what one agent reads and writes over max_steps, rounded up to the next 10,000. Add up the token usage the API returns after each call and end the run when the total passes the cap.
- daily_budget_usd is 1.5 times the typical daily cost, rounded up. Track spend in your own code and refuse to start new runs once the day's budget is used. Provider spending limits help too, but they are usually monthly and can take time to react.
When a cap trips, stop cleanly: save what the agent has done, return a clear message, and log the run so you can see why it ran long. A capped run that fails loudly is far cheaper than an uncapped one that succeeds eventually.
Six ways to cut an agent's bill
- Trim tool results. Tokens added per step is usually the biggest lever. Return the fields the agent needs, not whole web pages or full API responses. Halving it from 1,500 to 750 takes the default run from $4.49 to $3.46.
- Cache the stable prefix. Keep the system prompt and tool definitions identical and at the very start of every request. Raising the cached share from 50% to 90% takes the default run to $1.72.
- Compact the history. Every few steps, replace old tool results with a short summary. The context stops growing as fast, and so do the late steps.
- Use a smaller model for routine steps. Planning may need a large model; reading a file or formatting output rarely does. The same agent on Claude Haiku 5.5 costs $0.23 per run.
- Check for success early. Give the agent a clear test for "done" so it stops when the task is complete, instead of spending steps double-checking.
- Fix the retries at the source. Flaky tools, vague schemas and outputs that fail to parse all multiply the bill. A retry rate that drops from 10% to 2% is a 7% saving on every run.
What the estimate leaves out
Hidden reasoning tokens are billed as output, so add a thinking budget to output per step if your model thinks before acting. Charges for search, code execution or other hosted tools, cache write premiums, batch discounts, taxes and enterprise pricing are not included. Prices are standard pay-as-you-go text prices; long-prompt price tiers are applied step by step where a provider publishes one.