Dispatch counter
Every Agent dispatch is logged by a PostToolUse hook (agent name, the model param, CLAUDE_CODE_SUBAGENT_MODEL and its FORCE flag when set, the session model, and the model the dispatch actually ran on when the mod recorded it - nothing else) to ${CLAUDE_PLUGIN_DATA}/dispatches.jsonl, which is ~/.claude/plugins/data/<id>/. History moved over from older versions sits beside it in dispatches-legacy.jsonl and is read together with it. The log is self-pruned to 30 days, kept across plugin updates and deleted when you uninstall the plugin. Stats show how much work routing actually kept off your session model - real counts, not invented dollar savings:
/model-routing:stats
# in-chat report: per-agent dispatch breakdown + real token volume per model.
# Dispatches that ran on a higher tier than the session get their own section,
# "Ran ABOVE the session tier"
/model-routing:stats --days 1
# today's slice; --days N sizes the window (default 7)
/model-routing:stats --days 7 --ago 7
# the week before last week's end - before/after comparison when you
# tune routing (dispatch history reaches 30 days back; token history as
# far as Claude Code keeps transcripts)
/model-routing:stats --session fable
# only sessions that ran on your default model - useful when a
# fallbackModel ladder or manual /model switches mix tiers into one
# window and you want the numbers for your normal setupnode "<plugin>/hooks/dispatch-counter.mjs" stats
# routed-down: 14 today · 92 7d (one-liner for status lines)
node "<plugin>/hooks/dispatch-counter.mjs" tokens
# token volume per model from subagent transcripts (7d), with the share
# that ran BELOW its own session's model - fable days and opus days are
# each judged against their own baselineCoverage note: dispatch counts see Agent-tool dispatches only (the hook matches Agent|Task); Workflow-spawned agents never pass through that tool, so they are invisible to the dispatch report - but tokens reads their transcripts (nested under subagents/workflows/) and counts their volume against the parent session like any other subagent.
The dispatch report
Each dispatch is judged against the session model it was dispatched from: ran cheaper, ran at the session tier, ran above it, or not comparable (a model or session family the tier table does not know). The model a dispatch ran on is the one the mod recorded when it applied the automatic default or saw the pin; without that record the report reconstructs it in the harness order: model param, frontmatter pin, CLAUDE_CODE_SUBAGENT_MODEL, session model. CLAUDE_CODE_SUBAGENT_MODEL_FORCE overrides every param and pin, and those rows read agent (forced=...).
A pin is not a cap. A pinned agent runs its pin on any session model, so a reviewer on a sonnet session shows up in "Ran ABOVE the session tier", counted, with nothing hidden. That section is descriptive: it says what ran where, and leaves the judgment to you.
The by-agent section
report counts dispatches; tokens weighs them. A dispatch is one line in a log whether it processed four thousand tokens or four million, so a count ranks by how often something happened and never by how much it cost. tokens names the agent behind each slice of volume:
By agent - which role processed the volume:
304.0M (49%) model-routing:implementer 24 agents on sonnet-5, opus-5
59.8M (10%) model-routing:reviewer 28 agents on sonnet-5, fable-5, opus-5
15.3M (2%) codex:codex-rescue 11 agents on sonnet-5Neither report is the authority on everything. What model ran, and how much it processed - only the transcripts know that. What was asked for - only the log knows that. Both sides stamp the session at dispatch time: the log writes the model it is on when the dispatch fires, and the transcript side matches the agent's sidecar toolUseId back to the assistant line that dispatched it and takes that line's model, falling back to the model in effect at the agent's launch and then to the transcript head. So a mid-session /model switch moves both reports together. Read a disagreement as each report describing the half it can see.
Attribution comes from agent-<id>.meta.json, the sidecar Claude Code writes beside every subagent transcript, which names the agent type the usage lines omit. It is not a documented interface, so every field is treated as optional: a sidecar that is missing, unreadable, or names no type drops its transcript out of this section only, and the count of those is printed. Every other total in the report is computed from the transcripts alone and is unaffected. Per-subagent token accounting has been requested and closed as not planned upstream, so the sidecar is currently the only route to this.
Foreign agents this plugin already knows
The dispatch report resolves an agent's pin through the bundled agents, your own agents in <config>/agents (read from their frontmatter) and FOREIGN_AGENT_PINS, a small hand-curated map of other plugins' agents to the model their own frontmatter pins - codex:codex-rescue to sonnet, two caveman agents to haiku. Nothing reads another plugin's files at runtime; each entry is added by hand after that exact agent is seen causing a wrong verdict. The table stays deliberately small: discovering every installed plugin's agents would mean walking ~/.claude/plugins/cache on every report, for agents that may never be dispatched bare in your logs.
The cost line
tokens also prices the volume it just counted, because tokens need translating and dollars do not. Sample output - the window rolls daily, so your figures will differ:
At API list prices (rates as of 2026-09-09), this is what the volume above would have cost on the Claude API:
as it ran $2,380
had every subagent inherited its session model $4,417
difference $2,037
main sessions, same rates (not routable) $15,599Read it as a counterfactual, which is exactly what it is: on a subscription you pay none of this, and the difference carries the same assumption as the volume figures above - that every subagent would otherwise have inherited the session model, which agents pinned by other plugins would not.
The arithmetic is per token type rather than per token, because they are priced an order of magnitude apart: base input at the model rate, cache reads at 0.05x on Opus 5.5 and Sonnet 5.5, 0.025x on Fable and Mythos 5.2 and 5.1, 0.1x elsewhere, five-minute cache writes at 1.25x, one-hour writes at 2x, and output at its own rate. Haiku 5.5 prices each request on its own card: above 100K prompt tokens, cache reads and writes included, the whole request bills at $0.50/$2.50 instead of $0.10/$0.50. Cache reads dominate real transcripts, so a flat volume multiply would overstate the bill several times over. Transcripts break cache writes down by TTL; a line carrying only a total is charged at the cheaper five-minute rate.
Several documented modifiers push these figures DOWNWARD, so treat them as conservative rather than optimistic. Models from Opus 4.7, Sonnet 5 and Fable 5 onward use a tokenizer producing roughly 30% more tokens for the same text than Sonnet 4.6 and earlier, so re-pricing a cheap model's token count at an expensive model's rate understates what that work would really have cost there. Nothing in a usage line reveals whether fast mode (double rates on Fable 5.2, Mythos 5.2, Opus 5.5, Opus 5 and Opus 4.8) or US-only inference (1.1x from 4.6 onward) applied, so neither is added. And a model absent from the price table is excluded from every figure and declared on its own line, never counted as free - a window where nothing can be priced prints that declaration instead of figures, because silence would read as "this cost nothing".
The rates are first-party Claude API list prices; Bedrock and Google Cloud bill separately and are not modelled.
Prices are transcribed from the Anthropic pricing page and stamped with the date, which is printed beside the figure. One model on that table changes rate on a calendar date, so a window is priced at the rates in effect at its end rather than at today's. Before quoting a number anywhere, check the stamp against the current page.
Embed the one-liner in your status line by appending the command's output to whatever your statusLine.command already prints. Delete the .jsonl any time to reset; a missing file just means zero.
Smoke tests for the counter: node --test hooks/dispatch-counter.test.mjs. The cost line above the prompt has its own test, hooks/band.test.ts, which runs only under claude plugin test .; CI has no Claude Code CLI, so run it locally before changing hooks/register.mjs or hooks/lib/.