Skip to content

feat: per-plugin & per-skill cost attribution#213

Open
vivekchand wants to merge 1 commit intomainfrom
fix/gh-clawmetry-201-plugin-cost-attribution
Open

feat: per-plugin & per-skill cost attribution#213
vivekchand wants to merge 1 commit intomainfrom
fix/gh-clawmetry-201-plugin-cost-attribution

Conversation

@vivekchand
Copy link
Owner

Closes #201

What

Adds a /api/cost-attribution endpoint and a visual cost attribution panel in the Tokens tab that breaks down token usage and cost by tool category (Reasoning, File & Shell, Web Research, Browser Automation, Communication, Sub-Agents, Media & Analysis, System).

How

  • Backend: New @bp_usage.route("/api/cost-attribution") parses session JSONL files and attributes each assistant turn's cost to the tools used in that turn (equal split when multiple tools). Turns with no tool calls are categorized as "Reasoning". Results are cached for 30s.
  • Frontend: SVG donut chart showing cost distribution by category with a legend, expandable per-tool breakdown table. Added to both dark and light theme HTML sections.
  • Tests: 5 new test cases in tests/test_api.py covering endpoint accessibility, response structure, category/tool field validation, and daily breakdown presence.

Categories

Category Tools
Reasoning Text-only turns (no tool calls)
File & Shell read, write, edit, exec
Web Research web_search, web_fetch
Browser Automation browser
Communication message, tts
Sub-Agents sessions_spawn, sessions_send, subagents, etc.
Media & Analysis image, pdf, canvas
System session_status, agents_list, nodes, process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Per-plugin & per-skill cost attribution

1 participant