Repository navigation
improve(tool-search): show input signatures for MCP tools in search results - #196266
Conversation
…esults tool_search rendered input "unknown" for every MCP tool, so models called tool_describe before almost every MCP call. Render the same bounded, structure-only signature used for OpenClaw tools from the MCP input schema. Client tools keep "unknown" because Code Mode lists them in its system prompt from the same compact entries. Remote schemas can carry huge literals, so string literals longer than the hint budget are rejected before serialization. Code Mode prompt construction skips MCP entries before compaction; it never listed them. Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]>
…esults Worked on by: - @jalehman - @GrahamMcBain Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> OpenClaw-Publication: a0929bba-b988-4c27-b67d-606a685a1e6e
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR adds bounded MCP input signatures to Tool Search results while preserving client-schema deferral. Example: An agent searches for world__read_channel.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-directed improvement addresses a discovery limitation still present on main, and review found no concrete introduced defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe run-scoped tool catalog receives MCP schemas and supplies compact search results, full descriptions, and execution metadata to structured Tool Search and Code Mode. flowchart LR
A[MCP server schemas] --> B[Run scoped catalog]
B --> C[Bounded input renderer]
C --> D[Tool Search results]
B --> E[Full tool description]
D --> F[Agent tool call]
F --> G[Existing execution owner]
Technical reviewBest possible solution: Use the existing bounded renderer for MCP discovery while retaining full descriptions, client deferral, and existing execution ownership. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically returns unknown for MCP input hints; the supplied before/after capture corroborates that behavior, and this review executed no target code. Is this the best way to solve the issue? The patch is a focused extension of the existing catalog renderer, with no competing renderer, new state, or configuration surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7554b069a703. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +14, Tests +121, Docs +12, Other +2. Total +149 across 10 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 9, 2026, 4:42 PM ET / 21:42 UTC. |
#196432) * fix(test): reconcile warm reload and procfs test-line debt Allocate nine missing lines for #196385 and correct #196416 from 33 to its actual 36 test lines. #196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar. * fix(test): account for the latest main test-line offset Main #196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack. (cherry picked from commit 644ff7d)
…esults (openclaw#196266) * improve(tool-search): show input signatures for MCP tools in search results tool_search rendered input "unknown" for every MCP tool, so models called tool_describe before almost every MCP call. Render the same bounded, structure-only signature used for OpenClaw tools from the MCP input schema. Client tools keep "unknown" because Code Mode lists them in its system prompt from the same compact entries. Remote schemas can carry huge literals, so string literals longer than the hint budget are rejected before serialization. Code Mode prompt construction skips MCP entries before compaction; it never listed them. Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> * improve(tool-search): show input signatures for MCP tools in search results Worked on by: - @jalehman - @GrahamMcBain Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> OpenClaw-Publication: a0929bba-b988-4c27-b67d-606a685a1e6e * fix(test): restore the main test-line budget after warm reload changes (openclaw#196432) * fix(test): reconcile warm reload and procfs test-line debt Allocate nine missing lines for openclaw#196385 and correct openclaw#196416 from 33 to its actual 36 test lines. openclaw#196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar. * fix(test): account for the latest main test-line offset Main openclaw#196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack. (cherry picked from commit b67d29e) * test(agents): align host-denial proof with immediate failure settlement --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Backport source eb8c48f. Preserve release type ownership and skip MCP schemas before compaction in both Code Mode prompt construction and expired-run recovery. Exclude unrelated host-denial test changes from the source squash. Allocate the retained input-hint tests and extra precompaction regression. Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit dcc7c4cd5e8237bf14c36d5273f386038b5fe40c)
Related: #166133, #194877
Requested by @jalehman.
Work sessions
Linked for team reference; these sessions aren’t public.
What Problem This Solves
Tool Search returns
input: "unknown"for every MCP tool, so agents calltool_describebefore almost every MCP call. Each extra round trip re-sends the prompt. In the g-harness-evals analysis, OpenClaw on Opus averaged about 1.8tool_describecalls per trial on top of about 3.8tool_searchcalls.User Impact
tool_searchresults (single and batch) now show a compact input signature for MCP tools, for example{ channel: string; limit?: number /* integer, <= 500, > 0 */; ... }. An agent can call simple MCP tools directly from the search result.tool_describestill returns the full schema, and a schema that cannot be summarized still showsunknownor.... Client tools are unchanged.Why This Change Was Made
compactToolSearchCatalogEntryrenders MCP input schemas with the existingcompactToolInputHintrenderer. That renderer is already bounded: 300 characters, four nesting levels, 16 properties per object, property names over 128 characters dropped and other non-identifier names JSON-escaped, and short enums. It keeps only structure: names, types, required/optional, enums, and numeric bounds. Descriptions, defaults, and formats are dropped.tool_describealready returns the whole MCP schema, so withholding this summary did not protect anything.input: "unknown". Code Mode builds its system-prompt tool index from these same compact entries and lists client tools there (MCP tools are excluded from that index). Rendering client hints would put caller-supplied schema text into the Code Mode system prompt, which currently has only the callable name. Indirectorymode, client tools are already direct with full schemas.const/enumliteral that exceeds the hint budget beforeJSON.stringify. Code Mode prompt construction and its wait-error path filter out MCP entries before compaction, so MCP hints are not rendered there. Those entries were already dropped by binding selection, so the Code Mode prompt does not change.Proxyto assert that MCP schemas are never traversed at all. They now assert the contracts that remain: MCP parameter text does not affect ranking, and OpenClaw does not reject MCP calls on schema grounds. The throwing-Proxycase is kept for client tools.tool_describewhen input is not clear, which still applies tounknown/...hints.docs/tools/tool-search.mdno longer says MCP inputs are deferred, and it documents the bounds and the client decision.parametersto the canonical presentation schema. These hints readentry.parameters, so they will follow that change automatically. Its helpers resolve which schema is used and do not apply to rendering. The two PRs touch different lines intool-search-catalog.ts.number /* integer ... */, and a new assertion checks that an integer argument reaches the MCP executor as a JSON number throughdispatch_action.Evidence
Before/after against the real g-harness-evals world MCP server (
world/world-mcp, streamable HTTP with bearer auth). The path was: OpenClaw's session MCP runtime manager →materializeBundleMcpToolsForRun→applyToolSearchCatalog→tool_searchexecute. Sizes are the model-facing tool result text, including the untrusted-content wrapper. Before is the parent commit; after is0596c231. The capture harness was a local, uncommitted Vitest file.tool_searchcall{ query: "list channels" }(8 hits){ query: "read channel" }(6 hits)14 of the 15 world tools get complete signatures.
request_approvalrenders{ action: string; authorization: string; channel?: unknown; details?: { ... } }, so it still needstool_describe. For these tools, atool_describeresult is 778–2,513 B, plus one more model request that re-sends the prompt. The reduction in describe calls was not measured: no scripted or real-model run was done. Buildingdistfor a fullopenclaw agent --localrun is refused on this shared host by the managed-Gateway runtime-artifact publication guard. The capture above exercises the production MCP runtime and Tool Search modules directly.Tests
tool-search.discovery.test.tscase through the realtool_search/tool_describe/dispatch_actiontools:const, and 1,000 extra properties. It stays at or under 300 chars, renders on one line, drops the long name, collapses depth, and ends in...;unknown;tool_describestill returns the full schema;MAX_TOOL_SEARCH_BATCH_RESPONSE_CHARSwithtruncated: true, and remaining candidates keep their full hint.origin/main(expected 'unknown'). The huge-constassertion fails without the literal bound.tool-search*,code-mode*,tool-schema-hints,attempt-client-tools,attempt.tool-search-run-plan,agent-tools.prefix-stability,system-prompt-report. One perf file is skipped by design.--maxWorkers=1take 46.6 s wall, nearly all of it Vitest worker preparation. Test bodies take 1–15 ms each.tsgocore and core-test shards, oxlint and oxfmt on changed files, markdownlint on the doc,git diff --check, and the test-line ratchet all pass. The ratchet uses allocationconfig/test-lines-allocations/mcp-tool-search-input-hints.txt(+114 net lines: 121 MCP boundary-case lines minus seven obsolete host-denial waiting-path lines).pnpm check:changedfailures are inherited fromorigin/mainin files this PR does not touch: the dead-export scan (src/daemon/launchd.ts,src/plugins/provider-runtime.ts, and others) and one core lint error inui/src/e2e/sidebar-rail-alignment.e2e.test.ts(no-shadow).CI repair: Integrated the existing main lint and test-budget repairs. The new main failure-settlement behavior from #196435 exposed a stale host-denial test: reproduced on pinned main
21f17afce911(20 pass, one fails), then corrected the expectation without weakening late mutation completion, exactly-once execution, lifecycle drain, or no-spawn assertions. All 21 host-denial tests pass, plus targeted lint/format. The small test-only diff received an independent review with no findings. The pinned-base test-line ratchet passes with zero slack. The earlier 104 focused MCP and prefix-stability tests also passed.Gaps: no isolated-Gateway or real-model run, and no measured change in describe-call count.
Worked on by