feat(agent): fill Skills/MCP/Rules categories in context breakdown#2357
Draft
k11kirky wants to merge 1 commit into
Draft
Conversation
This was referenced May 25, 2026
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced May 25, 2026
b68e4e4 to
ebe1dbc
Compare
923dacd to
08d0f9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
The context breakdown displayed in usage updates was missing accurate token estimates for the Rules (CLAUDE.md), Skills (slash commands), and MCP tools categories. These were left at zero even when content was present, making the breakdown unreliable for understanding what's consuming context.
Changes
Three new estimator functions were added to
context-breakdown.ts:estimateRulesTokens— reads the raw CLAUDE.md content and estimates its token contribution to the system prompt.estimateSkillsTokens— estimates tokens for the slash-command list (name, description, hint) injected by the SDK.estimateMcpTokens— estimates tokens for connected MCP tools based on their name and description.A
readClaudeMdQuietlyhelper reads CLAUDE.md from the project root at session initialization, falling back toundefinedon any IO error, so the rules estimate is populated from the start.A
getCachedMcpToolsfunction was added totool-metadata.tsto expose a snapshot of the current MCP metadata cache for use by the estimator.A
updateBreakdownCategorymethod was introduced onClaudeAcpAgentto safely patch a single key of thecontextBreakdownBaselinewithout clobbering other fields. It is called after slash commands are fetched and after MCP tool metadata is loaded, so the baseline stays current as those values become available.How did you test this?
Unit tests were added for all three new estimator functions covering zero/empty inputs, positive token counts, and scaling behavior. Existing
buildBreakdowntests continue to pass.Publish to changelog?
No