AI Agents Burn Tokens on Planning, Not Coding

AI Agents Burn Tokens on Planning, Not Coding

A systematic analysis of token consumption in agentic coding tasks shows that planning and error recovery dominate costs, enabling developers to predict and optimize spending. The findings challenge the assumption that execution is the primary cost driver.

A new study from arXiv reveals that AI agents spend up to 60% of their token budget on planning and error recovery, not actual code generation. This changes how developers should think about cost optimization and model selection for agentic workflows.
  • What happened: Researchers at arXiv published the first systematic study of token consumption patterns in agentic coding tasks, analyzing trajectories to answer where tokens go, which models are efficient, and whether usage can be predicted.
  • Why it matters: As AI agents become integral to complex workflows, token costs are exploding—this study provides the first data-driven framework to predict and optimize those costs.
  • Key tension: Developers want to cut costs, but have lacked visibility into where tokens are actually spent. This research resolves that tension by pinpointing planning and error recovery as the main cost drivers.

Where Do AI Agents Actually Spend Tokens?

According to the arXiv study, token consumption in agentic coding tasks is heavily skewed toward two phases: planning and error recovery. The researchers analyzed agent trajectories and found that planning consumes 35-40% of total tokens, while error recovery accounts for 20-25%. Execution—the actual code generation—only uses 15-20% of tokens. This is a critical finding because most developers assume the bulk of costs come from generating code, not from the agent's internal reasoning or backtracking.

The study also revealed that token consumption varies significantly by task complexity. Simple tasks like adding a function see planning consume 30% of tokens, while complex multi-file refactoring tasks push planning to 45%. Error recovery tokens spike when agents encounter syntax errors or logic bugs, often re-iterating solutions multiple times before succeeding. This means that developers deploying agents on complex, error-prone tasks are bleeding tokens on recovery loops they never see.

Which Models Are Most Token-Efficient?

AI Agents Burn Tokens on Planning, Not Coding

The arXiv researchers compared several popular models, including GPT-4o, Claude 3 Opus, and Gemini 1.5 Pro, on token efficiency for coding tasks. They found that Claude 3 Opus achieved a 22% lower token consumption per completed task compared to GPT-4o, primarily due to fewer error recovery iterations. According to the study, Claude's superior error handling reduced recovery token usage by 35%, making it the most cost-effective for complex tasks. However, GPT-4o was more token-efficient on simple tasks, consuming 12% fewer tokens than Claude for single-file edits.

The study also noted that Gemini 1.5 Pro struggled with planning efficiency, consuming 18% more tokens on planning than GPT-4o. This suggests that model selection should be task-dependent: use GPT-4o for simple edits, Claude for complex multi-step tasks, and avoid Gemini for planning-heavy workflows. The researchers emphasized that token efficiency is not just about model size—architecture and training data play a crucial role in how agents allocate tokens during reasoning.

MetricGPT-4oClaude 3 OpusGemini 1.5 Pro
Total tokens per task (complex)12,5009,75014,200
Planning token share38%35%42%
Error recovery token share22%15%25%
Execution token share18%20%16%
Cost per task (estimated)$0.25$0.19$0.28
VerdictBest for simple tasksWinner: Best overall efficiencyLeast efficient

Can Agents Predict Token Usage Before Execution?

The arXiv study also tested whether agents can forecast their own token consumption before starting a task. The researchers developed a predictive model based on task type, complexity, and historical trajectory data, achieving 87% accuracy in estimating total token usage within a 10% margin of error. This is a game-changer for cost management in production systems. According to the paper, the model uses features like number of files affected, estimated lines of code, and presence of external dependencies to predict token burn.

However, the study noted limitations: predictions were less accurate for novel tasks (72% accuracy) and tasks requiring external API calls (68% accuracy). This means that while pre-execution token prediction is feasible for routine coding tasks, it remains unreliable for exploratory or integration-heavy work. The researchers suggested that developers implement a two-tier system: use predictions for cost budgeting on standard tasks, and set hard token limits for novel tasks to avoid runaway costs.

What Are the Operational Tradeoffs for Developers?

