Skip to content

feat(agents): show searchable tool capabilities automatically - #114508

Merged
steipete merged 1 commit into
mainfrom
codex/tool-search-capability-directory
Jul 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/tool-search-capability-directory

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

When Tool Search is enabled, the default code and structured modes previously hid the real catalog without telling the model which capabilities it could discover. Models had to guess when search was useful, even though the Gateway already knew the policy-filtered catalog.

Why This Change Was Made

Automatically render the existing trusted, policy-filtered capability directory for every enabled Tool Search mode. Keep it bounded to 18,000 characters, alphabetically deterministic, above the explicit system-prompt cache boundary, and memoized by immutable catalog snapshot. Use mode-correct search guidance and never copy untrusted MCP or client names, descriptions, or schemas into the prompt. Keep direct-only tools, disabled Tool Search, Codex-native dynamic tools, approvals, hooks, and local-model runtime configuration unchanged.

User Impact

Models immediately know which authorized OpenClaw and plugin capabilities are searchable without receiving every full tool schema. Repeated turns preserve KV-cache prefix reuse, and the model still learns that policy-approved MCP and client capabilities can be discovered safely.

Evidence

  • Blacksmith Testbox: 322 passing tests across 14 focused files, including 200-tool stress tests for code, structured, and directory modes; malicious MCP and client metadata; snapshot cache reuse and invalidation; local-model lean mode; provider prompt state; direct-only tools; and stable prompt-cache prefixes.
  • Real Gateway and mock provider: tool-search-gateway-e2e passes with 68 direct tools versus 2 compact tools; the hidden target is present in the compact directory and absent from the direct-mode directory; both modes call the same real plugin tool.
  • Verified provider request size: 93,541 direct bytes versus 42,572 compact bytes, including the new capability directory.
  • Full remote pnpm check:changed: all TypeScript, core and plugin lint, security, architecture, dependency, and boundary guards pass; zero runtime import cycles.
  • Full remote pnpm check:docs: 737 Markdown files clean, 752 MDX files validated, zero broken links, and generated docs map up to date.
  • Final Codex autoreview: clean, with no actionable findings.
  • Independently inspected Codex native discovery and dynamic-tool contracts; OpenClaw Tool Search remains isolated from Codex-owned native surfaces.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: qa-lab size: M maintainer Maintainer-authored PR labels Jul 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 6:24 AM ET / 10:24 UTC.

ClawSweeper review

What this changes

Adds an automatic, bounded directory of trusted searchable tool capabilities to agent system prompts when Tool Search is enabled, with documentation and gateway-fixture coverage.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep this PR open for maintainer review. It makes a new default agent-prompt behavior—automatically adding a bounded searchable-capability directory—and the supplied evidence is strong on mocked/runtime test coverage but does not include inspectable after-fix real-provider proof. Likely related people: steipete is the available low-confidence routing candidate as the feature author.

Priority: P2
Reviewed head: a9f805dca00699e40e0bd96f7664f57d4a0f0477
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has focused implementation and test evidence, but the required real after-fix behavior proof is not yet inspectable.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR reports gateway execution with a mock provider and passing checks, but no inspectable redacted live-provider artifact demonstrates the changed prompt behavior after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR reports gateway execution with a mock provider and passing checks, but no inspectable redacted live-provider artifact demonstrates the changed prompt behavior after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Prompt-default change: The branch changes embedded attempt prompt preparation so the directory is enabled whenever Tool Search controls are enabled and a catalog is registered, rather than depending on the prior callable-directory condition.
Bounded directory implementation: The branch adds an 18,000-character prompt limit and caches rendered directories by immutable catalog-entry snapshot and mode/options.
Coverage supplied by the PR: The branch adds unit coverage for code, tools, and directory modes, directory ordering and bounds, cache behavior, untrusted MCP/client metadata handling, and prompt-cache placement.
Findings None None.
Security None None.

How this fits together

Embedded agent runs assemble a system prompt from the enabled tool configuration and policy-filtered tool catalog before sending a request to a model provider. Tool Search replaces many direct schemas with compact discovery controls; this PR also gives the model a safe summary of capabilities it can discover.

