What your agents' work costs: detailed usage statistics
Cuewire 0.1.27 counts what your coding agents use, per project, layer, task and role. It reads the agents' own logs, keeps only the counts, and keeps them on your computer.
This post explains the feature: what it answers, how it counts, and where its figures are exact or not. The screenshots and charts here show sample data, the made-up month the manual's screenshots use. A follow-up post will show real numbers from a real project.
The question it answers
The usage panel has always shown how many tokens your agents used today. That says little once several agents work together on a canvas. You want to know what a feature cost, which role spends the most, and how much went into work that was thrown away.
Detailed usage statistics answer that with a few figures:
- Cost per merged layer. This is the headline. It is the project's whole cost, divided by the layers merged in the range. Failed work, base-layer work and layers never merged stay in the cost, so it says what a merged layer really took.
- Tokens per changed line. The project's tokens, divided by the lines added and removed in merged layers. The output tokens per line are shown beside it.
- Waste share. The share of tokens and cost spent on tasks that failed, were abandoned or were replaced, and on turns you interrupted.
- Rework share. The share spent on tasks that redo earlier work.
- Cache hit rate and context use. How much of each prompt came from the model's cache, and how full each task's context got.
The Summary splits them by role, by layer, and by agent and model. For tasks, the Tasks tab gives the average, median, 95th percentile and largest per role.
Principles
- Off until you turn it on. Counting starts when you do. Tokens used before that are not counted, and nothing is filled in from older logs.
- On your computer. The statistics live in a database in your data folder. Nothing is sent anywhere, and there is no telemetry for it.
- Counts, never content. Cuewire keeps token counts, models, times and the names that tie them together. Prompts, replies and code are never kept.
- Honest labels. A figure that is missing something says At least. A figure that relied on an estimate says Approximate. A dash means there is nothing to show; it never stands for zero.
- API list prices. Cost is what the tokens would cost at each model's list price. That is a yardstick, not your bill.
- Your word wins. Cuewire finds merged layers by itself, but Mark merged and Mark not merged overrule it. Rework is declared by the sender, never guessed.
How it fits together
Agents write logs of their own on the machine they run on. Claude Code, Codex, Copilot CLI and Gemini CLI each log every model call with its token counts. Cuewire's daemon on that machine already reads these logs for the usage panel. While statistics are on, the same reader passes each call on with all its counts.
The daemon also notes what the logs can't say. Which agent session runs in which terminal, when a prompt or a turn starts and ends, and the bridge's task events: sent, delivered, answered, cancelled. These records hold ids, times and counts, never text.
The daemon appends the records to a file on disk. Every 15 seconds the Cuewire app takes them, over the connection it already holds to run that machine's terminals. It saves them first, then tells the daemon to drop them. A remote machine holds counts only until your computer takes them.
Tying a call to its work
A log line says which agent session made a call. It doesn't say which project, layer or task that was. The app works that out, in steps:
- Session to terminal. The agent's hooks report its session id from the terminal it runs in.
- Terminal to project, layer and role. Every Cuewire terminal has an id that names its project, canvas and layer. Its role is the one it had at the time of the call.
- Call to task. When a task reaches an agent, its prompt starts with a banner:
[cuewire] Task … from …. The prompt hook reads that banner and drops the rest of the text.
A task then owns the calls from its start until the agent starts on something else. It also ends with the turn in which the agent answered it. Sub-agents count for the session that started them. Calls between two tasks still count for the project, layer and role.
What you type to an agent yourself is a direct conversation. A run of your own prompts in one terminal counts as one, so a short "yes" doesn't become a task. Direct conversations have their own row and stay out of the task averages.
The app keeps the raw records and runs this join over them, so a late record just re-runs it. When a hook didn't report a task, its start is taken from when it was delivered. That task is marked Approximate. So is any figure with more than 5% of its tokens from such tasks, or from a session reported late.
Rework is not guessed. The sender says so: cuewire ask Builder --rework task-3a-4 "Fix the two findings". Cuewire tells the agents on a canvas to do that when they send rejected work back. --replaces sends a task in place of one still running, which then counts as Replaced.
How counting works
What each log gives
From each model call Cuewire keeps four token counts: input, output, cache read and cache write. It also keeps the model, the time, the tool calls and how full the context was. The vendors count differently, so Cuewire brings them to one meaning: input is the part not read from the cache.
- Claude Code logs input without the cache. Its cache writes come split by how long the cache lives, 5 minutes or 1 hour, which cost differently.
- Codex logs input with the cached part inside it, so Cuewire takes that part out. Its output includes reasoning.
- Copilot CLI logs input with its cache reads and writes inside it. Before 0.1.27 the usage panel added them again and showed Copilot at about twice its real figure.
- Gemini CLI logs input with its cached tokens inside it, and its thinking tokens apart. Cuewire adds the thinking to output.
The price table knows each vendor's cache lifetimes: 5 minutes and 1 hour for Anthropic, 30 minutes and 12 hours for OpenAI. A cache write is priced by the lifetime it was made for.
Counting each call once
Every call gets a key from its own log: Claude Code's message and request ids, or Codex's response id, for example. Reading a log again, after a restart or a crash, adds nothing.
Claude Code writes a reply on several lines while it streams, each with the usage so far. Only the last line has the full output. Cuewire keeps the largest counts seen for a call, and stores the call's full counts, never differences. A copied transcript repeats earlier calls in a new file; the key catches those too.
Codex keeps finished sessions compressed, as rollout-*.jsonl.zst. Cuewire reads those as well. A Codex sub-agent, such as its automatic review, counts for the session that started it.
When a log lacks something
- Calls the transcripts leave out. Claude Code keeps its own count of a session, and it can be higher than its transcripts: titles and compactions, for example. The difference shows as Not in transcripts. It counts for the session's project, layer and role, but no task, so per-task figures are lower bounds.
- Turns without usage. Hooks report each turn. A turn whose usage isn't in the logs lowers the coverage, and totals then say At least.
- Unknown prices. A model missing from the price table has no cost. Its tokens still count, and any cost that leaves them out says so.
- Machines that can't count. A remote computer with an older Cuewire, or with log reading turned off, is named in the coverage list.
Prices
Cuewire carries a table of API list prices, in US dollars per million tokens. It is updated by hand in releases. Each call stores its cost and the table's version.
Once its counts are final, a call keeps the price it was given. A later table doesn't change past figures. A call with no price may get one later.
Coverage
Coverage is the share of turns, per kind of agent, whose usage Cuewire found in the logs. Hooks see each turn start and end, so Cuewire knows how many there were. Below 100%, totals are lower bounds. The Coverage list in the Summary says what is missing and why.
When a layer counts as merged
Cost per merged layer needs to know which layers were merged. Cuewire leaves merging a layer to you, so the statistics look it up every 10 minutes (pull requests once an hour). A layer with no commits of its own never counts as merged.
git merge --squash turns the layer's commits into one new commit, so the layer's branch is never in the target. Ancestry misses a squash merge, and so does the pull request route when there is no pull request. The squash route finds those:
- The pre-filter. Cuewire makes an id of the layer's whole change since it left the target. It is a SHA-256 over each file's header, mode and added and removed lines. Context lines and hunk headers are left out, so a change that moved a little still matches. It makes the same id for each one-parent commit on the target that touches the same files, up to 500 back. A match is only a candidate: two different changes could share an id.
- The confirm.
git merge-tree --write-tree --merge-baseapplies the layer to the candidate's parent. The result must be exactly the candidate's own tree. Git writes the objects to a scratch folder, never to your repository. This needs Git 2.40 or newer. - The guards. The commit must come after the layer's last commit, and must not be a commit the layer copied in. No other layer on the same repository may match it, and no other layer may have claimed it.
- A budget. All this gets at most 4 seconds of git per run, and each layer gets its turn.
When in doubt, there is no answer: the layer stays Open, and you can mark it. A layer found this way shows Merged (squash).
What you see
Press Ctrl+K (Cmd+K on a Mac) and run Usage statistics…. At the top you pick a project and a range: 7 days, 30 days, 90 days or All. It has four tabs.

