Skip to content

fix(tool-search): add alwaysVisibleTools config to bypass catalog compaction - #118335

Closed
xiaoping1988 wants to merge 6 commits into
openclaw:mainfrom
xiaoping1988:fix/tool-search-direct-tool-config
Closed

xiaoping1988 wants to merge 6 commits into
openclaw:mainfrom
xiaoping1988:fix/tool-search-direct-tool-config

Conversation

@xiaoping1988

Copy link
Copy Markdown

What Problem This Solves

Fixes an issue where operators cannot configure frequently-used tools to remain directly visible in the tool palette. When using Tool Search catalog compaction, all tools except control tools get hidden behind search, requiring extra steps to access common tools like read_file, write_file, or edit.

Why This Change Was Made

Adds a new tools.toolSearch.alwaysVisibleTools config option that accepts an array of tool names. These tools bypass the catalog compaction and remain visible alongside control tools. The solution normalizes tool names (handling case variations) and filters them during catalog application, keeping the most-used tools one-click accessible without breaking the compact catalog design.

User Impact

Operators can now configure their most-used tools to stay directly visible in the tool palette while still benefiting from catalog compaction for the remaining tools. For example, adding ["read", "write", "edit"] to alwaysVisibleTools keeps these core editing tools always accessible, reducing friction in daily workflows.

Configuration example:

{
"tools": {
"toolSearch": {
"enabled": true,
"mode": "tools",
"alwaysVisibleTools": ["read", "write", "edit", "exec"]
}
}
}

Evidence

TypeScript type definitions updated in src/config/types.tools.ts and src/agents/tool-search-types.ts
Zod schema validation added in src/config/zod-schema.agent-runtime.ts with test coverage in src/config/schema.test.ts
Runtime parsing implemented in src/agents/tool-search-config.ts using normalizeTrimmedStringList and normalizeToolName
Catalog compaction logic updated in src/agents/tool-search-catalog.ts to filter always-visible tools
Integration points covered in src/agents/code-mode.ts, src/agents/code-mode-runtime.ts, and src/agents/tool-search-directory.ts
Help text and labels added in src/config/schema.help.runtime.ts and src/config/schema.labels.ts

…paction

Add tools.toolSearch.alwaysVisibleTools config option to allow operators
to keep frequently-used tools directly visible without requiring search.

Changes:
- src/config/types.tools.ts: Add alwaysVisibleTools field to ToolSearchConfig type
- src/config/zod-schema.agent-runtime.ts: Add alwaysVisibleTools to ToolSearchSchema
- src/config/schema.help.runtime.ts: Add help text for alwaysVisibleTools
- src/config/schema.labels.ts: Add label for alwaysVisibleTools
- src/config/schema.test.ts: Add test case for alwaysVisibleTools parsing
- src/agents/tool-search-config.ts: Parse alwaysVisibleTools with normalizeTrimmedStringList
  and normalize tool names using normalizeToolName
- src/agents/tool-search-types.ts: Add alwaysVisibleTools Set<string> to ToolSearchConfig
- src/agents/tool-search-catalog.ts: Filter alwaysVisibleTools in applyToolCatalogCompaction
- src/agents/code-mode.ts: Pass config parameter to applyToolCatalogCompaction
- src/agents/code-mode-runtime.ts: Initialize alwaysVisibleTools as empty Set in toToolSearchConfig
- src/agents/tool-search-directory.ts: Pass config parameter to applyToolCatalogCompaction
- src/agents/tool-search-ranking.test.ts: Initialize alwaysVisibleTools as empty Set in test fixtures
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Aug 3, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 4, 2026, 9:17 PM ET / August 5, 2026, 01:17 UTC.

ClawSweeper review

What this changes

The PR adds tools.toolSearch.alwaysVisibleTools, a configuration list intended to keep selected tools directly visible instead of cataloging them.

Merge readiness

⛔ Blocked until real behavior proof is added - 14 items remain