flowchart LR
  A[Agent run] --> B[Tool Search settings]
  B --> C[Policy-filtered tool catalog]
  C --> D[Bounded capability directory]
  D --> E[Stable system-prompt prefix]
  E --> F[Model provider]
  F --> G[Tool Search bridge]
  G --> H[Authorized tool call]
Loading

Decision needed

Question Recommendation
Should enabled Tool Search automatically spend part of every existing agent prompt on the bounded capability directory, rather than leaving capability discovery implicit? Confirm the automatic default: Accept the bounded directory as the standard Tool Search experience after reviewing its context-budget and model-behavior tradeoff.

Why: This is a deliberate new default for existing configured users and changes agent context allocation and model guidance; tests can verify mechanics but cannot select the product default.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR reports gateway execution with a mock provider and passing checks, but no inspectable redacted live-provider artifact demonstrates the changed prompt behavior after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Enabled Tool Search runs gain up to 18,000 additional stable prompt characters by default, which can change context budget, provider request size, and model behavior for existing configurations.
  • Resolve merge risk (P1) - The PR describes mock-provider gateway evidence rather than an inspectable after-fix real-provider artifact, so the changed prompt behavior has not yet met the external-PR real-behavior proof gate.
  • Complete next step (P2) - A maintainer must decide whether the new automatic prompt default is the intended product behavior, and the contributor needs to provide inspectable real-runtime proof before merge.
Agent review details

Security

None.

PR surface

Source +51, Tests +238, Docs +15, Other +3. Total +307 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 74 23 +51
Tests 3 307 69 +238
Docs 1 34 19 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 0 +3
Total 9 418 111 +307

Review metrics

Metric Value Why it matters
Agent-prompt default 1 new automatic directory, capped at 18,000 characters Every enabled Tool Search run can receive a larger stable prompt prefix, so the context-budget and upgrade behavior need explicit review.

Stored data model

Persistent data-model change detected: persistent cache schema: src/agents/system-prompt.test.ts, persistent cache schema: src/agents/tool-search-directory.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm the default and add live proof (recommended)
    Keep the implementation direction, obtain explicit maintainer confirmation for the automatic prompt expansion, and attach redacted after-fix evidence from a real provider request or live run.
  2. Accept the context-budget tradeoff
    Maintain the automatic default as proposed and document that existing Tool Search users receive the bounded directory on upgrade.

Technical review

Best possible solution:

Confirm that an automatic bounded capability directory is the intended default for all enabled Tool Search modes, then attach a redacted live-provider or provider-request artifact demonstrating the safe directory and successful discovery path before merge.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR adds a new capability-discovery behavior rather than reporting a currently failing user workflow. The supplied tests and gateway fixture describe the intended behavior but are not a bug reproduction.

Is this the best way to solve the issue?

Unclear: the implementation is a coherent bounded, policy-filtered approach, but whether it should be automatic for every existing Tool Search configuration is a maintainer product decision rather than a purely technical fix.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 50dee059a254.

Labels

