feat(tool_search): opt-in deferral for infrequent built-in toolsets - #61744
feat(tool_search): opt-in deferral for infrequent built-in toolsets#61744alexgunsberg wants to merge 1 commit into
Conversation
Extend the existing tool_search/tool_describe/tool_call progressive- disclosure bridge so named built-in toolsets can ride it when explicitly listed in tools.tool_search.defer_toolsets. Default remains empty (core tools never defer). Recommended hot path (terminal/file/web/skills/clarify/todo/memory/code_execution) stays direct when only infrequent toolsets are opted in. Measured on a typical MCP-light install with enabled=on: ~19.9k → ~10.8k tool-schema tokens (~46% reduction) while keeping session tool_defs byte-stable across assemblies.
Duplicate of #60182 ( |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused opt-in design and the default-empty compatibility posture.
Problems
tools/tool_search.py:206reloadsdefer_toolsetsfrom persisted config when a bridge call is dispatched. The active agent’s tools are assembled at initialization (agent/agent_init.py:1159-1163), so a later config edit can make a built-in tool disappear from the model-facing tools array but no longer qualify fortool_describeortool_call. This conflicts with the session-stable toolset/cache invariant inAGENTS.md:19-23.
Suggested changes
- Bind the resolved deferral set to the session tool snapshot and thread it through bridge dispatch and executor unwrapping rather than reloading config on each call.
- Add a regression test that changes effective config after assembly and verifies the original session can still describe and invoke its deferred built-in tool.
This is an automated hermes-sweeper review.
| return False | ||
| # Check registry toolset for MCP prefix. | ||
| if defer_toolsets is None: | ||
| defer_toolsets = load_config().defer_toolsets |
There was a problem hiding this comment.
This reloads persisted config after the session’s agent.tools list has already been assembled. If defer_toolsets changes mid-session, a tool absent from that list can become ineligible for tool_describe/tool_call; please use a session-bound resolved deferral set instead.
|
Closing under Alex's zero-review autonomous delivery policy. Upstream grants this account read-only permission, so the PR cannot be auto-merged. The exact head commit is preserved on the alexgunsberg fork; no review action is requested from Alex. |
What does this PR do?
Tool Search already defers MCP/plugin tools behind
tool_search/tool_describe/tool_call, but built-in toolsets always load. On MCP-light installs the built-in schemas are the entry tax (~15-20k tokens per turn).This adds
tools.tool_search.defer_toolsets: an explicit, default-empty list of built-in toolset names whose tools ride the existing bridge. Zero behavior change unless configured.Why not invent a new mechanism?
Six open PRs already approach this (#60182, #43521, #45147, #53193, #42551, #41800). This is a focused rebased variant of the
defer_toolsetsdesign (#60182), with:DEFAULT_CONFIG+cli-config.yaml.examplebuiltinfor opted-in core toolsMeasured impact (MCP-light personal install)
enabled: on+ recommendeddefer_toolsetsRecommended opt-in (keeps terminal/file/web/skills/clarify/todo/memory/code_execution direct; leaves
kanbandirect for workers):Capability catalog BM25 still finds cron, browser, delegation, image, TTS, Cursor, and X-search tools. Assemblies are byte-stable within a session.
Related
Type of Change
How to Test
scripts/run_tests.sh tests/tools/test_tool_search.py tests/test_get_tool_definitions_cache_isolation.py tests/test_model_tools.py -q(87 passed locally)defer_toolsets, classification is identical to mainenabled: on, infrequent core schemas leave the tools array; hot path tools remain direct; bridge can describe/call deferred toolsChecklist