Skip to content

fix(execution): optimize tools.search performance and support multi-namespace search (#1935) - #1939

Open
Adityakk9031 wants to merge 1 commit into
UsefulSoftwareCo:mainfrom
Adityakk9031:fix/tools-search-multi-namespace-timeout
Open

fix(execution): optimize tools.search performance and support multi-namespace search (#1935)#1939
Adityakk9031 wants to merge 1 commit into
UsefulSoftwareCo:mainfrom
Adityakk9031:fix/tools-search-multi-namespace-timeout

Conversation

@Adityakk9031

Copy link
Copy Markdown
Contributor

Summary

Resolves #1935 by resolving timeouts in tools.search when namespace is omitted or multiple slugs are searched in a single execution run.

Root Cause

  1. searchTools performed an unbounded executor.tools.list() across all integrations on every invocation, triggering full workspace table scans and policy checks.
  2. prepareField and scoreToolMatch re-normalized and re-tokenized query strings and large OpenAPI tool descriptions in a loop for every tool in the catalog.
  3. tools.search lacked array/multi-namespace support, causing agents to batch independent searches and multiply runtime cost.

Solution

  • Precompute query normalization/tokenization once outside the tool scoring loop.
  • Use single-pass normalization and Set-based O(1) token lookups in prepareField.
  • Directly scope executor.tools.list({ integration }) for exact namespace enumeration.
  • Support namespace: string | string[] (array and comma-separated slug lists) in tools.search.

Verification

  • bun run --cwd packages/core/execution test -- src/tool-invoker.test.ts (41 passed)
  • bun run --cwd packages/hosts/mcp test (221 passed)
  • bun run --cwd packages/core/execution typecheck
  • bun run lint

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] execute tools.search times out when namespace is omitted or several slugs are searched in one run

1 participant