Skip to content
deftpace

What does a coding agent cost per workflow, and how do we measure it?

By Kevin DawkinsPublished 5 min read

In short: Per-seat and per-token figures tell you almost nothing about what coding agents cost. The unit that matters is cost per merged change, counting failed runs and the human time spent on review. In a typical setup, human review is by far the largest part of that cost.

What goes into the cost

Cost components and whether teams usually miss them
ComponentOften missed?
Model tokens: input, output, and cache reads and writesNo, but often not attributed to anyone
Sandbox and compute timeYes
Paid tool calls: search, connectors, APIsYes
Failed and abandoned runsYes. Nothing merged, but you paid for them
Agent code reviewRarely matters. It usually costs well under a dollar per review
Human reviewer minutesAlmost always, and it is usually the biggest line

How to instrument it

  • Route all agent traffic through a single gateway. Teams that make this mandatory get one bill, one budget system and one place to tag requests. Direct vendor subscriptions scatter spend where nobody can see it.
  • Tag every request at the point where traffic is routed. Use workflow, team, task (the ticket or pull request) and app. Add the tags at the gateway or the agent harness, not afterward from logs.
  • Attribute usage that has no API key. Usage through OAuth or personal tokens can show up as zero dollars per person unless it is credited to the token's owner.
  • Stack your budgets by team, project, key and user. Most gateways have no department level, so use tags for that.

How to join cost to outcome

Join cost, by task tag, to what happened to the change:

  • Merged
  • Abandoned: the pull request was closed, or the run failed without opening one
  • Reverted: within a set window, for example 14 days

Cost per merged change runs well above cost per pull request opened. The gap is your abandoned work.

The three numbers to report

  1. Cost per merged change. Also report cost per durable change, which excludes reverts.
  2. Success rate: merged changes divided by total runs.
  3. Time to merge: the median from the start of a run to the merge.

What causes blowups

  • Long contexts. Agent sessions grow toward the model's context limit unless they are compacted. Compact early, at around 200,000 tokens.
  • Cache misses. Cache entries that expire in the middle of a session force expensive rewrites. Ordering prompts so the stable content comes first raises the cached share of input tokens and nearly eliminates first calls with nothing cached.
  • The wrong model for the task. Measure quality on your own evals, then change the default model. This is often the largest single saving.
  • Routing that ignores the cache. Switching models in the middle of a session throws the cache away, which can cancel the saving. The one good moment to route is the first prompt of a session.
  • Loops and misconfiguration. A misconfigured agent in a loop can burn a five-figure sum overnight. Making spend visible on a dashboard is often enough to cut it sharply.
  • Review bots that run on everything. Check where review-bot spend goes. It often runs on changes where it never leaves a comment.

Controls

  • Set a budget per workflow, with an alert that a person watches. An agent that hits its budget and fails quietly while the alert is muted can be down for more than a day before anyone notices.
  • Make hitting a budget limit loud. Failing closed is right. Failing closed and silently is an outage.
  • Route by task type, at the start of a session only.
  • Cap iterations and turns per run, and set a token ceiling per run.
  • Alert at 50%, 75% and 100% of budget, and on unusual spend over a short window.

Worked example

A bug-fix agent over one month. The coding agent runs on Claude Opus 5.5 at medium effort. Every pull request it opens gets an automated first review from GPT-6.2 Sol at its default reasoning effort, then a human review.

List API rates, in US dollars per million tokens
ModelInputCache readCache writeOutput
Claude Opus 5.5 (coding agent)$4.00$0.20$5.00$20.00
GPT-6.2 Sol (reviewer)$2.00$0.10$2.50$10.00
Assumed tokens for one coding run and one review
Token typeTokensRate per millionCost
Coding run (Opus 5.5)
Cache reads1,800,000$0.20$0.36
Cache writes150,000$5.00$0.75
Uncached input50,000$4.00$0.20
Output, including reasoning60,000$20.00$1.20
Per run$2.51
Review (GPT-6.2 Sol)
Input: diff, files touched, and the ticket100,000$2.00$0.20
Output, including reasoning6,000$10.00$0.06
Per review$0.26

About 90% of the input on a coding run is a cache read. That share does most of the work here. With no caching, the same 2 million input tokens would cost $8.00 per run instead of $1.31.

Worked example: a bug-fix agent over one month
LineInputCost
Runs200
Model tokens (Opus 5.5)200 × $2.51$502.00
Sandbox compute200 × $0.40$80.00
Tool calls200 × $0.10$20.00
Pull requests opened140 (60 runs produced none)
Agent review (GPT-6.2 Sol)140 × $0.26$36.40
Human review140 × 15 minutes = 35 hours × $120 per hour$4,200.00
Total$4,838.40
Merged110 (30 pull requests abandoned)
Reverted within 14 days4
Cost per merged change$4,838.40 ÷ 110$43.99
Cost per durable change$4,838.40 ÷ 106$45.65
Machine-only cost per merged change$638.40 ÷ 110$5.80
Success rate110 ÷ 20055%

Human review is 87% of the cost. Halving token spend saves about $2.28 per merged change. Halving review time saves about $19, roughly eight times as much. That is why review rules and cost are the same conversation. The rules are in What review rules should we set for agent-written code?

Takeaway: a cost model to copy

Download as CSV

Cost model: inputs and formulas per workflow
LineInputFormula
RunsRCount of runs tagged with this workflow
Model tokens$tok per runR * $tok
Sandbox computemin per run, $min per minuteR * min * $min
Tool callscalls per run, $call eachR * calls * $call
Pull requests openedPFrom the join to pull requests
Agent review$rev per reviewP * $rev
Human reviewrmin minutes per pull request, $hr per hourP * rmin * $hr / 60
TotalSum of the cost lines
MergedMFrom the join to pull requests
RevertedVReverts within 14 days
Cost per merged changeTotal / M
Cost per durable changeTotal / (M - V)
Success rateM / R
Time to mergeMedian of merged_at - run_started_at

About Deftpace

Deftpace helps engineering and operations teams put agents to work without lowering the bar. Kevin Dawkins builds production agent infrastructure, including the routing and cost tracking described here. Email hello@deftpace.com.