What does an agent loop actually cost?
Multi-step agents resend their full history on every step, so cost grows quadratically with step count, not linearly — a single-turn chat calculator will badly underestimate this. Model the real shape instead.
Assumes fixed context (system prompt + tool schema) is resent every step, plus accumulating history from prior steps — the real shape of a stateless chat-completions API loop. Retry overhead is applied as a flat multiplier on total cost.
Why agent costs grow quadratically, not linearly
Chat-completion APIs are stateless — every call resends the full conversation, not just the new part. In a tool-using agent loop, each step's response (and the tool's observation) gets appended to that history, so by step N you're resending everything from steps 1 through N-1 on top of the new content. If each step adds roughly T tokens of new context, total input tokens across N steps work out to approximately T × N(N+1)/2 — quadratic, not linear, growth. Double the step count and the token bill doesn't double, it roughly quadruples. This is the actual mechanism behind the commonly-cited "agents use 4-15x more tokens than chat" figures.
What the inputs mean
Fixed context is what's resent unchanged on every single step — your system prompt plus every tool's schema definition. Tool schemas aren't free: real-world measurements put the average around 700 tokens per tool definition, so an agent with a dozen tools can spend a meaningful chunk of its context budget before any real work happens. Context added per step is the growing part — the model's own response plus whatever the tool returned, both of which get resent on every subsequent step. Output tokens per step is only what the model actually generates each turn (billed at the output rate), which is typically smaller than the total context growth per step, since tool observations aren't LLM-generated but still count as input on the next call.
Why the presets differ so much
The four starting presets are grounded in real step-count data rather than round numbers: coding agents commonly run 12-30 steps per task (SWE-bench agent trajectories average in that range), while a simple lookup-and-answer loop might resolve in 3-4. Because cost grows with the square of step count, that difference matters far more than it looks — a coding agent isn't just "4x more steps" expensive than a simple loop, it's closer to 15-20x on the input-token side alone.
What this doesn't model
This is a planning estimate, not a trace replay: real agents don't take a fixed number of steps every time, context isn't always a clean linear accumulation (some frameworks prune or summarize older history), and retry behavior varies a lot by task. Use the retry-overhead slider to sanity-check a range rather than treating the output as exact. For a single-turn (non-agentic) estimate, use the regular calculator instead.
