WiseCrewAI → Guides

Why AI Agents Are Expensive — And How to Fix It

9 min readUpdated 2026-11-18

AI agents that take multiple steps accumulate tokens quadratically: each step re-sends the entire conversation history. This guide explains the token math behind agent costs and provides proven strategies to keep them affordable.

The hidden cost multiplier in agents

A single LLM call costs (input + output) tokens. An agent that takes 10 steps doesn't cost 10× a single call — it costs much more. Each step re-sends the full conversation history (all previous inputs and outputs) plus the new context. If each step generates 500 output tokens and the system prompt is 2,000 tokens, step 10 sends 2,000 + (500 × 9) = 6,500 input tokens. The cumulative input cost across 10 steps is roughly 35,000 tokens — not the 20,000 you might expect from 10 × 2,000.

Real cost examples for agent workloads

Customer support agent (5 tool calls per ticket, Sonnet 5): ~15K tokens per resolution = $0.045 input + $0.015 output = $0.06/ticket. At 1,000 tickets/day = $1,800/month. Code review agent (8 steps per PR, GPT-5.4): ~40K tokens per PR = $0.10 input + $0.06 output = $0.16/PR. At 200 PRs/day = $960/month. Research agent (15 steps with web search, Opus 5): ~120K tokens per task = $1.80 input + $0.90 output = $2.70/task. At 100 tasks/day = $8,100/month. The step count is the primary cost driver.

Strategy 1: Minimize steps

Every eliminated step saves not just that step's tokens but all future steps that would have re-sent its output. Give the agent better tools that return more useful data per call. Instead of separate "search" and "get details" tools, combine them into one tool that returns both. Instead of iterative refinement loops, give clear instructions upfront with examples. Reducing a 10-step agent to 7 steps typically saves 35–40% on tokens, not just 30%.

Strategy 2: Sliding window and summarization

Don't send the full conversation history on every step. Implement a sliding window: keep only the last 3–5 steps in full and summarize older steps into a brief paragraph. This caps context growth at a fixed size regardless of step count. A 20-step agent with a 5-step window uses roughly the same tokens as a 7-step agent without windowing. The trade-off: the agent may lose details from early steps. Mitigate this by extracting key decisions and intermediate results into a structured "memory" object that persists compactly.

Strategy 3: Model routing per step

Not every agent step needs the same model. Use Opus or GPT-5.4 for the planning step and the final synthesis. Use Haiku or GPT-5 mini for tool-calling steps that just need to extract parameters and format API calls. A typical agent has 1–2 "thinking" steps and 5–8 "execution" steps. Routing execution steps to a budget model saves 60–80% on those steps with no quality impact — the tool calling doesn't require deep reasoning.

Strategy 4: Prompt caching for agents

Agent system prompts and tool definitions are repeated on every step — perfect for prompt caching. If your system prompt + tool schemas are 5,000 tokens and you take 10 steps, caching saves 45,000 tokens of re-processing. With Anthropic's caching (90% discount on reads), this saves roughly $0.60 per 10-step session on Sonnet 5. Across 1,000 sessions/day, that's $18,000/month in savings. Enable caching on any agent framework that supports it — this is the single highest-ROI optimization.

Related calculators

agent cost calculator →prompt caching calculator →conversation cost calculator →

Related guides

prompt caching explainedmulti model routing guidehow to reduce llm costs

Frequently Asked Questions

Why does my agent cost so much more than a simple chatbot?

A chatbot sends 1 message and gets 1 response. An agent sends 5–20 messages in a loop, and each message includes the entire prior conversation. A 10-step agent uses roughly 10× more tokens than 10 independent chatbot messages because of the accumulated context. The fix: prompt caching (saves 80–90% on repeated context), sliding window (caps context growth), and model routing (cheap model for simple steps).

What is a reasonable cost per agent task?

It depends on the task value. Customer support: $0.05–$0.20/ticket is acceptable (replacing $5–$15 in human cost). Code review: $0.10–$0.50/PR (replacing 30 minutes of developer time). Research tasks: $1–$5/task (replacing hours of manual research). If your agent costs more than 10% of the human cost it replaces, optimize before scaling.

How do I calculate my agent's cost before deploying?

Use the WiseCrewAI Agent Cost Calculator. Input: model, system prompt size, average tool call count, average tokens per tool response, expected output tokens per step. It calculates the cumulative token cost across all steps including context re-sends. Run it with your actual system prompt and typical tool outputs for an accurate estimate.

What is the most expensive part of an agent run?

The system prompt re-sent on every step is usually the single largest cost component, followed by accumulated tool outputs. In a 15-step agent with a 5K system prompt: system prompt cost = 5K × 15 = 75K tokens (40% of total input). Tool outputs accumulated over 15 steps = ~90K tokens (48%). The agent's own reasoning = ~22K tokens (12%). This is why caching the system prompt is the #1 optimization.

How do I debug an agent that is using too many tokens?

Log the full token breakdown per step: input tokens (system + history + current), output tokens, and cache hit/miss. Look for: (1) tool outputs that are unexpectedly large (a web scrape returning 20K tokens instead of expected 2K). (2) Unnecessary verification steps (the agent re-checking work it already confirmed). (3) Context that grows because tool results are not truncated. Most agent cost overruns trace back to 1–2 specific tool outputs that should be summarized or truncated.

Should I use a single powerful agent or multiple specialized agents?

Single agent: simpler, cheaper (one context), easier to debug. Multiple agents: better task isolation, can use different models per agent, but higher total token cost due to context duplication. Use single agent for most tasks. Use multi-agent only when: (1) tasks can run in parallel (time savings justify cost), (2) tasks require genuinely different expertise/tools, or (3) a single agent's context would exceed the model's window.

How do agent costs change with different models?

The same 10-step agent workflow costs dramatically different amounts by model. Example (5K system prompt, 1K tool outputs per step): GPT-5 mini ($0.25/M): ~$0.02 per run. Claude Sonnet 5 ($3/M): ~$0.25 per run. Claude Opus 5 ($15/M): ~$1.25 per run. That is a 62× cost difference between the cheapest and most expensive option. Use the cheapest model that meets your quality bar, and route between models per step for maximum savings.

Guide updated 2026-11-18. Pricing data verified weekly. See methodology · sources.