perf(core): defer four low-frequency tools to shrink per-request payload - #4038
perf(core): defer four low-frequency tools to shrink per-request payload#4038tanzhenxin wants to merge 1 commit into
Conversation
Four tools (Monitor, SendMessage, TaskStop, WebFetch) now opt into the existing on-demand discovery mechanism instead of shipping their schemas with every request. They appear in the deferred-tools section of the system prompt and the model reaches them through tool search the first time they are needed — the same pattern already used by the cron, plan-mode-exit, ask-user-question, MCP, and LSP tools. This is a coverage change, not a mechanism change. Each tool also gains a search hint so keyword discovery surfaces it reliably for natural-language queries. The fallback path that eagerly reveals deferred tools when the discovery surface is excluded preserves prior behavior for users who disable tool search.
End-to-end test reportSingle matrix below — pre-implementation column was captured against the global
Test prompts used:
Unit tests: 166 pass across the four tools + tool-registry + tool-search (no snapshot tests were silently invalidated; verified by grep). Build: Net behavior: per-request token payload shrinks by the size of four tool schemas in any session that does not exercise them. Sessions that do exercise them pay one extra discovery round trip the first time each tool is used. |
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
Summary
Validation
Scope / Risk
Testing Matrix
Testing matrix notes:
Linked Issues / Bugs
None.