dashboard: per-tool token attribution chart in run header tooltip #969

Closed
opened 2026-05-08 12:16:20 +00:00 by claude-desktop · 1 comment
Collaborator

User story

As an operator I want to see "what consumed my tokens" — a small horizontal bar chart breaking down a run's token usage by tool kind (Read 41% · Bash 22% · Edit 12% · system 25%) — surfaced in the context-meter tooltip, so I can pick the right intervention (compaction, smaller files, narrower greps) instead of guessing.

Context

Token attribution is documented to be the highest-leverage observability surface for agent loops (Augment Code's writeup). Nobody else surfaces it inline — this is a small differentiator, cheap to ship.

Acceptance criteria

  • Server attributes usage_delta to the in-flight tool call (when one is open) or to "system / model output" (when no tool call is open). Aggregation lives on TaskRecord.usageByTool: Record<ToolKind, ModelUsage>.
  • SSE coalesces updates ≤4 Hz.
  • <TokenAttributionChart> rendered inside the context-window-meter tooltip. Stacked horizontal bar; each segment colored per ToolKind; legend below; sorted by descending share.
  • Top 3 segments labelled inline; rest grouped under "other (N kinds)" with full breakdown on hover.

Out of scope

  • Cross-run aggregation (analytics page) — separate ticket.
  • Cost attribution chart — same primitive, separate concern; can be added cheaply once this lands.

Dependencies

  • Depends on #952 (live token meter — usage_delta).
  • Depends on the two-meter run header ticket.

References

## User story As an operator I want to see "what consumed my tokens" — a small horizontal bar chart breaking down a run's token usage by tool kind (Read 41% · Bash 22% · Edit 12% · system 25%) — surfaced in the context-meter tooltip, so I can pick the right intervention (compaction, smaller files, narrower greps) instead of guessing. ## Context Token attribution is documented to be the highest-leverage observability surface for agent loops (Augment Code's writeup). Nobody else surfaces it inline — this is a small differentiator, cheap to ship. ## Acceptance criteria - [ ] Server attributes `usage_delta` to the in-flight tool call (when one is open) or to "system / model output" (when no tool call is open). Aggregation lives on `TaskRecord.usageByTool: Record<ToolKind, ModelUsage>`. - [ ] SSE coalesces updates ≤4 Hz. - [ ] `<TokenAttributionChart>` rendered inside the context-window-meter tooltip. Stacked horizontal bar; each segment colored per `ToolKind`; legend below; sorted by descending share. - [ ] Top 3 segments labelled inline; rest grouped under "other (N kinds)" with full breakdown on hover. ## Out of scope - Cross-run aggregation (analytics page) — separate ticket. - Cost attribution chart — same primitive, separate concern; can be added cheaply once this lands. ## Dependencies - Depends on #952 (live token meter — `usage_delta`). - Depends on the two-meter run header ticket. ## References - Augment Code: https://www.augmentcode.com/guides/ai-agent-loop-token-cost-context-constraints
Collaborator

🤖 Auto-assigned to dev (heuristic: area:dashboard + body 1530 bytes (≤ 2 KB) — code role). Reply /unassign to reroute.

🤖 Auto-assigned to **dev** (heuristic: area:dashboard + body 1530 bytes (≤ 2 KB) — code role). Reply `/unassign` to reroute.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
charles/claude-hooks#969
No description provided.