How this calculator works
The AI Agent Loop Budget Calculator estimates what a single agent run costs and how much that cost varies when the number of steps is uncertain. You enter the average steps per run and a step standard deviation, the input and output tokens consumed at each step, and the per-million-token input and output prices. The tool multiplies tokens by price across the expected step count and models the spread, reporting P50, P95, and P99 cost per run, plus daily totals from your runs per day and parallel worker count. The main drivers are step-count variance, output tokens (usually the priciest side), and how many runs you fan out.
The key trade-off to watch is the tail. A loop that averages a modest cost can still produce rare runs that iterate far past the mean, so budgeting on P50 alone understates real spend. Size limits and alerts against P95 or P99, and cap maximum steps so a runaway loop cannot quietly multiply your bill.
Frequently asked questions
Why is average agent cost not enough to budget?
Agent loops have high step-count variance. A task that averages 8 steps might occasionally need 25. If you cap at the average, 5% of runs get cut off early or spike your bill. P95/P99 planning gives you a safety margin for real worst-case costs.
What is a good max_steps budget for an AI agent?
Set max_steps at your P99 step count: avg_steps + 2.33 × step_std. This caps 99% of normal runs while letting them complete. Any agent exceeding this limit is likely stuck in a loop — a hard stop here saves money without harming normal runs.
How do parallel agent workers multiply cost?
Parallel workers each run full agent loops independently. Cost scales linearly: 10 workers = 10× the per-run cost. The P99 for the entire fleet is higher because at least one of 10 workers is very likely to hit a long run.
What is a runaway agent loop?
A runaway loop is when an agent repeatedly calls tools or itself without making progress — often due to a planning error or an unreachable goal. Without a max_steps cap, a single runaway can cost 10–100× a normal run. Always enforce a hard step cap in production.
How do I calculate P99 cost for an agent?
Assuming steps follow a roughly normal distribution: P99 steps ≈ avg_steps + 2.33 × step_std. P99 cost = P99_steps × tokens_per_step × (input_price + output_price) / 1M. This calculator does that math and also shows daily fleet budget.