# What AI coding agents cost per pull request, and how to track it

*Track what Claude Code and Codex cost per pull request: what OpenTelemetry gives, tools that attribute by branch or divide, and one Mac's measured figures.*

Dmitriy Solodukha, checked 2026-11-27 · https://caprock.dev/guides/ai-coding-agent-cost-per-pull-request/

No coding agent reports its cost per pull request. Claude Code's
OpenTelemetry export has a cost metric and a count of pull requests, but
nothing links one to the other. Tools that do it either follow each
session's branch to the pull request it became and add up those sessions
(LangSmith, LangWatch, Caprock), or divide total spend by merged pull
requests (Dash0, DX).

**In short**
- **Built in:** cost per request and a pull request count, not joined.
- **Attributed:** a session's branch is matched to the pull request with that
  head branch.
- **Averaged:** total spend divided by merged pull requests.
- **What Caprock adds:** the join done on your machine, per pull request and
  per release, with no account.

## What the agents give you

- **Claude Code's OpenTelemetry metrics.** `claude_code.cost.usage` is an
  estimated cost in USD per API request; `claude_code.pull_request.count`
  counts pull requests it created. They share a session ID, not a pull
  request: no metric carries a branch, and the repository only with
  `OTEL_METRICS_INCLUDE_REPOSITORY=true`. Setup:
  [Claude Code OpenTelemetry](https://caprock.dev/guides/claude-code-opentelemetry/).
- **Claude Code analytics** (Team and Enterprise). Contribution metrics, in
  beta, count pull requests with Claude Code by matching session activity to
  merged diffs; the dashboard shows no cost.
- **ccusage** reports cost by day, session and, for Claude Code, project;
  Codex by day and session. It has nothing per branch or pull request.

## Two ways to put a cost on a pull request

*How each tool puts a cost on a pull request, from each one's own docs, read 27 November 2026.*

| Tool | Method | Needs |
| --- | --- | --- |
| LangSmith | a session's repository and branch, matched to the pull request | its tracing plugins, GitHub or GitLab connected |
| LangWatch | sessions on the pull request's head branch, summed over its life | GitHub connected |
| Dash0 | total spend ÷ merged pull requests an agent assisted | GitHub or GitLab integration |
| DX | total estimated cost ÷ merged pull requests | Data Cloud and a supported AI tool source |
| Caprock | the branch a session pushed and the pull request it opened, on your machine | the desktop app; GitHub for pull request status |

- **Attribution** answers "which pull request was expensive, and why". It
  misses work that never reached a branch, and a session that worked on
  several pull requests has to be split.
- **Division** is one figure for a team and needs no per-session data, but it
  hides the one pull request that cost ten times the rest.

Prices, where each publishes one: LangSmith's Developer plan is free with 5k
base traces a month and Plus is $39 a seat a month; LangWatch's Developer
plan is free with 50k events a month and Growth is €29 a seat a month, and
it can be self-hosted. Dash0 lists a 14-day trial; DX publishes no price.

## What it came to on one Mac

Read from Caprock's own database on one developer's Mac, 29 September to 28 October 2026, at
API list price — what the same work would cost on the API, not a bill:

- **$7.89** per merged pull request, dspv/caprock
- **$3.04** per merged pull request, cybrixcc/caprock-web

**dspv/caprock:** $5,699 over 722 merged pull requests. **cybrixcc/caprock-web:** $589 over 194 merged pull requests.
That is the division method, project cost over pull requests merged in the
window. In the seven days to 16 October 2026, dspv/caprock
merged 45 pull requests for $343.78
of agent cost, $7.64 each, and the dearest one, #720,
cost $71.13 — the spread an average hides. More on these
figures: [FinOps for coding agents](https://caprock.dev/guides/finops-for-coding-agents/#allocate-the-unit-is-a-pull-request-on-a-laptop).

## What Caprock adds: the join, on your machine

Caprock is a free, open-source desktop app for macOS, Windows and Linux that
records every Claude Code, Codex and OpenCode session on the machine, the
ones started in your own terminal included, and prices each turn at list
price as it is written:

- **Session to pull request.** A session's pull requests are found from the
  pull requests it opened and the branches it pushed; a pull request opened
  by a script gets the cost of the one session running a shell command in
  that repository at that moment, or stays unattributed.
- **Shared sessions are split.** A session that worked on several pull
  requests is divided between them and marked *shared*; every session is
  charged once.
- **Per release.** Each release costs what the pull requests it shipped cost,
  and the Pipeline lists the most expensive pull requests and releases.
- **Local.** The join happens on your machine; GitHub is read with your own
  token or `gh` for pull request status and CI.

The Pipeline is part of the free app. Every figure is at API list price, an
estimate rather than your bill.

## Which to use

- **OpenTelemetry into your own backend** — you already run one and will
  write the join yourself.
- **LangSmith or LangWatch** — a team that wants per-pull-request cost in a
  hosted tool, across developers.
- **Dash0 or DX** — one average per team, next to other engineering metrics.
- **Caprock** — your own machine, per pull request and per release, with no
  account; the join is done locally.

## Sources

- [Claude Code docs — Monitoring usage (OpenTelemetry): claude_code.cost.usage, pull_request.count, read 27 November 2026](https://code.claude.com/docs/en/monitoring-usage)
- [Claude Code docs — Analytics: contribution metrics, read 27 November 2026](https://code.claude.com/docs/en/analytics)
- [LangSmith docs — Coding agents: track pull requests, read 27 November 2026](https://docs.langchain.com/langsmith/coding-agents)
- [LangChain — LangSmith pricing, read 27 November 2026](https://www.langchain.com/pricing)
- [LangWatch docs — Coding agents: pull requests, read 27 November 2026](https://langwatch.ai/docs/coding-agents/pull-requests)
- [LangWatch — pricing, read 27 November 2026](https://langwatch.ai/pricing)
- [Dash0 docs — Darkplane: track cost, read 27 November 2026](https://www.dash0.com/docs/dash0/darkplane/insights/track-cost)
- [DX docs — AI cost management, read 27 November 2026](https://docs.getdx.com/reports/ai-cost-management)
- [ryoppippi/ccusage on GitHub, read 27 November 2026](https://github.com/ryoppippi/ccusage)
- [Caprock CHANGELOG — 0.153.0 release cost, 0.157.0 one cost per pull request, 0.158.0 script-opened pull requests, 0.179.1](https://github.com/dspv/caprock/blob/master/CHANGELOG.md)
- [Caprock docs — Pipeline: costs at API list price, shared sessions (docs/app.md)](https://github.com/dspv/caprock/blob/master/docs/app.md)
