Guides → Playground & Guide → Agent Loop Cost - Multi-Turn Agent Budget with Runaway Risk

Agent Loop Cost - Multi-Turn Agent Budget with Runaway Risk

Meet Aisha Patel. Staff Engineer building a multi-step research agent. "Each task takes 4-8 LLM calls. What does that actually cost - and what happens when an agent loops forever?"

🔥 One bad prompt last week ran 47 loops before timeout. Bill spike: $340 for one task.

The story

Agent loops compound. Each call has accumulated context from previous calls. Turn 1: 2K tokens. Turn 5: 8K tokens. Turn 10: 20K tokens. By turn 15, you're paying premium for context the model can barely use.

Aisha's research agent typically does 4-8 calls per task. Average task: 18K total input + 3K output. At Sonnet pricing, ~$0.10 per task. 1,000 tasks/day = $3K/mo. Looks fine - until one task ran 47 loops at 200K tokens accumulated context, costing $340.

Two costs to model: typical-case (4-8 turns, well-behaved) and runaway-case (loop until timeout, 30-60 turns). The gap between them is your operational risk. Hard limits and circuit breakers make this manageable.

🎮 Playground

Agent Loop Cost Playground

Here are the inputs that move the result the most. Play with the sliders and check it out. The number updates live.

What will an agent loop cost?

Tasks × turns × tokens — plus a “runaway tail” for loops that don’t stop. Balanced tier, ~30 days. (Runaway risk fixed at default; see the breakdown.)

Estimated monthly cost

💡Base = tasks × turns × tokens × rate. The runaway tail adds the cost of a small fraction of tasks looping to their cap — shown in “Why this number”.

Three real scenarios

Same calculator, three team sizes. Click a tab to see how the numbers shift.

$3,155 / month ≈ $37,857 / year

Simple lookup - user query → API call → format response. 3 turns, 2K tokens each. 5K tasks/day. ~$450/mo. Runaway risk is low (well-defined boundary).

Healthy range: $300-600/mo

See inputs used
turnsPerTask
3
tokensPerTurn
2,000
tasksPerDay
5,000
runawayProbability
0.1
runawayMaxTurns
50
runawayMaxTokens
200,000
modelTier
balanced

Use cases

Same calculator, different applications. Sizes above, workloads here. Pick the one that looks like yours.

Pre-loaded scenarios for the most common applications. Click a tab to see realistic numbers, then hit "Try this scenario" to load it into the calculator above.

$2,771 / month ≈ $33,253 / year

Code agents have higher runaway risk than most - they can get stuck in lint-fix loops. Hard turn limit at 30 + token limit at 200K is essential.

Healthy range: $200-700/mo

See inputs used
turnsPerTask
8
tokensPerTurn
5,000
tasksPerDay
200
runawayProbability
1
runawayMaxTurns
100
runawayMaxTokens
500,000
modelTier
balanced

Ready to run the numbers?

Open the full calculator. Pick a model, enter your tokens, see per-call, daily, monthly, and annual cost.

🚀 Open the full calculator →

Best vendors for agentic workloads

Verified 11 hours ago
  1. 1
    GPT-5 Mini
    $0.250 in · $2.00 out ·
  2. 2
    gpt-5.1-codex-mini
    $0.250 in · $2.00 out ·
  3. 3
    Command
    $1.00 in · $2.00 out ·

About this calculator: Agent Loop Cost - Multi-Turn Agent Budget with Runaway Risk

Multi-turn agents (ReAct, AutoGPT, function-calling) have compounding token costs. Model the per-task cost + runaway risk before deploying. Live pricing across 17 vendors.

🎛 Inputs you control

Each input shapes the cost. Click an input on the calculator to set it. The explanations below match the live calculator field by field.