Label changes:

  • add P2: This is a bounded agent-runtime feature with a meaningful but non-emergency effect on existing Tool Search users.
  • add merge-risk: 🚨 compatibility: The branch changes the default system prompt for existing enabled Tool Search configurations and can alter context use and model behavior after upgrade.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports gateway execution with a mock provider and passing checks, but no inspectable redacted live-provider artifact demonstrates the changed prompt behavior after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a bounded agent-runtime feature with a meaningful but non-emergency effect on existing Tool Search users.
  • merge-risk: 🚨 compatibility: The branch changes the default system prompt for existing enabled Tool Search configurations and can alter context use and model behavior after upgrade.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports gateway execution with a mock provider and passing checks, but no inspectable redacted live-provider artifact demonstrates the changed prompt behavior after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Prompt-default change: The branch changes embedded attempt prompt preparation so the directory is enabled whenever Tool Search controls are enabled and a catalog is registered, rather than depending on the prior callable-directory condition. (src/agents/embedded-agent-runner/run/attempt.ts:299, a9f805dca006)
  • Bounded directory implementation: The branch adds an 18,000-character prompt limit and caches rendered directories by immutable catalog-entry snapshot and mode/options. (src/agents/tool-search-directory.ts:22, a9f805dca006)
  • Coverage supplied by the PR: The branch adds unit coverage for code, tools, and directory modes, directory ordering and bounds, cache behavior, untrusted MCP/client metadata handling, and prompt-cache placement. (src/agents/tool-search.test.ts:188, a9f805dca006)
  • Real-behavior proof gap: The PR body describes a real Gateway run with a mock provider and checks, but the provided context contains no linked redacted live-provider transcript, terminal capture, log, recording, or artifact showing the changed provider prompt after the fix. (a9f805dca006)
  • Repository policy application: The supplied repository AGENTS.md treats prompt/runtime behavior and default changes as compatibility-sensitive, requires a best-fix and upgrade-safety pass, and reserves maintainer judgment for product-direction choices. (AGENTS.md:1, 50dee059a254)

Likely related people:

  • steipete: The available review context identifies steipete as author of the sole branch commit touching the Tool Search directory and embedded-agent prompt path; no current-main ownership history was available in the supplied review evidence. (role: feature author; confidence: low; commits: a9f805dca006; files: src/agents/tool-search-directory.ts, src/agents/embedded-agent-runner/run/attempt-system-prompt-prepare.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted terminal capture, provider-request log, or live-run artifact showing the bounded directory and successful discovery with a real provider.
  • Obtain maintainer confirmation that automatic directory injection is the desired default for existing Tool Search users.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Addressing the latest ClawSweeper rank-up moves before landing:

  1. Maintainer decision: the repository maintainer explicitly requested: “We should do this by default. Obviously make sure to keep the KV cache in mind … If tool search is enabled we should automatically give it the directory.” This PR implements that exact decision. It does not enable Tool Search globally or change tools.toolSearch defaults; the directory is added only when search controls are already enabled and the policy-filtered catalog is registered.

  2. Inspectable real Gateway/provider-request evidence: the hosted Blacksmith Testbox ran the actual QA Gateway, installed the 36-tool plugin, issued real Gateway /v1/responses requests, and inspected the full recorded provider prompt—not a truncated snippet or unit mock. The repository scenario intentionally requires its deterministic mock-openai provider; substituting a paid live provider would not exercise this scripted, provider-inspectable acceptance scenario.

pnpm openclaw qa suite \
  --provider-mode mock-openai \
  --scenario tool-search-gateway-e2e \
  --output-dir .artifacts/qa-e2e/tool-search-auto-directory

Status: pass
Target: fake_plugin_tool_17
Direct declared tools: 68
Compact declared tools: 2
Direct directory contains target: false
Compact directory contains target: true
Direct request bytes: 93,541
Compact request bytes: 42,572
Direct planned tool: fake_plugin_tool_17
Compact planned tool: tool_search_code
Both modes executed the same real plugin target successfully.
  1. KV-cache and compatibility: the directory is alphabetically deterministic, capped at 18,000 characters, above the existing explicit stable-prefix boundary, and memoized in a process-local WeakMap keyed by the immutable catalog-entry array. It contains no turn IDs, message text, hydrated per-turn guesses, or untrusted MCP/client descriptions. There is no persistent cache, SQLite schema, database migration, or storage-format change; the automated “persistent cache schema” classification is a false positive for an in-memory WeakMap and a prompt-boundary regression test.

Final proof: 322 focused tests across 14 files; full pnpm check:changed; full pnpm check:docs; 0 runtime import cycles; 0 broken documentation links; malicious external-tool coverage and 200-tool bounds in all three modes; and a clean independent Codex autoreview.

@steipete
steipete merged commit c8ebf57 into main Jul 27, 2026
126 of 137 checks passed
@steipete
steipete deleted the codex/tool-search-capability-directory branch July 27, 2026 10:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: qa-lab maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant