Skip to content

[Story] Detailed context-usage panel showing per-section token cost #574

Open

Description

@edelauna

Context

Zoo Code shows total token usage in the chat header, but doesn't break down where those tokens go. Users trying to optimize MCP usage have no signal for how much their tool definitions are costing. Once dynamic loading lands, this panel is also how users verify it's working ("attached 30 of 200 tools — saved 8k tokens").

Closes: RooCodeInc/Roo-Code#10238.

Developer Notes

  • Compute per-section token counts at API request build time in `src/core/task/Task.ts`: base system prompt, MCP tool array, conversation history, and any other major sections.
  • Use the same tokenizer already used to compute the total context count — no new dependency.
  • Emit the breakdown to the webview via a new scoped message (e.g. `contextUsageBreakdown`).
  • Add `ContextUsagePanel.tsx` to `webview-ui/src/components/chat/`: collapsed by default in the chat header; expands to show per-section rows.

Acceptance Criteria

  • Per-section breakdown computed at request build time
  • New webview component renders breakdown, collapsed by default
  • Total matches existing top-level token count (no double-counting)
  • Unit test: panel reflects accurate counts for each section

Activity

  1. changed the title [-][Story] W0.4 — Detailed context-usage panel showing per-section token cost[/-] [+][Story] Detailed context-usage panel showing per-section token cost[/+] on Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions