Ongoing

Agent Spend

Creator · 2026 · 4 min read

Track your AI spend per project, ticket and PR.

Overview

The agent tools already compute the cost of every model response, including subagent conversations, and write it to local session logs. agent-spend reads those logs, sums them into an append-only ledger, and joins sessions to branches and pull requests through git history, so a pull request can carry the line: this shipped work cost this much.

Somewhere in most companies adopting AI there is a finance person asking a simple question: what are we spending on this, and what did it produce? Tooling exists for the first half. Nothing on the market answers the second, because an API call carries no record of the work it belonged to.

The observation this project rests on: the agent tools on my machine already price every model response at the moment it happens and write the figure to local logs, including work run inside subagents. A month of that data came to $7,976.69 across 54 sessions. A hand-checked session matched the reader to four decimal places. No proxy, SDK or billing integration involved; the numbers were already on disk.

What the logs cannot say is which pull request or piece of shipped work the spend belongs to. That join, from session to branch to PR through git history, is the remaining work. It ends with pull requests carrying a cost line, and the spend that joins to nothing broken out with reasons rather than hidden. That unattributed remainder is the part leadership should ask about first.

Writing that came out of this project:

Related Writing