Your coding agent budget pays for context, not code
Planning and gathering context account for two thirds of agent costs.
Michael Mangus/Aug 25, 2026/8 min readCoding 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.

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.

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.

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
| PR | Title | Scope | Type | +lines | Claude Code | Codex |
|---|---|---|---|---|---|---|
| #28080 | feat: enable microsoft sign ups | cross-cutting | feature | +2600 | $21.16 | $6.42 |
| #28387 | feat(unified-cal): connection-based unified calendar API with CRUD, freebusy, and list connections | cross-cutting | feature | +3522 | $8.67 | $3.82 |
| #27912 | feat: add signup watchlist review mode | cross-cutting | feature | +565 | $7.96 | $2.31 |
| #28129 | fix: correct admin password banner message and auto-sign-out after 2FA enable | cross-cutting | bugfix | +286 | $6.05 | $2.47 |
| #28071 | fix: consolidate booking access checks into doesUserIdHaveAccessToBooking | cross-cutting | refactor | +284 | $5.57 | $2.31 |
| #27922 | feat: enable onboarding-v3 globally and update e2e tests | cross-cutting | test | +61 | $5.43 | $2.36 |
| #28100 | refactor: move `AppList` to features with slot props | cross-cutting | refactor | +104 | $5.39 | $2.03 |
| #27923 | fix: resolve signup watchlist review issues and auto-unlock on SIGNUP entry removal | cross-cutting | mixed | +542 | $4.99 | $2.38 |
| #28176 | feat(bookings): add booking audit logging to instant bookings | cross-cutting | feature | +557 | $4.67 | $2.03 |
| #27896 | feat: add annual plans for teams/organizations | cross-cutting | feature | +297 | $4.45 | $3.15 |
1–10 of 60 pull requests · — marks excluded reference-fetch runs
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
OSS has Changed. So has Dosu.
Aug 23, 2026 / 5 min read
Changes coming to Dosu OSS plan on Sept 1st. ~96% of OSS projects see no change.
How to Build Agent Memory: The Building Blocks of Agent Memory
Aug 21, 2026 / 11 min read
We break down 'Are We Ready for an Agent-Native Memory System?' — the four building blocks of agent memory: storage, extraction, retrieval, and maintenance.
August Drop: Turn your old agent logs into Dosu knowledge
Aug 19, 2026 / 3 min read
Configure Dosu from chat, understand its impact in the app, and find out what your agents read.
Introducing Decant: Insights for your Claude Code and Codex sessions
Aug 12, 2026 / 6 min read
Claude Code and Codex log every session you run. Decant turns those logs into real numbers for what your agents did and how much it cost, without leaving your machine.