Tool discovery: list-tools / execute-tool meta-tools (closes #37) - #54
Merged
Conversation
Adds two meta-abilities + a per-agent catalog_mode toggle that lets agents discover and invoke tools on demand instead of declaring every input schema in every system prompt. - openclawp/list-tools — paginated, category-filterable catalog with one-line descriptions. Categories inferred from slug namespace when not set explicitly. - openclawp/execute-tool — dispatches by slug; rejects recursion through the meta-tools. - default_config.catalog_mode (default off → byte-identical legacy behaviour) swaps the tool-list-resolver output for the two meta-tools at resolve time, regardless of how many abilities are in the agent's allow-list. - docs/tool-discovery.md documents the round-trip-vs-tokens trade-off and how to opt in. - Tests: 12 PHPUnit cases (pagination cursor, allowlist, category filter, recursion guard, multi-line description collapse) + smoke checks (ability registration, dispatch round-trip, resolver behaviour with catalog_mode on/off). Caching across turns and a wp-admin toggle are deferred — the resolver re-walks the registry per call today. Follow-up issue tracks per-conversation caching. Closes #37 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
lezama
force-pushed
the
ship/issue-37-tool-discovery
branch
from
May 18, 2026 10:43
78b8aea to
6f30932
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.
Summary
openclawp/list-tools(paginated, category-filterable catalog) andopenclawp/execute-tool(dispatcher by slug) — that let an agent discover and invoke tools on demand instead of paying for every input schema in every system prompt.catalog_modetoggle indefault_config. Default off → byte-identical legacy behavior. On → the resolver swaps the full tool-list declarations for the two meta-tools, regardless of how many abilities the agent allow-lists.category, falls back to inferring from the slug namespace (posts/recent→posts).tests/unit/ToolDiscoveryTest.php, 12 cases) plus integration smoke checks for the abilities registering, the dispatcher round-trip, and the resolver swap with the toggle on/off.What ships
includes/class-openclawp-tool-discovery.php— pure helpers (list_tools,execute_tool,meta_tool_resolver_payload).includes/class-openclawp-abilities.php— registersopenclawp/list-tools+openclawp/execute-tool.includes/class-openclawp-tools-resolver.php— honorsdefault_config.catalog_mode.docs/tool-discovery.md— opt-in instructions and the round-trip-vs-tokens trade-off.tests/bootstrap.php— adds__(),is_wp_error,WP_Errorstubs so the unit suite can run without WP.What's deferred (follow-up issues)
list-toolsoutput. The resolver re-walks the registry on every call today. Cheap on sites with <100 abilities, worth caching beyond that.default_config['catalog_mode'] => true). Add the UI in a follow-up so the admin surface stays unblocked for the other in-flight issues.Test plan
vendor/bin/phpunit --testsuite unit— 12 new cases pass (44 total, 90 assertions).wp_get_ability( 'openclawp/list-tools' )->execute( [] )returns a paginated catalog excluding the meta-tools themselves.wp_get_ability( 'openclawp/execute-tool' )->execute( [ 'tool' => 'openclawp/echo', 'args' => [ 'text' => 'hola' ] ] )returns{ tool: 'openclawp/echo', result: { echoed: 'hola' } }.default_config => [ 'catalog_mode' => true, 'tools' => [ ...20 slugs ] ]and confirmOpenclaWP_Tools_Resolver::for_agent()returns exactly two declarations.catalog_modereturns all 20 declarations (regression guard).list-toolsthenexecute-tooland the loop completes in one combined turn budget.Closes #37
Generated with Claude Code