Model (the reasoning one): The model that runs each agent turn — usually a reasoning or large model.
How to choose: Use what you actually run the loop on; the per-turn price is paid on every accumulated turn, so model choice dominates total agent cost.
System prompt + tool definitions (tokens): The fixed prefix sent on every turn: system prompt plus all tool/function schemas.
How to choose: Count your real system prompt + tool JSON. In quadratic mode you re-send this every turn, so it is the #1 prompt-caching target.
Initial user task (tokens): The opening user request that starts the loop.
How to choose: Use a typical task prompt size — roughly 750 words is about 1,000 tokens.
Avg turns per task: How many tool-call / response loops a task runs before it finishes.
How to choose: Simple agents 3-5, ReAct 10-20, planning agents 50+. Cost scales about N-squared in quadratic mode, so this is the single biggest driver.
Avg tool result size (tokens): Tokens each tool / function response adds to the running context.
How to choose: Measure your largest tool outputs; bloated results silently multiply cost because they ride along on every later turn.
Avg assistant reply per turn (tokens): Tokens the model generates per turn (reasoning plus the action it takes).
How to choose: Estimate a typical per-turn output; output tokens are usually priced higher than input.
Agent tasks per day: How many complete agent tasks you run per day.
How to choose: Use real or projected traffic; daily and monthly totals scale directly with this number.
System prompt cached: Whether the stable prefix (system prompt + tool defs) is served from prompt cache.
How to choose: Turn on if your provider supports caching — the biggest agent-cost lever once turns exceed about 10, often 40-60% off.
📋 Typical values & starting points Don’t know a value yet? Start with these broad, sourced ballparks — the calculator’s ▾ Typical menus pre-load the same options.

Context: Agent loops compound context: turn 1 ~2K tokens, turn 10 ~20K. Typical tasks run 4-8 turns; runaways 30-60. The bill is made of the bad days - cap runaway turns/tokens.

Input Default Typical ballparks
turnsPerTask moves the needle 6 Simple tool-use · 4 = 4 · Typical agent · 6 = 6 · Deep research/complex · 10 = 10
tokensPerTurn moves the needle 3,000 Lean prompts · 1.5K = 1,500 · Typical · 3K = 3,000 · Context-heavy · 8K = 8,000
runawayProbability 0.5 Hard caps in place · 0.1% * = 0.1 · Typical · 0.5% * = 0.5 · No circuit breakers · 2% * = 2 (rough estimates)
tasksPerDay moves the needle 1,000 Pilot team · ~100/day = 100 · Small production · ~1K/day = 1,000 · Mid production · ~10K/day = 10,000
runawayMaxTurns 50
runawayMaxTokens 200,000
modelTier balanced

Ballparks are broad industry starting points (sourced ranges; * = rough estimate) — your result gets more accurate as you replace them with measured numbers. Try them live in the calculator; API & agent users get the same data from the MCP resource aicost://input-reference/agent-loop-cost.

📊 CALCULATOR AT A GLANCE
Agent Loop Cost - Multi-Turn Agent Budget with Runaway Risk full size

Reading your result

Typical-case cost is the baseline. Per-task: tokens × per-turn × turns. Multiply by tasks/day × 30 = monthly. This is the budget you forecast.

Runaway-case cost is the tail risk. 0.5% of tasks hitting 50 turns at 200K accumulated tokens = a few hundred dollars/month in invisible spend. At 2% runaway rate, this becomes the dominant cost line. Most teams don't notice until the bill arrives.

Compare to non-agent alternatives. If this same task could be done with a single 30K-token call (skip ReAct, use long-context model), is the agent worth the 2-3× cost premium? Sometimes yes (better tool use, audit trail). Sometimes no (just looks impressive).

Set hard limits. Max turns + max tokens per task + max cost per task = your circuit breakers. Without these, one bad prompt can blow a daily budget.

What "good" looks like:
  • Single tool call (3 turns): $0.02-0.05/task on balanced tier
  • Standard agent (6-8 turns): $0.08-0.15/task - Aisha's case
  • Research agent (12-20 turns): $0.30-0.80/task
  • Long workflow (25+ turns): $1.50-5/task - usually merits a single long-context call instead

What this calculator can't tell you

Honest limitations. Every model is wrong; some are useful. Where this one falls short:

For these, use: Agentic Workflow Cost for full pipeline. Multi-Model Router for tiered routing.

Trade-offs

Cost isn't the only dimension. Click any constraint to see how recommendations change.

What matters most to you? Click any dimension — recommendations update.

Best fit for "cost":

  1. Hard turn + token limits Eliminates runaway tail
  2. Cheap-tier sub-agents Route reasoning to premium, tool calls to cheap

Agent cost optimization isn't about model choice - it's about turn count. Cutting turns 6→4 is a 33% savings. Cutting accumulated context per turn (smart context windowing) is another 30-50%.

Most popular

Everything above is the 80% case. The last 20% is where the money is.

The gaps we just listed are real, and they are the expensive ones: your actual prompts, your switching cost, your MLOps overhead. An AICost expert spends the hour on your AI and cloud costs, not a generic playbook. You leave with a written report: the way forward, in 30 days of concrete steps.

  • An hour with the people who built the engines
  • Report the same day
  • The fee credits toward any AICost plan
  • Two slots a week