Keep open for maintainer product direction, but this exact head is incorrect: it can bypass Code Mode’s direct-tool boundary and the existing MCP lookalike trust gate. It also lacks public documentation and after-fix runtime proof.

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

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The exact head has two high-priority tool-surface boundary defects and no real behavior proof.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body lists code and test changes but provides no redacted after-fix agent-run output, recording, or runtime logs demonstrating generic visibility, deferred MCP collision handling, and unchanged Code Mode behavior. 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 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body lists code and test changes but provides no redacted after-fix agent-run output, recording, or runtime logs demonstrating generic visibility, deferred MCP collision handling, and unchanged Code Mode behavior. 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 6 items Current Tool Search behavior: Current main already keeps the core coding tools named in the PR’s example (read, edit, and exec) directly visible while retaining them in the catalog.
Code Mode dispatch is independent of Tool Search mode: The surface planner calls the Code Mode catalog whenever Code Mode controls are enabled; its existing regression uses Code Mode with Tool Search configured as directory.
Exact-head Code Mode defect: The branch decides whether to suppress the override from tools.toolSearch.mode; a Code Mode run configured with tools or directory therefore reaches the direct-visibility branch.
Findings 3 actionable findings [P1] Pass the active catalog surface instead of inferring Code Mode
[P1] Keep MCP lookalikes behind the trusted direct-tool gate
[P2] Document the public Tool Search setting
Security Needs attention Code Mode can expose configured normal tools: The branch uses Tool Search mode to identify Code Mode even though the actual surface planner independently selects Code Mode, allowing configured normal tools onto its direct model surface.
Name-only matching exposes MCP lookalikes: A configured matching name is made direct before the trusted-source predicate runs, so it can expose an MCP lookalike that current behavior intentionally defers.

How this fits together

Tool Search compacts an agent’s tool catalog into a small direct surface plus deferred search. Generic Code Mode reuses the catalog machinery but owns a stricter direct-tool boundary for model safety.

flowchart LR
  A[Operator configuration] --> B[Tool surface planner]
  B --> C{Code Mode active?}
  C -->|Yes| D[Code Mode catalog]
  C -->|No| E[Generic Tool Search]
  E --> F[Visible tools and catalog]
  D --> F
Loading

Decision needed

Question Recommendation
Should OpenClaw add a persisted generic Tool Search direct-visibility override when its stated core coding-tool examples are already directly visible by default? Keep the current direct defaults: Decline the new setting because the stated coding workflow is already covered by the existing generic Tool Search behavior.

Why: This is a new core configuration contract rather than a repair of established behavior, and the repository policy sets a high bar for new config surfaces.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body lists code and test changes but provides no redacted after-fix agent-run output, recording, or runtime logs demonstrating generic visibility, deferred MCP collision handling, and unchanged Code Mode behavior. 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.
  • Pass the active catalog surface instead of inferring Code Mode (P1) - Code Mode is selected by the tool-surface planner independently of tools.toolSearch.mode. With Code Mode active and Tool Search set to tools or directory, this check is false and the next branch exposes configured normal tools directly. Carry a caller-owned surface flag and cover the real Code Mode route.
  • Keep MCP lookalikes behind the trusted direct-tool gate (P1) - This runs before the existing source-qualified visibility predicate, so a configured name such as message promotes an MCP lookalike directly instead of leaving it deferred. Require the existing trusted-source contract or an explicit source-qualified configuration format, with collision coverage.
  • Document the public Tool Search setting (P2) - This adds only internal schema help; the public Tool Search configuration page has no supported syntax, mode scope, collision behavior, or Code Mode exclusion for the new setting.
  • Resolve security concern: Code Mode can expose configured normal tools - The branch uses Tool Search mode to identify Code Mode even though the actual surface planner independently selects Code Mode, allowing configured normal tools onto its direct model surface.
  • Resolve security concern: Name-only matching exposes MCP lookalikes - A configured matching name is made direct before the trusted-source predicate runs, so it can expose an MCP lookalike that current behavior intentionally defers.
  • Resolve merge risk (P1) - Merging can expose configured normal tools on a Code Mode run despite Code Mode superseding Tool Search.
  • Resolve merge risk (P1) - A name-only override can promote an MCP lookalike directly, bypassing the existing trusted-source visibility rule.
  • Resolve merge risk (P1) - This adds a persisted core configuration surface although the stated core coding-tool examples are already directly visible on current main.
  • Complete next step (P2) - A maintainer must first confirm whether this new core configuration contract is wanted; the contributor then needs to address the tool-surface findings and provide real behavior proof.
  • Improve patch quality - Make generic-versus-Code-Mode selection caller-owned and add real surface-plan regression coverage.
  • Improve patch quality - Preserve trusted-source and MCP collision handling for configured direct tools.
  • Improve patch quality - Add public configuration documentation and redacted after-fix runtime evidence.

