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 🖥️
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
| Part | Role |
|---|---|
| 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
- Token consumption / token usage
Used interchangeably (explicit footnote) to mean both input and output tokens used by an LLM agent across an entire multi-round trajectory, not per-call. - Agentic coding task
A multi-round, tool-using, autonomous problem-solving process on a SWE-bench-style GitHub issue, carrying the full conversation history forward each round -- contrasted explicitly with 'code reasoning' (single-turn, no tools) and 'code chat' (multi-turn dialogue, no repository interaction). - Phase (Setup / Explore / Fix / Validate / Closeout)
A five-way functional segmentation the authors impose on every trajectory's rounds, used purely for aggregation and reporting, not something the agent itself declares. - Cache read / cache creation / non-cached input
The three sub-categories of input tokens under Anthropic-style explicit prompt caching: cache creation writes new context into the cache (priced at a chosen TTL, here the 5-minute rate); cache read retrieves previously-cached context at a steep discount; non-cached input is genuinely fresh, full-price prompt content. - Self-prediction
The specific experimental design where the same coding agent used to execute a task is repurposed, via a different system prompt, to estimate its own future token cost before executing -- as opposed to training or querying a separate, external cost-prediction model. - Prediction overhead
The ratio of the token/dollar cost spent producing a self-prediction to the actual cost of executing the task -- a cost-of-cost-estimation metric.
Propositions
- explicitAgentic coding tasks consume roughly three orders of magnitude more tokens than single-turn code reasoning and multi-turn code chat tasks, and this gap is driven almost entirely by input-token growth rather than output tokens.conf: high
- explicitToken usage on agentic coding tasks is highly variable and inherently stochastic: the abstract's headline figure is that repeated runs of the identical task and model can differ by up to 30x in total tokens, but the paper's own per-model average (Figure 2b: max/min cost ratio averaged across all 500 instances) is only about 2x -- so 30x is a heavy-tail extremum, not the typical run-to-run spread, and the most expensive problem costs on average ~7 million more tokens than the cheapest.conf: high
- explicitcontestedHigher token spend does not translate into higher task accuracy -- accuracy peaks at intermediate cost quartiles and saturates or declines at the highest cost levels ('inverse test-time scaling').conf: highcontradictsAgentics / Tech Things: Tokenmaxxing is dead, long live tokenmaxxing · p5 — Tokenmaxxing's 'compounding correctness' regime-shift thesis claims more token spend generally yields better agentic-loop outcomes; this paper's own 500-task, 8-model SWE-bench study finds the opposite at the high end -- accuracy peaks at intermediate cost and saturates or declines with more spend -- directly supplying the general coding-task benchmark evidence that extract-tokenmaxxing#g1 says is missing.supportsThe Economics of Agentic AI: Engineering for Imperfection · p3 — That essay argues theoretically that 'no amount of additional... inference-time compute can resolve a failure caused by a missing structural constraint'; this paper's empirical finding (more tokens do not raise accuracy, and high-cost runs show more redundant, unproductive exploration) is concrete benchmark evidence for the same underlying claim.
- explicitThe most expensive runs show a sharply higher rate of repeated (redundant) file-view and file-modify actions on the same file, compared to cheaper runs on the same problem -- consistent with wasted, unproductive exploration rather than deeper reasoning.conf: highsupportsUber's Zero Growth Stack: Scaling Services, While Optimising Infrastructure and AI Cost · p8 — Uber's move away from aggregate cost/throughput tracking toward granular metrics like 'net code quality ratio' is motivated by suspicion that gross spend hides waste; this paper supplies a concrete mechanism (repeated, redundant file view/edit actions inflating cost on failed or expensive runs) that would specifically require Uber-style granular attribution to detect.
- explicitModels differ substantially and consistently in token efficiency (Kimi-K2 and Claude Sonnet-4.5 consume, on average, over 1.5M more tokens than GPT-5 on the same tasks), and this ranking holds even on the subset of tasks every model solves and the subset every model fails -- so the difference is an inherent model trait, not a byproduct of task difficulty or of harder models attempting harder problems.conf: highrefinesThe Almedra Token-Efficiency Benchmark, Updated For GLM 5.2 · p5 — Almedra's benchmark (harness varied, model held fixed) concludes harness design is the dominant driver of efficiency differences. This paper (model varied, harness/OpenHands held fixed) finds model identity is an independent, robust driver of efficiency, stable across shared success/failure subsets. Together they show efficiency has (at least) two independent axes -- harness and model -- rather than either being the sole driver.
- explicitHuman expert-rated task difficulty (time-to-resolve categories from SWE-bench-Verified) is only weakly associated with actual agent token cost (Kendall tau_b = 0.32); 6.7% of tasks rated '<15 minutes' cost more tokens than the average '>1 hour' task, and 11.1% of '>1 hour' tasks cost fewer tokens than the average '<15 minute' task.conf: high
- explicitCache-read input tokens are the single largest category of both raw token volume and dollar cost in every phase of an agentic coding trajectory, even though output tokens are priced roughly 80x higher per token -- because the sheer accumulated volume of reused context outweighs the higher per-token price of generation.conf: highextendsI benchmarked CC's caveman plugin against 'be brief'. The token math is wild. · p4 — Caveman's finding is scoped to output-token compression in a single-turn/chat-style setting ('output tokens are the mechanism for reasoning'). This paper shows that in long-horizon agentic coding specifically, the dominant cost driver is cache-read *input* accumulation, not output -- extending token-economics analysis to a task regime where the caveman finding's premise (output tokens are the main lever) does not hold.
- explicitFrontier models can predict their own token cost before executing a task only with weak-to-moderate correlation with actual usage (up to 0.39, achieved by Claude Sonnet-4.5 on output tokens), and input-token prediction is harder than output-token prediction for most models -- with one named exception, Kimi K2, which attains its highest correlation (0.38) on input tokens rather than output.conf: high
- explicitAll tested models systematically underestimate their own real token usage when self-predicting, with the bias most pronounced for input tokens as real values scale into the millions; this underestimation persists (and worsens) even when no in-context worked example is given, indicating the bias is not merely an artifact of the demonstration.conf: high
- explicitThe cost of producing a self-prediction (prediction overhead) is usually well under the cost of executing the task itself, but overhead and prediction accuracy are not monotonically related -- some models (Sonnet 3.7, Sonnet 4) spend over 2x the task's eventual cost on prediction without achieving the best correlations, while Sonnet 4.5 achieves its best correlation at only 0.32x task cost.conf: high
- explicitdevelopedBecause token usage is highly variable and hard to predict, and self-prediction only yields coarse-grained rather than instance-precise estimates, purely upfront/fixed pricing for agentic products is not currently viable, and consumption-based (usage-metered) pricing will remain the practically necessary model until pre-execution estimation improves.conf: mediumextends ←How to Respond to the Coming AI Cost Shock · p4 — Draws the practical, executive-facing conclusion (abstract AI budgeting doesn't work) from the same underlying fact the research piece establishes empirically: token usage is highly variable and poorly self-predictable, undermining fixed/upfront pricing.
- implicitAn agent's capacity to reason about and estimate its own resource consumption is one measurable instance of a broader, more valuable capacity for behavioral self-modeling -- the same capacity that would let an agent decide whether a task is worth attempting or recognize when to stop.conf: medium
- implicitHuman perceptions of task difficulty and an LLM agent's actual computational effort are different constructs measuring different things, not two imperfect measurements of one shared underlying 'difficulty' -- so improving human time-estimates would not by itself improve token-cost prediction.conf: medium
Arguments
- Token usage varies enormously across problems and across repeated runs of the same problem (up to 30x).
- Frontier models can self-predict their own cost only with weak-to-moderate correlation and systematically underestimate real usage.
- A viable pricing scheme must be either accurate-and-upfront or transparently usage-based -- there is no third option that is simultaneously fixed-price and reliably profitable/acceptable to users at this level of variance.
- The executing agent's self-prediction, with its privileged access to the repository and its own planned tool calls, represents close to the best-case predictor available; if it cannot beat weak-to-moderate correlation, no cheaper external predictor is likely to do much better.
- Providers and users would not accept a fixed price calibrated to a systematically-biased-low estimate (the underestimation problem), which is itself an argument against using current self-prediction directly as a pricing input.
- If self-prediction is used operationally for 'budget alerts' as the paper suggests, and the bias is systematically toward underestimation, then alerts built on raw self-predicted numbers will themselves warn too late or too low unless a calibrated safety margin is added -- a practical risk the paper does not spell out even though its own data (Fig. 11) directly implies it.
- Accuracy is non-monotonic in cost: it rises from minimum to low cost, then saturates or falls at higher cost quartiles.
- The frequency of repeated file-view and file-modify actions on the same file rises sharply as cost quartile increases.
- Repeated viewing/editing of the same file is a valid behavioral proxy for wasted, non-productive search, rather than, e.g., legitimate iterative refinement or necessary re-verification that a genuinely hard problem would require.
- The correlation between high cost and repeated actions reflects agent behavior driving the cost, rather than both being downstream effects of the same underlying task ambiguity (a third-variable / confounding possibility the paper does not rule out).
- If repetition itself (rather than an independent judgment of unnecessary repetition) is the operative signal, then a cheap real-time governor that caps repeated file actions per file could plausibly recover much of the wasted spend without hurting accuracy -- the paper stops short of proposing or testing this concrete mitigation, even though its own finding directly motivates it.
Narratives
- The round-by-round case study of a single agent trajectory on task 'astropy astropy-7336' (Sec 5.3, Figure 9, Table 2): cache-read cost climbs as a smooth, steadily rising baseline while sharp cost spikes coincide with specific discrete actions (reading a new file, running tests, writing a final summary).
→ Makes the abstract phase-level finding ('cache reads dominate, spikes come from new-content actions') concrete and mechanistically legible -- it shows, rather than just states, that accumulated context is a slow-burning cost while the agent's own choices about what to newly ingest are what spike any given round. - The full worked in-context example embedded in the self-prediction system prompt (Appendix C.2): a synthetic SWE task about a version-comparison bug across a 50+ file codebase, walked through step by step (explore, read, test, estimate) and ending in a fully itemized JSON token-budget breakdown by phase.
→ Implicitly demonstrates the authors' own hypothesis about what 'good' self-prediction reasoning should look like -- systematic phase decomposition grounded in actual tool use -- and its presence/absence (tested in Appendix D) is used as evidence that demonstration improves calibration without eliminating the underlying underestimation bias.
Questions addressed
- ✅ Where do AI coding agents spend their tokens?
Overwhelmingly on accumulated, cache-read input context, concentrated in the Explore and Fix phases (about two-thirds of all rounds combined); output tokens matter mainly during Setup (planning) and parts of Fix/Validate/Closeout (code generation, summaries). - ✅ Which models are more token-efficient?
GPT-5 and GPT-5.2 achieve strong accuracy at comparatively low token cost; Claude Sonnet-4/4.5 and Qwen3-Coder-480B operate in a higher-cost regime; Kimi-K2 is the clear outlier on both highest cost and lowest accuracy. This ranking is stable across shared success and shared failure task subsets, i.e., it is a property of the model, not the task mix. - ⭕ Can agents predict their own token consumption before executing a task?
Partially: self-prediction captures coarse relative trends (weak-to-moderate correlation, up to 0.39) but is unreliable at the instance level and systematically underestimates real cost -- the authors explicitly conclude this remains 'a genuinely difficult task' and 'an open problem', not something they claim to have solved. - ⭕ If cost estimates are used operationally (budget alerts, tiered pricing, early-stop triggers), how should the systematic underestimation bias be handled so users aren't blindsided by bills exceeding the alert threshold?
Not addressed. The paper documents the underestimation bias thoroughly (Fig. 11, Appendix D) but never proposes or evaluates a calibration correction, safety margin, or conformal-prediction-style interval that would make the biased point estimate usable for an actual budget-alert product.
Gaps
- incompleteThe entire study uses a single agent harness (OpenHands) and a single benchmark (SWE-bench-Verified). The headline claim that token efficiency is 'an inherent characteristic of the model' (stable across shared success/failure subsets) is only shown to be task-invariant within one harness -- it is not shown to be harness-invariant. Whether Kimi-K2's outlier inefficiency is a property of Kimi-K2 itself, or of the specific way OpenHands' prompting/tool-calling interacts with Kimi-K2, is left untested; this is the mirror image of a gap already flagged against a different corpus benchmark (the Almedra GLM benchmark, which varies harness while holding the model fixed and never tests the reverse).
Read next: Look for (or run) a study that benchmarks the same set of models across multiple harnesses (Claude Code, Cursor/Aider, OpenHands, a bare ReAct loop) on the same SWE-bench subset, to separate model-intrinsic token efficiency from harness-model interaction effects. - incomplete'Redundant' file view/edit actions are operationalized purely as repetition counts (viewing or modifying the same file more than once), with no independent check on whether any given repetition was actually unnecessary. A model re-reading a file because its context window evicted or compacted the earlier read is a mechanically different failure mode (context management / caching mechanics) from a model aimlessly re-exploring because it hasn't found the bug -- the paper's causal story ('redundant back-and-forth... reflecting inefficient search dynamics') doesn't distinguish these, even though they would call for entirely different fixes (better context retention vs. better search strategy).
Read next: Look for work that instruments *why* an agent re-opens a file (context eviction vs. genuine re-exploration) rather than just counting repeats -- likely to intersect with this corpus's context-rot / context-engineering material. - incompleteGiven the well-documented, consistent underestimation bias in self-predicted token costs, the paper never tests the cheapest possible fix: applying a simple learned or fixed calibration multiplier to each model's raw self-estimate. Before concluding that 'making [self-prediction] reliable... remains an open problem,' a post-hoc calibration check would show how much of the practical problem a near-zero-cost correction already resolves.
Read next: Read follow-up work on calibration of LLM confidence/self-estimates (Kadavath et al. on 'language models mostly know what they know', cited in this paper) for whether simple recalibration closes most of the underestimation gap. - incompleteThe entire cost-decomposition analysis (Sec 5, Fig. 8-9) fixes the Anthropic cache-creation rate at the 5-minute write tier for all reported figures. Cache-write TTL is a pricing-policy choice, not an inherent property of the task -- a 1-hour cache tier (which Anthropic also offers) would materially shift the reported cost split between cache-creation and cache-read, and potentially which phase looks most expensive. The paper presents its cost breakdown as if it reflects an inherent property of agentic coding tasks, when part of it is actually an artifact of the specific cache-tier choice made for the study.
Read next: Re-run the same phase/round cost decomposition (Sec 5.2-5.3) under the longer 1-hour cache-write tier to see how much of the 'cache reads dominate' finding is robust to the pricing-tier choice versus an artifact of the 5-minute TTL selected here. - incompleteThe study is scoped entirely to coding tasks. Whether the central mechanistic finding -- that long-horizon, tool-using agents accumulate cost primarily through re-fed cache-read input context rather than output generation -- generalizes to non-coding long-horizon agents (research agents, browsing agents, ops/on-call agents) or is specific to code's characteristic re-read/re-edit access pattern on a small number of files is not discussed, despite the paper's own framing ('originally developed mainly for coding tasks... increasingly used in a wide range of tasks and domains beyond coding') explicitly raising and then dropping the question.
Read next: Look for equivalent token-consumption breakdowns on non-coding agentic benchmarks (deep-research agents, browser-use agents, SRE/on-call agents) to test whether cache-read/input dominance is a coding-specific artifact or a general property of long-horizon tool use. - illogicalThe paper's own two headline variance figures disagree in magnitude but are presented as if they tell one consistent 'highly variable' story. The abstract and its most-quoted framing use 'up to 30x' as the run-to-run variance headline; but the paper's actual per-model statistic (Figure 2b: max/min cost ratio, averaged across all 500 instances) is roughly 2x -- 30x is a heavy-tail extremum from a distribution whose typical spread is an order of magnitude smaller. The pricing argument in the Discussion ('token usage... is highly variable and hard to predict') leans rhetorically on the more dramatic 30x figure without acknowledging that the typical case is far tamer, which matters directly for how alarming the pricing-unpredictability conclusion should actually be.
Read next: Re-read Figure 2 and its caption carefully before citing this paper's variance claims elsewhere in the corpus; prefer the ~2x average-case figure over the 30x extremum when assessing how large a problem token-cost unpredictability actually is for typical (not tail-risk) pricing design.
Closes gaps elsewhere
- The Almedra Token-Efficiency Benchmark, Updated For GLM 5.2 · g5 — The gap asks whether a fixed harness's efficiency ranking would hold across multiple underlying models. This paper runs the reverse but complementary experiment -- one fixed harness (OpenHands), eight different models -- and finds the model-level efficiency ranking is stable across shared-success and shared-failure task subsets, i.e. model identity is an independent driver of efficiency separate from task difficulty, partially answering the model-vs-harness disentanglement the gap calls for (though it does not itself vary harness, leaving the harness-invariance direction still open).
- Agentics / Tech Things: Tokenmaxxing is dead, long live tokenmaxxing · g1 — This paper supplies general coding-task benchmark data on the accuracy-vs-cost relationship the gap calls for -- across 500 SWE-bench-Verified problems and 8 frontier models, accuracy peaks at intermediate cost and saturates/declines at the high end, countering an unqualified 'more tokens = better' generalization. The match is not exact: the gap's 'compounding correctness' claim is about iterative agent loops (restarting/re-prompting across iterations), while this paper's cost-quartile comparison is across four independent repeated runs of the same task, not accumulating loop iterations -- so this closes the 'does more spend reliably improve outcomes on general coding tasks' half of the gap without directly testing the loop-iteration mechanism itself.
Related documents
- I benchmarked CC's caveman plugin against 'be brief'. The token math is wild.
- Agentics / Tech Things: Tokenmaxxing is dead, long live tokenmaxxing
- The Almedra Token-Efficiency Benchmark, Updated For GLM 5.2
- GitHub Copilot's Project HydraFusion Promises Frontier Level Performance Through Multi-Model Routing
- GLM-5.2 is the new leading open weights model on the Artificial Analysis Intelligence Index
- The new GPT-5.6 family: Luna, Terra, Sol
- Uber's Zero Growth Stack: Scaling Services, While Optimising Infrastructure and AI Cost
- Agentic Engine Optimization (AEO)
- Google's AlphaEvolve Reaches General Availability with Evolutionary Code Optimization as a Service
- With Android CLI, Google is Making the Android Toolchain Agent-Friendly