
A coding agent can look productive long before it produces value. It searches the repository, opens files, reads tests, forms a hypothesis, edits code, runs a command, studies the failure, and tries again. Every step consumes tokens and compute, but none guarantees a useful result. The patch may fail, be rejected, or solve the immediate problem while creating maintenance, security, or operational risk elsewhere.
Cost accumulates throughout the attempt, while value appears only after the change is validated and accepted. That is why an AI coding agent often becomes expensive before it becomes useful.
The cost arrives before the outcome
A code assistant usually responds to a prompt. A coding agent performs a sequence of actions. It interprets the task, searches the repository, inspects files, develops a hypothesis, modifies code, runs tests, interprets the results, and revises its approach.
Bai et al. (2026) analyzed coding-agent trajectories from eight frontier models using OpenHands and SWE-bench Verified. In that experimental configuration, agentic coding consumed an average of 4.17 million counted tokens per task. Code chat averaged 3,390 tokens, while single-round code reasoning averaged 1,190.
Those figures are not a forecast for every enterprise agent; token accounting, caching, harness design, and task complexity vary. The more important finding is where the consumption came from.
Earlier prompts, model responses, file contents, and tool results were repeatedly carried into later rounds. Input tokens outnumbered output tokens by more than 150 to one. The agent was not primarily spending resources writing code. It was spending resources determining what code to write. Exploration and fixing represented nearly two-thirds of the rounds studied. That work is necessary, but it also compounds. When an agent opens another file, adds a test log, or runs a verbose command, that information may remain in the trajectory and be processed again later. A larger context window does not solve this problem. It allows the agent to retain more information, but it does not ensure that the information remains relevant. Capacity is not judgment.
The same study found that token consumption for an identical task could vary by as much as 30 times across runs. More spending did not produce steadily better outcomes. The most expensive runs showed more repeated file views and modifications.
Some repetition is reasonable after a failed test. The problem is repetition without new evidence. When an agent searches the same area, edits the same file, or reruns the same command without changing its hypothesis, activity substitutes for progress.
Even a completed patch is not yet realized value. Baumann et al. (2026) analyzed thousands of recorded coding-agent sessions and found that only about 44% of agent-produced code survived into user commits. The finding exposes an important gap: code can be generated, billed, and counted without becoming part of the product.
Generated lines, completed sessions, and token consumption are adoption measures. The more meaningful unit is the cost of a change that is correct, reviewable, accepted, and able to survive production use.
Enterprise scale changes the economics
This distinction matters more when agentic capabilities move from isolated pilots into the broader engineering environment.
JPMorganChase provides a useful example of that transition. Its internal LLM Suite reached 200,000 onboarded users within eight months, and the firm described the next phase as connecting generative AI with internal data and workflows so agents could complete sequences of actions toward a goal (JPMorganChase, 2025).
By 2026, the firm described agentic AI as increasingly adopted across its engineering workforce. Global Chief Information Officer Lori Beer emphasized reimagining the full product-development lifecycle, matching the right model to the right task, and balancing security, resiliency, and cost-effectiveness (JPMorganChase, 2026).
That is the leadership question behind broad agent adoption: once agents become widely available, how does an organization prevent access from becoming uncontrolled consumption?
An inefficient run may be a small expense during a pilot. Across thousands of developers and tasks, repeated searches, oversized context, poorly matched models, and uncontrolled validation loops become an operating-model problem.
Providing access is an adoption decision. Building the system that makes access useful is an engineering decision.
Engineer the trajectory, not only the model
Organizations may respond to rising agent costs by choosing a cheaper model or imposing a global token limit. Both can help, but neither addresses the complete problem.
A coding agent is a system. Its behavior is shaped by the model, harness, repository instructions, context policies, tools, validation strategy, and stopping rules. Cost is therefore a property of the full trajectory, not merely the price of the model.
The first control is task and model routing. A frontier model should not be the default for every repository search, documentation update, test repair, or small refactor. The task should determine the model, tool access, context allowance, and approval requirements.
The second control is better repository guidance. Lulla et al. (2026) found that adding an AGENTS.md file was associated with lower median runtime and output-token use in their experiment. The study was limited and does not prove that repository instructions universally improve code quality, but it supports a practical principle: explicit knowledge can reduce trial-and-error discovery.
Agents should know where major components live, how to run focused tests, which architectural rules matter, and which areas they must not modify. The objective is not to give the agent more context. It is to reduce how much context the agent must rediscover.
The third control is a lifecycle for context. Agent trajectories are often append-only, even when an early hypothesis has been disproved or a large tool response has already been summarized. Xiao et al. (2026) showed that removing useless, redundant, and expired information could materially reduce input tokens and computational cost while maintaining measured performance.
The goal is the smallest context that preserves the evidence needed for the correct decision.
The fourth control is progress-aware stopping. A global budget cannot distinguish productive investigation from a loop. Instead, each expensive step should produce something new: a narrower scope, a stronger hypothesis, a failing test, a validated assumption, or a confirmed fix. When several attempts produce no new evidence, the agent should summarize what it knows and stop or escalate.
The final control is measurement. Resolve rate alone treats a focused five-step repair and a wasteful fifty-step repair as equivalent. Teams should also examine cost per accepted change, time to the first relevant file, repeated-action rate, review effort, rework before merge, and defects or rollbacks after deployment.
The goal is not the cheapest possible run. A cheap patch that is wrong or transfers substantial work to the reviewer is not efficient. Efficiency is the amount of validated engineering value produced for the resources consumed.
AI coding agents get expensive before they get useful because the enterprise pays for every step in the attempt while receiving value only from the accepted outcome. The answer is not to eliminate exploration or impose arbitrary limits. It is to engineer the trajectory so each costly step reduces uncertainty and moves the work closer to validation.
Giving developers access to agents is the beginning of adoption. Making those agents observable, bounded, and accountable for useful outcomes is the beginning of engineering.
References
Bai, L., Huang, Z., Wang, X., Sun, J., Mihalcea, R., Brynjolfsson, E., Pentland, A., & Pei, J. (2026). How do AI agents spend your money? Analyzing and predicting token consumption in agentic coding tasks. arXiv. https://arxiv.org/abs/2604.22750
Baumann, J., Padmakumar, V., Li, X., Yang, J., Yang, D., & Koyejo, S. (2026). SWE-chat: Coding agent interactions from real users in the wild. arXiv. https://arxiv.org/abs/2604.20779
JPMorganChase. (2025, June 3). LLM Suite named 2025 “Innovation of the Year” by American Banker. https://www.jpmorganchase.com/about/technology/blog/llmsuite-ab-award
JPMorganChase. (2026, June 15). Innovation for business impact: Key takeaways from JPMorganChase’s 11th Innovation Week. https://www.jpmorganchase.com/about/technology/blog/key-takeaways-from-innovation-week-2026
Lulla, J. L., Mohsenimofidi, S., Galster, M., Zhang, J. M., Baltes, S., & Treude, C. (2026). On the impact of AGENTS.md files on the efficiency of AI coding agents. arXiv. https://arxiv.org/abs/2601.20404
Xiao, Y.-A., Gao, P., Peng, C., & Xiong, Y. (2026). Reducing cost of LLM agents with trajectory reduction. Proceedings of the ACM on Software Engineering, 3(FSE), Article FSE056. https://doi.org/10.1145/3797084
The views expressed here are my own and do not represent JPMorganChase.