feat(token-burden): respect active tool set in tool definitions burden#2
Open
w-winter wants to merge 1 commit intoWhamp:mainfrom
Open
feat(token-burden): respect active tool set in tool definitions burden#2w-winter wants to merge 1 commit intoWhamp:mainfrom
w-winter wants to merge 1 commit intoWhamp:mainfrom
Conversation
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.
The tool definitions section previously called
pi.getAllTools()and counted every registered tool equally, even though extensions (e.g. the plan-mode and tools example extensions that Pi ships with that ships with) can usepi.setActiveTools(...)to disable tools at runtime (and pi excludes those disabled tools' descriptions from the system prompt). This meant the reported token burden for tools could be significantly overstated compared to what actually hit the context window.The tool burden view now cross-references
pi.getAllTools()withpi.getActiveTools()so only active tools count toward the section total. Inactive tools still appear in the drilldown with colored status icons (green●active, red○inactive) and a legend, matching the visual treatment skills already get for their on/hidden/disabled states, so we can see what's been deactivated and what it would "cost" if re-enabled.Summary of changes:
buildToolDefinitionsSectionaccepts anactiveflag per tool; inactive tools get 0 tokens/chars but remain as visible drilldown childrenactivestate by diffingpi.getAllTools()againstpi.getActiveTools()before building the sectionactive?: booleantoPromptSectionchildren andTableItemso the state threads through the full data pipeline●/○status icons with green/red coloring inrenderTableRow, add anactive / inactivelegend at the bottom of the tool drilldownactivethroughbuildTableItemsso drilldown children carry the distinctionTool definitions (N active, M inactive)when any tools are inactive,Tool definitions (N active)otherwiseactiveproperty propagation, and section label formatting