Why agent costs surprise people
The usual estimate is calls × tokens per call × price. For an agent that loop is wrong in a predictable way: every step re-sends the conversation so far. Step one sends the system prompt and the task. Step two sends all of that plus step one’s output and tool results. By step twelve the agent is paying for the first eleven steps again.
That makes cost grow roughly with the square of the loop length, not linearly. Retries add a multiplier on top, and reasoning tokens bill at the output rate. The simulator counts all of it and shows the gap as the hidden multiplier: the estimate divided by the naive calls × tokens figure.
How the estimate works
- Step k input = base input + k × (output + tool calls × tokens per tool result), when context carries over between steps. Turn that off for stateless agents.
- Retries: a retry rate r means each step runs 1 / (1 − r) times on average. At 30% you pay for 1.43 attempts per step.
- Caching: the cached share of every input bills at the provider’s cached rate. Cache-write surcharges are not added, so Anthropic estimates with caching run slightly low.
- Reasoning tokens bill as output and are not carried into the context.
- Context limits: inputs are capped at the model’s window and flagged. In practice that means you need compaction, which has its own cost.
- Fixed costs: tool API fees per call and monthly infrastructure are added separately.
A worked example
One research agent on Claude Sonnet 5.5 ($2 input / $10 output per million tokens, October 21, 2026 — recalculated when prices change). Twelve steps, 6,000 base input tokens, 800 output tokens per step, 1.5 searches per step returning 2,500 tokens each. No caching, no retries, no reasoning.
- Each step adds 800 + 1.5 × 2,500 = 4,550 tokens to the context.
- Total input over twelve steps: 12 × 6,000 + 4,550 × (0 + 1 + … + 11) = 72,000 + 300,300 = 372,300 tokens.
- Cost: 372,300 × $2/M + 12 × 800 × $10/M = $0.74 + $0.10 = $0.84 per task.
- The naive estimate is 12 × (6,000 × $2/M + 800 × $10/M) = $0.24. The real figure is 3.5× higher, before any retries.
At 40 tasks a day that is the difference between a $288 and a $1,009 monthly line item. The research-agent preset starts from these numbers, plus caching, reasoning tokens and a 5% retry rate.
What the levers tell you
The “biggest levers” chart changes one thing at a time — trimming tool results, caching, cutting retries, capping loops, batch pricing, a smaller model — and ranks them by monthly savings. On most agents, trimming what goes back into the context beats switching models, without the quality risk. When I measured a publishing agent, checking the work cost more than writing it. A cost model makes that kind of finding visible before the invoice does.
Related
- Half my agent’s budget goes to checking its own work
- Why I’m betting on a minimal agent harness
- Agent Failure Modes: A Taxonomy: loops and retry storms are where costs explode.
- LLM API Pricing Explorer for per-token prices.
FAQ
How much does it cost to run an AI agent?
Anywhere from fractions of a cent to several dollars per task. The biggest drivers are loop length, how much each step adds to the context, the model’s price, and the retry rate. A support agent doing four short steps on a mid-tier model costs a few cents per conversation. A coding agent doing 25 steps over a large repository context can cost a dollar or more per task.
Why is my agent more expensive than my estimate?
Usually context growth. Every step re-sends everything before it, so input tokens grow much faster than the step count. Retries, hidden reasoning tokens and verbose tool results are the next most common causes.
How do I reduce agent costs?
In rough order of impact without hurting quality: return less from tools (select fields, summarize pages), cache the stable prefix (system prompt and tool definitions), cap loop length, fix whatever causes retries, and use batch pricing for work that can wait. Moving to a smaller model saves the most but changes quality, so test it.
Is this my actual bill?
No. It is an estimate from list prices. Real invoices also reflect tokenizer differences, minimum cache sizes, cache-write charges, rate-limit retries and any discounts you have negotiated. Use it to compare designs and find the expensive parts, then check against your provider’s usage dashboard.
Can I share or save a scenario?
Yes. Copy share link puts the whole configuration in the URL, Copy summary gives you a plain-text version for a doc or ticket, Download CSV exports the per-agent breakdown, and Save to compare keeps up to six scenarios in this browser.