BACK TO BLOG

Your coding agent budget pays for context, not code

Planning and gathering context account for two thirds of agent costs.

Michael MangusMichael Mangus/Aug 25, 2026/8 min read

Coding agents have automated a significant chunk of software engineering work. They’ve also become a significant chunk of the budget for engineering teams. Gartner predicts that coding agent costs will exceed developer salaries within 2 years.

We set out to answer a simple question: Where does the money go?

We found that outputting code is a small fraction of a coding agent’s cost. On a sample of real-world engineering tasks, code output was about 26% of the cost on average and as little as 2% for some sessions.

Instead, the majority of time and money is spent planning how to approach the problem, using tools to gather context, and communicating with the person in the driver’s seat. In fact, about half of the dollars spent went to planning and gathering context at the beginning of the session before any code was even output.

These results indicate that more efficient access to context is the highest-leverage way to improve ROI on coding agents.

Research Method

To make sure our data was representative of real work, we gathered a sample of 60 pull requests from cal.diy. We chose that repository because it’s public but still similar to what you might encounter in professional software development; it powered a commercial product until cal.com went closed-source in April 2026.

We had coding agents re-implement the changes in our sample. For each PR, we converted its title and description into a hypothetical ticket for an agent to complete. We rewound the code to reflect its state just before the PR was merged, then asked both Claude Code (running Claude Opus 4.8) and Codex (running GPT‑5.5) to implement the change. In 8 cases, the agent discovered the original reference PR via command line tools and copied it. We excluded these from our analysis, leaving 112 agent sessions in total.

Finally, we ran the logs from those sessions through Decant, an open source tool that analyzes token usage. We evaluated the cost of each agent session using the four token classes measured by Decant: planning, context gathering, communicating, and writing code. In addition, we drew a distinction between “orienting” (all the work the agent does before it outputs any code changes) and “implementing” (the work performed after a line of code has been changed).

We measured the cost of these actions in terms of time spent, raw tokens used, and the actual dollar value of those tokens based on the model’s rate card (including the discounted cost of cache reads).

Results

Time and token costs

Overall, both models read far more than they write. Summed across all tasks, Claude Code generated 0.94M tokens of output but moved 185M tokens of context through its window, meaning that about 198 tokens are read for every one written. Codex read less overall but with the same shape: 0.69M tokens of output against 92M through its window, a ratio of 134 to 1.

Together, planning and context tokens account for 67% of the dollars spent and 65% of the active time when averaged across both agents. Writing code (the edits themselves, plus the build, test, and git commands around them) accounted for 26% of the dollars and 19% of the time.

Stacked bars showing how dollars and active time divide across four activity classes pooled across both agents: by dollars, planning 36 percent, context 31 percent, communicating 7 percent, code 26 percent; by time, planning 51 percent, context 13 percent, communicating 16 percent, code 19 percent

Figure 1. How every dollar and every active minute divides across the four activity classes, pooled across both agents. Planning and context together are about two-thirds of each; writing code is a minority of both.

The two agents differ in their approach. Claude Code uses most of its output tokens planning, which accounted for 50% of the dollars spent. Gathering context took another 29%, with just 13% for code and the rest spent communicating to the user. Measured in terms of time, the breakdown is similar: 48% of active time went to planning and 22% to gathering context, with 21% used to write code.

Codex reasons less and edits more, so by dollars its code share is larger: 35% spent on context, 13% on planning, and 48% on code. By time, though, code is still only 17% of the work done. Its code output is relatively fast, so most of Codex's working time still goes to planning and reading source files.

Orienting vs. implementing

To understand how much up-front work goes into making a change, we split each session into two phases: "orienting" is all the work done before any code is changed, and "implementing" is all the work after the first code edit.

Measured in dollars, orienting is about half the cost of an agent session: 46% of the money is spent before a single line of code is written. Claude Code spends 43% of its dollars orienting, while Codex spends 52%. Codex tends to make its first edit later, but after that its cost is almost entirely code. On the other hand, Claude makes its first edit sooner, but keeps spending tokens on context and planning throughout.

Two horizontal bars split at the first line of code: Claude Code spends 43 percent orienting and 57 percent implementing; Codex spends 52 percent orienting and 48 percent implementing

Figure 2. Where each agent’s dollars fall relative to its first line of code. Both spend roughly half their budget orienting before that edit exists.

Orienting burns tokens faster than any other part of the session because it's primarily making low-latency tool calls for reading context and planning. On average, a session took 4.2 minutes, of which 1.3 minutes were used orienting the agent - approximately 30% of total time spent.