The Summary holds the figures above, and the Coverage list under them. Every token figure is split into input, output and cache read, and every cost has its tokens beside it.
Where the tokens go, and where the money goes
In the sample month, cache reads are 92% of the tokens but only 22% of the cost. Output is 2% of the tokens and nearly half the cost. The chart works the sample's counts through the price table.
For the sample's two models, a cache read costs a tenth to a twentieth of fresh input. That is why the cache hit rate is on the Summary. It also means a raw token count says little about cost, so the sheet shows both side by side.
Layers
One row per layer, the most expensive first: its tokens, cost and roles, how it ended, and its lines and tokens per line once merged. Choose a layer to mark it merged or not.

Tasks
Per role, the tokens and cost of a typical task: the average, median, 95th percentile and largest. Then each task, with its status, tokens, cost, turns, tool calls and peak context use. One switch narrows the list to the ones that failed, were abandoned or were replaced.

Trend
Cost and tokens per day, cost per agent session, and tasks by how full their context got. A task that came close to the model's limit is the kind that loses detail when its agent compacts.

What is kept, and for how long
The statistics keep counts and the names that tie them together. Those are times, models and agent versions, and sessions, terminals, roles and task ids. They are also project, layer and machine names, and folder paths, which can include your user name. They never keep prompts, replies or code.

- Retention. Each call is kept for 90 days, then added into daily totals. Daily totals, tasks and layers are kept for 365 days. Both take 7 to 3650 days.
- Export. Export… saves four CSV files and a
stats.jsonto a folder you choose, for one project or all. - Delete. Delete… removes one project's statistics. Delete all statistics… removes everything, and connected machines drop what they still hold for this computer.
- Off. Turning statistics off stops the counting. What was counted stays until you delete it, and the off days show as an Off band.
One limit of off: a remote machine that isn't connected when you turn statistics off learns of it when it next connects. What it counted meanwhile is thrown away, never stored.
Each export and delete is written to the audit log.
Limits
- Prices are list prices. A subscription, a discount or a plan's included usage all cost differently. Treat cost as a yardstick between projects and layers.
- Agents with gaps in their logs. Turns whose usage isn't in the logs make totals lower bounds, and the Coverage list says so. Agents Cuewire has no reader for aren't counted.
- Agents started outside Cuewire. An agent you start in your own terminal, in a project's folder, isn't in the figures. The Coverage list says how many tokens such sessions used.
- Rework needs the flag. If nobody uses
--rework, the rework share stays at 0%, however much work was redone. - Squash detection has limits. It needs Git 2.40 or newer, and the layer's branch, unmoved since the squash. It misses an edited squash, one with other changes, and one more than 500 commits back among those touching the layer's files. It also misses a rebase merge of several commits. Mark those by hand.
- One false positive. The same change landed another way, such as copied in by hand, also counts as a squash.
- Twin layers. When two layers make the same change, neither is found merged by a squash. Mark the right one.
- Counting starts when you turn it on. Nothing is filled in from older logs.
Try it
Get 0.1.27 from the download page, or let Cuewire update itself. Open Settings (Ctrl+,, or Cmd+, on a Mac) and turn on Detailed usage statistics under Usage statistics. Then press Ctrl+K and run Usage statistics…, or click Open statistics in Settings.
The manual page, Usage statistics, has every figure and label in detail. A follow-up post will show real numbers from a real project: what its layers cost, and where its tokens went.