Skip to content

Commit 816a674

Browse files
committed
fix(tool-search): remove unused OpenClawConfig import and fix test to 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.
1 parent 747df8d commit 816a674

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

‎src/agents/tool-search-catalog.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { pruneMapToMaxSize } from "../infra/map-size.js";
22
import { generateSecureToken } from "../infra/secure-random.js";
33
import { getPluginToolMeta, type PluginToolMcpMeta } from "../plugins/tools.js";
4-
import type { OpenClawConfig } from "../config/types.openclaw.js";
54
import type { HookContext } from "./agent-tools.before-tool-call.js";
65
import {
76
isToolWrappedWithBeforeToolCallHook,

‎src/agents/tool-search.test.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,11 @@ describe("Tool Search", () => {
320320
const catalogRef = createToolSearchCatalogRef();
321321
const readTool = fakeTool("read_file", "Read files");
322322
const writeTool = fakeTool("write_file", "Write files");
323-
324-
// In Code Mode, alwaysVisibleTools is ignored; only control tools remain direct.
325-
// Note: we use a normal "exec" tool here to test that configured alwaysVisibleTools
326-
// do not bypass the Code Mode gate. The real Code Mode exec tool has special handling
327-
// elsewhere and is not part of this generic Tool Search compaction test.
328323
const fakeExecTool = fakeTool("exec_normal", "Run shell commands (normal tool)");
329324

330-
const compactedCodeMode = applyToolSearchCatalog({
325+
// Test applyToolCatalogCompaction directly with Code Mode-like parameters.
326+
// This verifies that alwaysVisibleTools is skipped when mode="code".
327+
const compactedCodeMode = applyToolCatalogCompaction({
331328
tools: [
332329
fakeTool("code_mode_exec", "Execute code"),
333330
fakeTool("code_mode_wait", "Wait for code"),
@@ -336,6 +333,7 @@ describe("Tool Search", () => {
336333
fakeExecTool,
337334
pluginTool("fake_lookup", "Look up a record"),
338335
],
336+
enabled: true,
339337
config: {
340338
tools: {
341339
toolSearch: {

0 commit comments

Comments
 (0)