Cuewire

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:

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

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.

On each machine with agents, the agents write their own logs. The Cuewire daemon there reads them and keeps the counts until the app takes them. Every 15 seconds, the Cuewire app on your computer takes them over the connection it already holds. It ties each call to its project, layer, task and role. It saves them in the statistics store, which the Statistics sheet reads. Each machine with agents this PC, an SSH host, a WSL distribution The agents' own logs Claude Code, Codex, Copilot, Gemini counts of each call Cuewire daemon keeps counts until the app takes them every 15 s, over the connection the app already holds Your computer Cuewire app ties calls to project, layer, task, role Statistics store a database in your data folder Statistics sheet Summary · Layers · Tasks · Trend
Your own computer is one of the machines: its daemon reads the agents that run there. The app does the attribution, so records from two machines meet in one place.

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:

  1. Session to terminal. The agent's hooks report its session id from the terminal it runs in.
  2. 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.
  3. 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.

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

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.

How Cuewire decides that a layer is merged. If you marked it, your mark stands. A layer with no changes of its own stays open. If its branch is in the branch it came from, it is Merged. If its pull request is merged, it is Merged (PR); an open one leaves it Open. Otherwise it looks for a squash: a commit with the same change id, which git merge-tree must confirm, and which must pass every guard. Then it is Merged (squash); any no on that path leaves it Open. Marked by you? yes Your mark no Changes of its own? no Open yes In the branch it came from? or origin's default branch yes Merged no Pull request merged? asked of gh or glab yes Merged (PR) open Open no PR, or closed A commit with the same id? the pre-filter no Open yes merge-tree gives its tree? the confirm, Git 2.40 or newer no Open yes Every guard passes? time, copies, twins, claims no Open yes Merged (squash)
Cheap checks first, and the squash route last. An open pull request means not merged yet, whatever a commit holds. A merge once found is kept, unless you mark the layer otherwise.

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:

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.

Sample data. The Summary tab of the Usage statistics sheet for the project web-app over 30 days. Tiles: Total cost $8.88 at API list prices; Tokens 10.6M (278k in, 234k out, 9.7M cache read, 347k cache write); Cost per merged layer $4.44 (5.3M tokens each, 2 merged); Tokens per changed line 18k (399 output tokens per line); Waste share 2%; Rework share 3%; Cache hit rate 94.0%; Coverage 100% (64 of 64 turns had usage). Below, daily token bars with an Off band and a bar of where tokens went. Then rows by role, by agent and model, and by layer.
Sample data. The Summary tab: one tile per figure and tokens per day, with an Off band. Below, where tokens went and the split by role, model and layer.

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.

Sample data: share of tokens and share of cost by kind. Input: 2.6% of tokens (278k), 11.3% of cost ($1.00). Output: 2.2% of tokens (234k), 48.4% of cost ($4.30). Cache read: 91.9% of tokens (9.7M), 21.9% of cost ($1.95). Cache write: 3.3% of tokens (347k), 18.4% of cost ($1.63). Total: 10.6M tokens, $8.88 at API list prices. share of tokens share of cost Input 2.6% · 278k 11.3% · $1.00 Output 2.2% · 234k 48.4% · $4.30 Cache read 91.9% · 9.7M 21.9% · $1.95 Cache write 3.3% · 347k 18.4% · $1.63 Sample month: 10.6M tokens, $8.88 at API list prices
Sample data, by kind of token. Outlined bars are the share of tokens, filled bars the share of cost, at list prices for the sample's two models.

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.

Sample data. The Layers tab: Payment webhook, Merged (PR), 17 tasks, $3.29, Builder 92%, 127 lines, 34k tokens per line; Search filters, Open, 17 tasks, $2.54; Checkout page, 6.9% approximate, Merged, 17 tasks, $1.88, 460 lines, 4.6k tokens per line; Base, 13 tasks, $1.17, Orchestrator 100%. Notes say what Approximate means, and that squash merges are found with Git 2.40 or newer.
Sample data. The Layers tab. Checkout page is Approximate: 6.9% of its tokens came from a task whose start was taken from its delivery.

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.

Sample data. The Tasks tab with Bridge tasks chosen. Tasks by role: Builder 26 tasks, 311k tokens on average, median 280k, p95 608k, max 654k, cost average $0.25; Reviewer 24 tasks, 42k tokens, $0.03; Direct conversations 12, 81k tokens, $0.09. Below, each task with when it started, its role, agent, model, status, tokens and cost, the most expensive first.
Sample data. The Tasks tab: tasks by role, then each task. Direct conversations have their own row.

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.

Sample data. The Trend tab: cost per day and tokens per day as bars, with an Off band; Cost per session $1.27 over 7 agent sessions; Tasks that compacted 0; Tasks by peak context use: under 50% 45, 50 to 80% 11, 80 to 95% 4, 95% or more 4.
Sample data. The Trend tab. The shaded days had statistics off.

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.

Sample data. The Usage statistics section of Settings: the Detailed usage statistics switch, turned on, with its caption; Each call kept for 90 days; Daily totals kept for 365 days; and the project web-app with Export… and Delete… buttons.
Settings, with sample data: the switch, how long statistics are kept, and each project's Export… and Delete….

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

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.