Book a Solution Session: $299 → or $99 for small business →

Not sure yet? The $39 AICost Blueprint credits toward a Session, and the Session fee credits toward any plan. You never pay twice for the same ground. See all pricing →

Ready to run your own numbers?

You have seen the shape of it. Open the calculator with your model, your tokens, your volume.

🚀 Open the full calculator →

Where to go next

Full agentic workflow (Claude Code, Cursor) →

Tasks × tokens × cache + runaway buffer. Production agents.

Route reasoning vs execution to different tiers →

Premium for planner, cheap for tool calls. 50%+ savings.

Long-context alternative analysis →

Sometimes a single 30K-token call beats 8 turns of 5K context.

Methodology

Source
https://platform.claude.com/docs/en/build-with-claude/agents
Extraction
Per-turn token accumulation modeled against 12 production agent traces.
Editorial gate
8-layer defense, see aicost.ai/ai-cost-economics
Last verified
7/27/2026, 8:00:00 PM

Author: Subu Vdaygiri, Founder & CEO of CloudIntelligence.ai. 17 years Fortune 100 (Ingram Micro, Siemens). Wharton CTO program · Kellogg CPO program · 10× AWS+Azure certified.

3 years of pricing history

Why this matters: pricing for major vendors has dropped 40-90% in the last 24 months. A budget set 12 months ago is probably wrong by 30%+.

View 3-year history for →
📖 Data sources & methodology 163 text models · 9 embeddings · 37 vision · 55 audio · 8 vector DBs across 10 vendor pages · last verified 2026-07-28

Methodology

  • All prices are USD per 1 million tokens, current as of 2026-07-28.
  • Vendor-published values have no mark. Inferred/extrapolated values are marked with * and listed below.
  • Batch API discounts are 50% off standard rates across providers that offer Batch mode.
  • Prompt caching discounts vary by provider (typically 80-90% off cached input tokens).
  • Regional data-residency surcharges (Anthropic 1.1x, OpenAI 1.1x, Google regional tiers) are NOT included in base rates.
  • Long-context pricing tiers apply when input exceeds model threshold.
  • Embedding prices are input-only (no output tokens generated).

Primary sources

Last-verified date is the most recent successful daily snapshot (aicost_pricing_snapshots) or, when no snapshot exists yet, the latest successful crawler run (aicost_crawler_runs). 10 of 10 vendors are currently verified. Aggregator services (TokenCost, AI Pricing Guru, etc.) are not listed.

Anthropic
2026-07-28
https://www.anthropic.com/pricing
Daily snapshot since Sep 2023 · 631 days captured
Anthropic Docs
2026-07-28
https://platform.claude.com/docs/en/about-claude/pricing
Daily snapshot since Sep 2023 · 631 days captured
OpenAI
2026-07-28
https://openai.com/api/pricing/
Daily snapshot since Sep 2023 · 632 days captured
Google AI
2026-07-28
https://ai.google.dev/gemini-api/docs/pricing
Daily snapshot since Dec 2023 · 607 days captured
Google Vertex
2026-07-28
https://cloud.google.com/vertex-ai/generative-ai/pricing
Daily snapshot since Dec 2023 · 607 days captured
DeepSeek
2026-07-28
https://api-docs.deepseek.com/quick_start/pricing
Daily snapshot since May 2024 · 546 days captured
xAI
2026-07-28
https://x.ai/api
Daily snapshot since Nov 2024 · 464 days captured
Mistral
2026-07-28
https://mistral.ai/pricing
Daily snapshot since Dec 2023 · 605 days captured
Cohere
2026-07-28
https://cohere.com/pricing
Daily snapshot since Sep 2023 · 631 days captured

Inferred values (marked with * in calculator tables)

Derived from industry conventions, not directly published by the vendor. Typical conventions: cached input = 10% of base (90% off), Batch API = 50% of base (50% off).