Findings

  • [P1] Pass the active catalog surface instead of inferring Code Mode — src/agents/tool-search-catalog.ts:415
  • [P1] Keep MCP lookalikes behind the trusted direct-tool gate — src/agents/tool-search-catalog.ts:429-434
  • [P2] Document the public Tool Search setting — src/config/schema.help.runtime.ts:116-117
  • [medium] Code Mode can expose configured normal tools — src/agents/tool-search-catalog.ts:415
  • [medium] Name-only matching exposes MCP lookalikes — src/agents/tool-search-catalog.ts:432
Agent review details

Security

Needs attention: The direct-visibility branch bypasses established Code Mode and trusted-source tool-surface boundaries.

PR surface

Source +36, Tests +90. Total +126 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 10 36 0 +36
Tests 3 90 0 +90
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 126 0 +126

Review metrics

Metric Value Why it matters
Configuration surface 1 added public setting; 0 migration The new setting changes the model-visible tool surface and requires an explicit compatibility and product-scope decision.
Production vs test growth production +36, tests +90 The production growth implements a new operator policy surface, so its core scope needs named justification rather than test coverage alone.

Merge-risk options

Maintainer options:

  1. Pause for product direction (recommended)
    Do not merge this branch until maintainers decide whether the additional persisted Tool Search policy belongs in core.
  2. Repair a narrowly sponsored override
    If sponsored, move the decision to the generic caller, preserve source-qualified visibility, test Code Mode with tools and directory, and document the supported names and collisions.

Technical review

Best possible solution:

Retain the existing default direct coding tools; only add a generic override if maintainers sponsor it, with caller-owned generic-surface gating, trusted source qualification, collision rules, Code Mode exclusion, public documentation, and runtime proof.

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

Yes, from source: enable Code Mode with Tool Search mode set to tools or directory and list a normal tool in alwaysVisibleTools; the Code Mode caller reaches the branch that exposes it directly.

Is this the best way to solve the issue?

No: current generic Tool Search already exposes the stated core coding tools directly, while the proposed common helper bypasses Code Mode and trusted-source ownership boundaries.

Full review comments:

  • [P1] Pass the active catalog surface instead of inferring Code Mode — src/agents/tool-search-catalog.ts:415
    Code Mode is selected by the tool-surface planner independently of tools.toolSearch.mode. With Code Mode active and Tool Search set to tools or directory, this check is false and the next branch exposes configured normal tools directly. Carry a caller-owned surface flag and cover the real Code Mode route.
    Confidence: 0.99
  • [P1] Keep MCP lookalikes behind the trusted direct-tool gate — src/agents/tool-search-catalog.ts:429-434
    This runs before the existing source-qualified visibility predicate, so a configured name such as message promotes an MCP lookalike directly instead of leaving it deferred. Require the existing trusted-source contract or an explicit source-qualified configuration format, with collision coverage.
    Confidence: 0.98
  • [P2] Document the public Tool Search setting — src/config/schema.help.runtime.ts:116-117
    This adds only internal schema help; the public Tool Search configuration page has no supported syntax, mode scope, collision behavior, or Code Mode exclusion for the new setting.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded but unapproved operator-facing Tool Search configuration change.
  • merge-risk: 🚨 compatibility: The new setting can alter direct tool exposure for existing configurations that activate Code Mode.
  • merge-risk: 🚨 security-boundary: The name-only branch bypasses the existing trusted-source guard that keeps MCP lookalikes deferred.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists code and test changes but provides no redacted after-fix agent-run output, recording, or runtime logs demonstrating generic visibility, deferred MCP collision handling, and unchanged Code Mode behavior. 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

Security concerns:

  • [medium] Code Mode can expose configured normal tools — src/agents/tool-search-catalog.ts:415
    The branch uses Tool Search mode to identify Code Mode even though the actual surface planner independently selects Code Mode, allowing configured normal tools onto its direct model surface.
    Confidence: 0.99
  • [medium] Name-only matching exposes MCP lookalikes — src/agents/tool-search-catalog.ts:432
    A configured matching name is made direct before the trusted-source predicate runs, so it can expose an MCP lookalike that current behavior intentionally defers.
    Confidence: 0.98