Task scope

Like real engineering work, the tasks in our sample have varying levels of complexity. Some changes require more context to make. We labeled every PR by comprehension scope, which measures how much of the codebase you have to understand to implement the change correctly.

Comprehension scope is not just a matter of how much code is changed in a PR - it's about how much context those changes require. Enabling a feature flag globally and updating its end-to-end tests (#27922, +61 lines) cost Claude $5.43, while a self-contained refactor of nearly the same size (#27972, +59 lines) cost $0.74. The two tasks involve writing about the same amount of code, but the expensive one requires understanding much more of the codebase.

Claude's average session grows from 1.1M context tokens and 1.4 minutes on self-contained tasks to 6.4M tokens and 8.1 minutes on cross-cutting tasks, leading to 4.5× higher costs (from $1.11 to $4.96). Its planning and context costs grow from 71% of spend on self-contained tasks to 81% on cross-cutting ones. Codex reads less context overall, so its bill grows too, but with a gentler slope — from 1.2M context tokens and $1.40 on self-contained tasks to 2.3M tokens and $2.14 on cross-cutting ones, a 1.5× increase.

Task complexity also scales the orienting time. Claude's orienting share holds at about 44% across every comprehension scope, even as the average bill grows 4.5× from self-contained to cross-cutting tasks. Comprehension isn't a fixed startup cost, but a roughly constant fraction of the bill that grows with the job.

Stacked bar chart of Claude's average cost per run by comprehension scope: low self-contained 1.11 dollars, mid local 2.06 dollars, high cross-cutting 4.96 dollars, each split into orienting on the bottom and implementing on top

Figure 3. Claude’s average cost per run by comprehension scope, split into orienting (bottom) and implementing (top). The bar grows 4.5× from left to right while the split barely moves.

See your own context costs

In general, most people view agent evaluation in terms of outcome quality: does the agent get the task done? However, if you want to maximize agent ROI, you need to consider not just the quality of the agent's work, but also its efficiency. Faster, cheaper agents mean more work gets done on the same budget.

To understand how your own agent is spending its time and money, Decant is our open source, local-only token accounting tool that powered this analysis. Try it on your own agent logs:

npx @dosu/decant   # account your own Claude Code / Codex sessions

If you want to take control of your agent spending, Dosu provides knowledge infrastructure for agents that can cut cost and latency in half. It's free for the first 30 days, so try Dosu yourself to see how much more efficient your agents can be.

Appendix: the 60 sampled pull requests

Scope
Sort
PRTitleScopeType+linesClaude CodeCodex
#28080feat: enable microsoft sign upscross-cuttingfeature+2600$21.16$6.42
#28387feat(unified-cal): connection-based unified calendar API with CRUD, freebusy, and list connectionscross-cuttingfeature+3522$8.67$3.82
#27912feat: add signup watchlist review modecross-cuttingfeature+565$7.96$2.31
#28129fix: correct admin password banner message and auto-sign-out after 2FA enablecross-cuttingbugfix+286$6.05$2.47
#28071fix: consolidate booking access checks into doesUserIdHaveAccessToBookingcross-cuttingrefactor+284$5.57$2.31
#27922feat: enable onboarding-v3 globally and update e2e testscross-cuttingtest+61$5.43$2.36
#28100refactor: move `AppList` to features with slot props cross-cuttingrefactor+104$5.39$2.03
#27923fix: resolve signup watchlist review issues and auto-unlock on SIGNUP entry removalcross-cuttingmixed+542$4.99$2.38
#28176feat(bookings): add booking audit logging to instant bookingscross-cuttingfeature+557$4.67$2.03
#27896feat: add annual plans for teams/organizations cross-cuttingfeature+297$4.45$3.15

1–10 of 60 pull requests · — marks excluded reference-fetch runs

1 / 6

All token accounting and pricing in this report is done by Decant, from each tool's own local session transcript. Costs are modeled at standard API rates, so they reflect what an API-billed session would cost rather than any subsidized plan; bucketing rules are documented in Decant's analytics methodology. Sessions are not scored for correctness — these are cost measurements, not a benchmark of which agent works better.

Found this article helpful?

Share it with your network to help others discover valuable insights.

Want more like this? Subscribe via RSS

Related Articles

Ready to transform your workflow?

Join leading organizations using Dosu to automate documentation, streamline support, and empower development teams to focus on building great products.