For developers deploying AI agents in production, the key tradeoff is between cost and performance. The arXiv study shows that using Claude 3 Opus for complex tasks can reduce token costs by 22% compared to GPT-4o, but at the expense of slower response times—Claude is 15% slower on average. This means that for latency-sensitive applications like real-time code completion, GPT-4o may still be preferable despite higher token consumption. The study also found that implementing token prediction models adds 5-10% overhead to task initiation, which may be unacceptable for high-frequency, low-value tasks.

Another tradeoff is model specialization. The researchers found that no single model excels across all task types. Developers must either accept suboptimal efficiency by using one model for everything, or build a routing layer that selects the best model per task—adding complexity to the agent infrastructure. The study recommends the latter, noting that a routing layer can reduce overall token costs by 30-40% while maintaining performance, but requires ongoing maintenance as models evolve.

How Should Developers Adapt Their Workflows?

Based on the arXiv findings, developers should take three concrete actions. First, instrument agent workflows to track token consumption by phase—planning, error recovery, and execution. The study provides sample code for integrating token tracking into existing agent frameworks like LangChain and AutoGPT. Second, implement pre-execution token prediction using the study's model, which is available as an open-source Python library. Third, adopt a model routing strategy: use GPT-4o for simple tasks, Claude 3 Opus for complex tasks, and avoid Gemini for planning-heavy workloads.

The researchers also recommended setting token budgets per task based on complexity. For example, a simple function edit should have a 5,000-token budget, while a multi-file refactor should have 20,000 tokens. If the prediction model estimates higher consumption, developers can either reject the task or switch to a more efficient model. This proactive approach prevents cost overruns and ensures predictable spending, which is critical for enterprises operating at scale.

My thesis: This arXiv study is the first credible attempt to demystify token consumption in agentic workflows, and it reveals that the biggest cost drivers are invisible to developers—planning and error recovery loops.

In the short term, developers can cut token costs by 30-50% simply by switching to Claude 3 Opus for complex tasks and implementing token budgets. The long-term winner will be the model provider that optimizes for low error recovery token usage, as that is the single largest controllable cost factor. I predict that within 12 months, OpenAI will release a fine-tuned variant of GPT-4o specifically for agentic coding that reduces error recovery tokens by 40%, based on the patterns identified in this study. The losers are developers who continue using a single model for all tasks without cost optimization—they will see their AI infrastructure bills double as agent adoption scales.

What remains uncertain is whether token prediction models can be generalized beyond coding tasks to other agentic domains like data analysis or customer support. The arXiv study's model is coding-specific, and its accuracy for other domains is unknown. I infer that similar patterns will hold, but validation is needed.

  1. OpenAI will release a GPT-4o variant optimized for agentic coding within 12 months, targeting a 40% reduction in error recovery token consumption.
  2. Claude 3 Opus will become the default model for complex agentic coding tasks by Q3 2026, capturing 35% of the enterprise agent market from GPT-4o.
  3. Token prediction models will become a standard feature in agent frameworks like LangChain by Q1 2027, with open-source implementations available within 6 months.
  1. April 2026
    arXiv study published

    First systematic analysis of token consumption in agentic coding tasks, revealing planning and error recovery as dominant cost drivers.

  2. Q3 2026
    Claude 3 Opus predicted to lead enterprise agent market

    Based on token efficiency findings, Claude is expected to capture 35% of the enterprise agent market.

  3. Q1 2027
    Token prediction models become standard in agent frameworks

    LangChain and similar frameworks expected to integrate pre-execution token prediction as a core feature.

Token Consumption by Phase in Complex Coding Tasks (estimated)

  • Token consumption in agentic coding is dominated by planning and error recovery, not execution—developers must monitor these phases.
  • Claude 3 Opus is the most token-efficient model for complex tasks, while GPT-4o wins on simple tasks; model routing is essential for cost optimization.
  • Pre-execution token prediction is feasible for routine tasks but unreliable for novel or API-heavy work—use a two-tier system.
  • Developers who ignore token consumption patterns risk 2x cost overruns as agent adoption scales.
  • The next competitive battleground for AI model providers will be reducing error recovery token usage, not just raw performance.

Source and attribution

arXiv
How Do AI Agents Spend Your Money? Analyzing and Predicting Token Consumption in Agentic Coding Tasks

Discussion

Add a comment

0/5000
Loading comments...