What I checked:

  • Current Tool Search behavior: Current main already keeps the core coding tools named in the PR’s example (read, edit, and exec) directly visible while retaining them in the catalog. (src/agents/tool-search.test.ts:316, ed31a4dd79bf)
  • Code Mode dispatch is independent of Tool Search mode: The surface planner calls the Code Mode catalog whenever Code Mode controls are enabled; its existing regression uses Code Mode with Tool Search configured as directory. (src/agents/tool-surface-plan.ts:95, ed31a4dd79bf)
  • Exact-head Code Mode defect: The branch decides whether to suppress the override from tools.toolSearch.mode; a Code Mode run configured with tools or directory therefore reaches the direct-visibility branch. (src/agents/tool-search-catalog.ts:415, 816a674985ac)
  • Existing trust boundary: Current main’s direct-tool predicate requires a trusted OpenClaw source, and its regression coverage keeps an MCP message lookalike deferred. (src/agents/tool-search-catalog.ts:228, ed31a4dd79bf)
  • Public documentation gap: The public Tool Search configuration page documents the existing modes and limits, but the branch changes only internal schema help and does not add this new setting to that page. Public docs: docs/tools/tool-search.md. (docs/tools/tool-search.md:258, ed31a4dd79bf)
  • Feature provenance: Blame attributes the current Code Mode direct-tool invariant to the commit that introduced the present catalog implementation. (src/agents/code-mode.ts:303, 92a9cc5a94d7)

Likely related people:

  • Shakker: Commit 92a9cc5 introduced the current Tool Search and Code Mode catalog implementation, including the trusted direct-tool invariant now affected by this branch. (role: introduced current catalog boundary; confidence: high; commits: 92a9cc5a94d7; files: src/agents/code-mode.ts, src/agents/tool-search-catalog.ts, docs/tools/tool-search.md)

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-03T00:49:30.495Z sha fad2e1b :: needs real behavior proof before merge. :: [P1] Preserve Code Mode’s trusted direct-tool gate | [P2] Document the new public Tool Search option
  • reviewed 2026-08-03T01:14:11.969Z sha f0965b9 :: needs real behavior proof before merge. :: [P1] Preserve Code Mode’s trusted direct-tool gate | [P2] Document the new public Tool Search option
  • reviewed 2026-08-03T01:27:36.255Z sha 364c040 :: needs real behavior proof before merge. :: [P1] Keep Code Mode independent of Tool Search mode | [P2] Document the new Tool Search setting

…l surface

Code Mode has a strict trusted direct-tool boundary: only explicitly
required tools may remain directly visible to the model. The new
alwaysVisibleTools config was incorrectly promoting configured normal
tools onto Code Mode's direct model surface, bypassing that boundary.

Fix: skip alwaysVisibleTools filtering in Code Mode (mode='code').
The generic Tool Search modes ('tools' and 'directory') still honor
alwaysVisibleTools as intended.

Added regression test verifying:
- Code Mode ignores alwaysVisibleTools and catalogs those tools
- Non-Code Mode respects alwaysVisibleTools and keeps them direct
…cope

The regression test for alwaysVisibleTools + Code Mode had two issues:

1. Used incorrect tool names (code_mode_exec/code_mode_wait) instead of
   the actual Code Mode control tool names. Fixed by using explicit
   isVisibleControlTool predicate and testing with fake tool names that
   don't conflict with real Code Mode tools.

2. Manually assigned catalogRef.current without the required counterScope
   field. Fixed by using a fresh catalogRef for the tools mode test,
   letting applyToolSearchCatalog initialize it properly.

The test now correctly verifies:
- Code Mode ignores alwaysVisibleTools (all non-control tools are cataloged)
- Tool Search mode respects alwaysVisibleTools (configured tools stay direct)
… use applyToolCatalogCompaction

1. Removed unused OpenClawConfig import from tool-search-catalog.ts
   (it was only used indirectly through resolveToolSearchConfig)

2. Fixed the regression test to directly call applyToolCatalogCompaction
   instead of applyToolSearchCatalog, because the Code Mode simulation
   requires passing isVisibleControlTool which is internal to the generic
   compaction function.

The test now correctly verifies that alwaysVisibleTools is ignored in
Code Mode (mode='code'), keeping only control tools direct while
cataloging all other tools including those in alwaysVisibleTools.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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