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

Longju Bai; Zhemin Huang; Xingyao Wang; Jiao Sun; Rada Mihalcea; Erik Brynjolfsson; Alex Pentland; Jiaxin Pei · pdf · 2026 source ↗ Reader 🖥️

Agent Cost AttributionPre-Execution Cost Prediction (Agent Self-Prediction)AI Unit EconomicsCoding AgentsContext Tax (Retry-Driven Cost Accumulation)EvalsToken Efficiency
Because agentic coding tasks burn tokens overwhelmingly through accumulating, cache-read input context rather than output generation -- and because that spend is highly variable, only weakly tied to human-perceived difficulty or to accuracy, and only weakly predictable by the executing agent itself before the task runs -- transparent upfront pricing for AI coding agents is not currently achievable, so consumption-based billing (with, at best, coarse-grained self-predicted budget alerts) is the only viable near-term model.

theoretical · argumentative — An empirical study (eight frontier LLMs x 500 SWE-bench-Verified problems x four runs) establishing descriptive facts about where and how agentic coding tasks spend tokens, then testing a specific capability claim (can agents predict their own cost pre-execution). The propositions are almost all 'X is true of agent token consumption,' but the paper explicitly frames its motivation and conclusion around a practical design question -- how agent pricing should work -- so the theoretical findings are marshalled in service of a practical argument about pricing policy (consumption-based billing remains necessary).

Structure

PartRole
Introduction (Sec 1): frames the problem as a transparency/completion-guarantee failure in current agent pricing, and states the three motivating questions (where do tokens go, which models are efficient, can agents predict their own cost).context
Data and Method (Sec 2): OpenHands agent framework, SWE-bench-Verified, eight frontier models, four independent runs per problem, fine-grained token/action metrics parsed from completion logs.methodology
Overall Consumption Patterns (Sec 3): agentic tasks vs. chat/reasoning cost comparison; variance across problems and runs; token cost vs. accuracy (inverse at the high end); human difficulty ratings vs. actual cost (Kendall tau_b = 0.32).evidence
Model Token Efficiency (Sec 4): accuracy-cost trade-off across 8 models; token efficiency persists across shared success/failure subsets, so it's model-specific behavior, not task difficulty; fine-grained file-action analysis (repeated views/edits).evidence
Token-Cost Dynamics Across Phases and Rounds (Sec 5): five-phase trajectory taxonomy (Setup/Explore/Fix/Validate/Closeout); cache-read tokens dominate volume and dollar cost in every phase; round-level case study (astropy-7336) showing cache-read as a steady baseline punctuated by discrete cost spikes from new-content actions.evidence / mechanism
Predicting Token Consumption Before Execution (Sec 6): formalizes the self-prediction task; agents achieve weak-to-moderate correlation (up to 0.39) and systematically underestimate real cost, especially input tokens; prediction overhead is usually less than task cost but not monotonically tied to accuracy.evidence
Discussion (Sec 7) and Conclusion (Sec 8): limitations (8 models, single harness/benchmark), argues for the pricing implications -- subscription models break under agentic variance, self-prediction can support coarse budget alerts but not exact pricing, consumption-based pricing stays the practical default.conclusion / practical argument
Appendices A-D: output-token-mirrored analyses, explicit cost-calculation formulas (Claude-style explicit cache vs. GPT-5-style implicit cache), the full self-prediction system prompt and worked in-context example, and a no-example ablation showing underestimation persists (and worsens) without the demonstration.supporting detail / robustness check

Key terms

Propositions

Arguments

Purely upfront, fixed-price billing for agentic coding products is not currently achievable, so consumption-based (usage-metered) pricing must remain the practical default. strength: medium
Explicit premises:
Implicit premises:
Inferences:
Excess token spend on expensive-but-failed runs reflects redundant, unproductive agent exploration rather than genuinely deeper or more careful reasoning. strength: medium
Explicit premises:
Implicit premises:
Inferences:

Narratives

Questions addressed

Gaps

Closes gaps elsewhere

Related documents