From the brainstorm picks of 2026-11-27: 066 radio composer with a segmented footer that fills the widget, 067 rules page list first with a match count, 068 schedules page that edits every cron and timer through the host reconciler, 069 account usage bar with count, calibration, switchable forecast and reset at the reset date, 070 usage explorer with full attribution, estimated cost, cache hit rate and per-turn context. 🎯 Fix: 95 % 💥 Break: 1 % 💸 Tokens: 100 % ⏱️ Velocity: 100 % 🛡️ Security: 100 % 🏆 Score: 94 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.0 KiB
070 - Usage Explorer
User Story
As the operator, I want a Resources view that breaks token use down by skill, tool, subagent, repository, model, agent and account, with cost and cache figures, so that I can find what costs the most and cut it.
Decisions (operator-confirmed 2026-11-27; do not re-litigate)
-
Attribution in the sampler (operator): the host sampler (
orchestrator/client/resources.py) tags each assistant message's usage with:skill: the last Skill call earlier in the same session,""before any;tool: the tool_use names in that message,""for text;subagent: the agent type of a sidechain transcript,""for the main thread;repo: the base name of the session's git top-level;- plus
model,agentandaccountas today.
Rows stay hourly, keyed by every dimension. Rejected: reusing the reports only (no skill dimension).
-
Usage view (operator): a new Resources panel. Group by one dimension (skill, tool, subagent, repo, model, agent, account, hour, day); filter by period and by any dimension's value; columns input, output, cache read, cache write, total, share, est. $, cache hit rate; sortable; clicking a row filters to it.
-
Cost estimate (operator): one price file per model family (input, output, cache read and cache write per million tokens, with its date); the column is labelled "est."; an unknown model shows "–".
-
Context per turn (operator, "everything capturable"): per agent and day, the median and p90 context per turn (input plus cache read) and the number of compactions, from the same scan.
-
Bounded: per hour at most 50 values per dimension; the rest fold into
(other). Retention as the existing token rows. -
Host only, names and counts only: no prompt or tool input text is stored.
Approach
flowchart TD
subgraph P["🧭 0 · Preparation"]
P1["📋 Write requirement"] --> P2{"✅ Operator approves?"}
P2 -- "✏️ corrections" --> P1
end
P2 -- "🤖 yes" --> A1
subgraph A["🔬 A · Sampler"]
A1["🏷️ Skill, tool, subagent, repo tags"] --> A2["📏 Context per turn, compactions"]
A2 --> A3{"🧪 Unit and integration green?"}
A3 -- "🔴 no: fix" --> A1
end
A3 -- "🟢 yes" --> B1
subgraph B["📊 B · Usage view"]
B1["🧮 Group, filter, sort API"] --> B2["💲 Est. cost, cache hit rate"]
B2 --> B3["🖥️ Panel with drill-down"]
B3 --> B4{"🧪 E2E green at 1920, 1366, 390?"}
B4 -- "🔴 no: fix" --> B1
B4 -- "🟢 yes" --> BF{"💬 Operator feedback on screenshots?"}
BF -- "✏️ changes" --> B1
end
BF -- "👍 fits" --> D1["🏁 Review, commit with operator OK, hand-over"]
Acceptance Criteria
Sampler
- A fixture transcript with a Skill call followed by two assistant
messages tags both with that skill; the messages before it carry
"". - A message with two tool_use blocks counts under each tool name once.
- A sidechain transcript's tokens carry its agent type; the main thread's
carry
"". - A 51st skill value within one hour lands in
(other). - No row holds prompt text: a fixture's secret marker string appears in no output file.
API and view
GET /api/usage?group=skill&since=<t>answers rows with the eight columns; totals equal the sum of the token rows.- Est. $ for a fixture model equals the hand-computed price; an unknown model gives null.
- Cache hit rate = cache read / (input + cache read) per row.
- The panel's group select, period select and row click filter as described; sorting by est. $ orders descending.
Tests
- Unit:
- Tagging, folding, price and hit-rate arithmetic in
tests/test_usage.py.
- Tagging, folding, price and hit-rate arithmetic in
- Integration:
/api/usagethrough the handler on fixture token rows.
- E2E:
tests/e2e/test_resources_usage_e2e.py: group switch, drill-down, screenshots at 1920, 1366 and 390.