Agent Loop Cost Estimator

An AI agent cost estimator. Enter the steps per task, the tokens added each step, and your model’s input/output prices to see the cost per task, per day and per month — and why re-sending a growing context each step makes cost scale with the square of the steps, not linearly. Shows where prompt caching helps.

$0.3204per task
$160per day
$4,806per month
Input tokens / task88,800
Output tokens / task3,600
Context-growth premium2.0×

Input tokens grow every step, so cost scales roughly with the square of the step count. The premium above is how much the growing context costs versus a flat context — prompt caching and step caps target exactly this.

The surprising thing about agent cost is that it does not grow with the number of steps — it grows with the square of them. An agent loops: plan, act, observe, repeat. Each turn is a new model call, and every call has to re-send the accumulated context — the system prompt, the tool schemas, and the entire history of what happened so far. So step one carries a little, step five carries five steps of history, step twenty carries twenty. Add those up and the total input is 1 + 2 + … + N = N(N+1)/2, which is proportional to N².

That single fact explains why a task that felt cheap at 5 steps becomes alarming at 20: quadrupling, not doubling, the token bill. This estimator makes it concrete — plug in your steps, the tokens each step adds, and your model’s input and output prices, and it shows cost per task, per day and per month, so a plausible-looking agent does not quietly turn into a budget line you did not expect.

The good news is that the quadratic term is also the most compressible. The repeated prefix — system prompt, tools, unchanged earlier turns — is exactly what prompt caching re-reads at a deep discount, so it attacks the expensive part head-on. The other levers follow from the same math: cap the steps so a loop cannot run away, trim or summarize history so context stops growing, route easy steps to a cheaper model, and cut output tokens since they usually cost more. Knowing your N and your per-step tokens tells you which lever is worth pulling first.

How it works

  • Cost per task, day and month from steps, tokens and prices.
  • Models context growth — cost scales ~N² in steps, not N.
  • Separates input and output token pricing.
  • Shows where prompt caching and step caps cut the bill.

Frequently asked questions

Why does an agent cost more than a single LLM call?

Because an agent runs a loop — plan, act, observe, repeat — and each iteration is a fresh model call that must re-send the accumulated context: the system prompt, the tool definitions, and the full history of previous steps and their results. A 10-step task is not 10 independent calls; it is 10 calls where each one carries everything before it, so the input tokens grow step over step. That accumulation is the hidden cost most people underestimate.

Why does the cost scale quadratically with steps?

If each step appends roughly the same amount of context, then step 1 sends 1 unit, step 2 sends 2, step 3 sends 3, and so on. The total is 1 + 2 + … + N, which is N(N+1)/2 — proportional to N². So doubling the number of steps roughly quadruples the input token cost, not doubles it. This is why long agent runs get expensive fast, and why capping steps and trimming history matter so much.

How does prompt caching change the math?

Prompt caching lets the stable prefix — system prompt, tool definitions, and earlier turns that do not change — be re-read at a large discount (often ~10% of the input price) instead of full price on every step. Since that prefix is exactly the part that repeats every iteration, caching attacks the quadratic term directly and can cut agent costs dramatically. This estimator shows the uncached cost; caching typically brings the effective input cost down toward the fresh-tokens-only case.

What are the biggest levers to reduce agent cost?

Cap the number of steps (a runaway loop is the worst case); trim or summarize history so context does not grow unbounded; use prompt caching for the stable prefix; route simple steps to a cheaper model and reserve the expensive one for hard reasoning; and reduce output tokens, which are usually priced higher than input. Estimating cost up front, as here, tells you which lever matters most for your particular step count and token sizes.