feat(claude): show what fills the context window in the composer meter - #10419
feat(claude): show what fills the context window in the composer meter#10419t3dotgg wants to merge 2 commits into
Conversation
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds a cross-stack Claude context-breakdown feature with a new authenticated RPC, provider SDK call, session recovery path, and interactive composer UI. It also changes an authorization file, so the change warrants human review despite its additive contracts and focused tests. Not approved because:
No code changes detected at Review your spending limits in Billing settings. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
Hovering the context meter in a Claude thread now shows what fills the window: system prompt, system tools, MCP tools, messages, skills, memory files, and custom agents, each with token counts and share of the window. Rows below the list expand to individual MCP tools, memory files, skills, and agents. The data comes from the Claude Agent SDK's getContextUsage, read on demand when the popover opens. Codex app-server reports only aggregate token counts, so the breakdown stays Claude only; the adapter method is optional for that reason. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Knip flagged the unused export. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
de53833 to
17f0c30
Compare
The context meter tells you how full the window is, but not what filled it. When a Claude thread sits at 44% before you type anything, you cannot tell if that is MCP tool schemas, memory files, or the conversation itself.
Hovering the meter in a Claude thread now shows the same per-category breakdown Claude Code's own
/contextcommand renders: system prompt, system tools, MCP tools, messages, skills, memory files, and custom agents, each with a token count and share of the window. Rows below the list expand to the individual MCP tools, memory files, skills, and agents so you can see which one is the offender.How it works
The Claude Agent SDK exposes
query.getContextUsage(), which returns categories, per-tool, per-file, per-skill, and per-agent token counts. A newprovider.getContextUsageRPC routes throughProviderServiceto an optionalgetContextUsageon the adapter. The Claude adapter maps the SDK response to a smallProviderContextUsagecontract. The web meter fetches it when the popover opens and refetches after the next token-usage event.The call is on demand only. It is never issued automatically after a turn, because the SDK's token-count fallback can make extra model requests (#8610).
Why Claude only
Codex app-server reports only aggregate token counts on
thread/tokenUsage/updated(input, cached input, output, reasoning, total) and has no method that returns a per-category or per-tool split. Estimating one client-side from transcript items would disagree with what Codex actually sends. The adapter method is optional so Codex, and any other provider, can add a breakdown later without touching the contract or UI.The SDK's
messageBreakdownfield is skipped on purpose. It sums every API call in the session, so it reads larger than the resident "Messages" slice next to it.Notes
Built with Claude Fable 5.1 in Claude Code.