Tool Search gives PI agents one compact way to discover and call large tool catalogs. It is useful when the run has many available tools but the model is likely to need only a few of them. When enabled for PI, the model receives oneDocumentation Index
Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
tool_search_code tool by default.
That tool runs a short JavaScript body in an isolated Node subprocess with an
openclaw.tools bridge:
How a turn runs
At planning time the PI embedded runner builds the effective catalog for the run:- Resolve the active tool policy for the agent, profile, sandbox, and session.
- List eligible OpenClaw and plugin tools.
- List eligible MCP tools through the session MCP runtime.
- Add eligible client tools supplied for the current run.
- Index compact descriptors for search.
- Expose either the PI code bridge or the structured fallback tools to the model.
openclaw.tools.call(...) crosses the bridge back into the Gateway, where the
normal policy, approval, hook, logging, and result handling still apply.
Modes
tools.toolSearch has two model-facing modes:
code: exposestool_search_code, the default compact JavaScript bridge.tools: exposestool_search,tool_describe, andtool_callas plain structured tools for providers that should not receive code.
code mode falls back to tools before
catalog compaction.
There is no separate source-selection config. When Tool Search is enabled, the
catalog includes eligible OpenClaw, MCP, and client tools after normal policy
filtering.
Why this exists
Large catalogs are useful but expensive. Sending every tool schema to the model makes the request larger, slows planning, and increases accidental tool selection. Tool Search changes the shape:- direct tools: the model sees every selected schema before the first token
- Tool Search code mode: the model sees one compact code tool and a short API contract
- Tool Search tools mode: the model sees three compact structured fallback tools
- during the turn: the model loads only the tool schemas it actually needs
API
openclaw.tools.search(query, options?)
Searches the effective catalog for the current run. Results are compact and safe
to put back into prompt context.
openclaw.tools.describe(id)
Loads full metadata for one search result, including the exact input schema.
openclaw.tools.call(id, args)
Calls a selected tool through OpenClaw.
tool_searchtool_describetool_call
Runtime boundary
The code bridge runs in a short-lived Node subprocess. The subprocess starts with Node permission mode enabled, an empty environment, no filesystem or network grants, and no child-process or worker grants. OpenClaw enforces a parent-process wall-clock timeout and kills the subprocess on timeout, including after async continuations. The runtime exposes only:console.log,console.warn, andconsole.erroropenclaw.tools.searchopenclaw.tools.describeopenclaw.tools.call
- tool allow and deny policies
- per-agent and per-sandbox tool restrictions
- owner-only gating
- approval hooks
- plugin
before_tool_callhooks - session identity, logs, and telemetry
Config
Enable Tool Search for PI runs with the default code bridge:Prompt and telemetry
Tool Search records enough telemetry to compare it with direct tool exposure:- total serialized tool and prompt bytes sent to the harness
- catalog size and source breakdown
- search, describe, and call counts
- final tool calls executed through OpenClaw
- selected tool ids and sources
- how many tool schemas the model saw up front
- how many search and describe operations it performed
- which final tool was called
- whether the result came from OpenClaw, MCP, or a client tool
E2E validation
The gateway E2E runner proves both paths with the PI harness:- Direct mode can call the fake plugin tool.
- Tool Search can call the same fake plugin tool.
- Direct mode exposes the fake plugin tool schemas directly to the provider.
- Tool Search exposes only the compact bridge.
- The Tool Search request payload is smaller for the large fake catalog.
- Session logs show the expected tool-call counts and bridged call telemetry.
Failure behavior
Tool Search should fail closed:- if a tool is not in the effective policy, search should not return it
- if a selected tool becomes unavailable,
tool_callshould fail - if policy or approval blocks execution, the call result should report that block instead of bypassing it
- if the code bridge cannot create an isolated runtime, use
mode: "tools"or disable Tool Search for that deployment