Vendor / Model Field Why it’s inferred
Anthropic — Claude Sonnet 4.6 cachedInput Derived at 10% of input rate — Anthropic publishes 90% cache-hit discount on this tier.
Anthropic — Claude Sonnet 4.5 cachedInput Derived at 10% of input rate; same 90% cache-hit convention as Sonnet 4.6.
Anthropic — Claude Sonnet 4.5 batchInput Derived at 50% of standard input — Anthropic documents uniform 50% Batch discount.
Anthropic — Claude Sonnet 4.5 batchOutput Derived at 50% of standard output — Anthropic documents uniform 50% Batch discount.
Anthropic — Claude Haiku 4.5 cachedInput Derived at 10% of input rate — Anthropic 90% cache-hit discount convention.
OpenAI — GPT-5.4 Mini cachedInput Derived at 10% of input — OpenAI documents automatic 90% discount on cache hits across GPT-5.x tier.
OpenAI — GPT-5.4 Nano cachedInput Derived at 10% of input — OpenAI 90% cache-hit convention.
OpenAI — GPT-5.4 Nano batchInput Derived at 50% of input — OpenAI Batch API uniform 50% discount.
OpenAI — GPT-5.4 Nano batchOutput Derived at 50% of output — OpenAI Batch API uniform 50% discount.
OpenAI — GPT-5.4 Pro cachedInput Derived at 10% of input — OpenAI 90% cache-hit convention.
OpenAI — GPT-5.4 Pro batchInput Derived at 50% of input — OpenAI Batch API uniform 50% discount.
OpenAI — GPT-5.4 Pro batchOutput Derived at 50% of output — OpenAI Batch API uniform 50% discount.
OpenAI — GPT-5.2 cachedInput Derived at 10% of input; no residency uplift.
OpenAI — GPT-5.2 batchInput Derived at 50% of input.
OpenAI — GPT-5.2 batchOutput Derived at 50% of output.
OpenAI — GPT-5 cachedInput Derived at 10% of input.
OpenAI — GPT-5 batchInput Derived at 50% of input.
OpenAI — GPT-5 batchOutput Derived at 50% of output.
OpenAI — GPT-5.5 Pro cachedInput Derived at 10% of input — OpenAI does not publish a cached rate for *-pro models; using the family convention.
OpenAI — GPT-5.5 Pro batchInput Derived at 50% of input.
OpenAI — GPT-5.5 Pro batchOutput Derived at 50% of output.
OpenAI — GPT-5.2 Pro cachedInput Derived at 10% of input — pro-tier convention.
OpenAI — GPT-5.2 Pro batchInput Derived at 50% of input.
OpenAI — GPT-5.2 Pro batchOutput Derived at 50% of output.
OpenAI — GPT-5.1 batchInput Derived at 50% of input.
OpenAI — GPT-5.1 batchOutput Derived at 50% of output.
OpenAI — GPT-5 Pro batchInput Derived at 50% of input.
OpenAI — GPT-5 Pro batchOutput Derived at 50% of output.
OpenAI — GPT-5 Nano cachedInput Derived at 10% of input.
OpenAI — GPT-5 Nano batchInput Derived at 50% of input.
OpenAI — GPT-5 Nano batchOutput Derived at 50% of output.
Google — Gemini 3 Flash cachedInput Derived at 10% of input — Google caching discount convention ~90%.
Google — Gemini 3.1 Flash-Lite cachedInput Derived at 10% of input — Google caching convention.
Google — Gemini 3.1 Flash-Lite batchInput Derived at 50% of input — Google Batch API uniform 50% discount.
Google — Gemini 3.1 Flash-Lite batchOutput Derived at 50% of output — Google Batch API uniform 50% discount.
Google — Gemini 2.5 Pro cachedInput Derived at 10% of input.
Google — Gemini 2.5 Flash cachedInput Derived at 10% of input.
Google — Gemini 2.5 Flash-Lite cachedInput Derived at 10% of input — Google caching convention.
Google — Gemini 2.5 Flash-Lite batchInput Derived at 50% of input — Google Batch API uniform 50% discount.
Google — Gemini 2.5 Flash-Lite batchOutput Derived at 50% of output — Google Batch API uniform 50% discount.
Google — Gemini 2.0 Flash cachedInput Derived at 25% of input per Google 2.0 family caching rates.
Google — Gemini 2.0 Flash batchInput Derived at 50% of input — Google Batch API uniform 50% discount.
Google — Gemini 2.0 Flash batchOutput Derived at 50% of output — Google Batch API uniform 50% discount.
Google — Gemini 2.0 Flash-Lite cachedInput Derived at 10% of input — Google caching convention.
Google — Gemini 2.0 Flash-Lite batchInput Derived at 50% of input — Google Batch API uniform 50% discount.
Google — Gemini 2.0 Flash-Lite batchOutput Derived at 50% of output — Google Batch API uniform 50% discount.
xAI — Grok 4 (legacy) cachedInput Extrapolated at 25% of base.

Pricing is cross-verified against the LiteLLM community registry when available. Daily snapshots are kept in aicost_pricing_snapshots; every change is logged to aicost_price_changelog with old & new values for full audit trail. Read the full methodology →