Skip to content

feat(token-burden): respect active tool set in tool definitions burden#2

Open
w-winter wants to merge 1 commit intoWhamp:mainfrom
w-winter:feat/active-inactive-tools
Open

feat(token-burden): respect active tool set in tool definitions burden#2
w-winter wants to merge 1 commit intoWhamp:mainfrom
w-winter:feat/active-inactive-tools

Conversation

@w-winter
Copy link
Copy Markdown

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 use pi.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() with pi.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:

  • parser: buildToolDefinitionsSection accepts an active flag per tool; inactive tools get 0 tokens/chars but remain as visible drilldown children
  • index: tag each tool's active state by diffing pi.getAllTools() against pi.getActiveTools() before building the section
  • types: add active?: boolean to PromptSection children and TableItem so the state threads through the full data pipeline
  • report-view: render / status icons with green/red coloring in renderTableRow, add an active / inactive legend at the bottom of the tool drilldown
  • report-view: propagate active through buildTableItems so drilldown children carry the distinction
  • section label: shows Tool definitions (N active, M inactive) when any tools are inactive, Tool definitions (N active) otherwise
  • tests: updated to verify active/inactive token accounting, active property propagation, and section label formatting
  • README: updated tool definitions docs to describe active-tool-aware behavior

ss1 ss2

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.

1 participant