From 63f48c79675f65bfe54730f782370b6c26cef8cb Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Fri, 14 Aug 2026 15:15:52 -0700 Subject: [PATCH] Route in-band execution through the comprehensive tool dispatcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The internal execute route used the bare server-tool router, which rejects VFS tools with 'Unknown server tool: read/glob/grep' — so nearly every background agent's first discovery call failed (102 in-band calls in one run, dozens rejected). It now uses the relay's executeTool dispatcher: registered handlers (VFS, function execute) with permission checks and param normalization, falling back to the app tool router — the same surface foreground execution gets. --- apps/sim/app/api/copilot/tools/execute/route.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/sim/app/api/copilot/tools/execute/route.ts b/apps/sim/app/api/copilot/tools/execute/route.ts index a2e4c3b73c..9da0848f6c 100644 --- a/apps/sim/app/api/copilot/tools/execute/route.ts +++ b/apps/sim/app/api/copilot/tools/execute/route.ts @@ -14,7 +14,8 @@ import { } from '@/lib/copilot/request/tools/resolved-secret-result' import { handleResourceSideEffects } from '@/lib/copilot/request/tools/resources' import type { ToolCallResult } from '@/lib/copilot/request/types' -import { createServerToolHandler } from '@/lib/copilot/tools/registry/server-tool-adapter' +import { ensureHandlersRegistered } from '@/lib/copilot/tool-executor' +import { executeTool } from '@/lib/copilot/tool-executor/executor' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import type { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry' @@ -128,8 +129,12 @@ export const POST = withRouteHandler((request: NextRequest) => } try { - const handler = createServerToolHandler(toolName) - const result = await handler(params, { + // The relay's comprehensive dispatcher: registry handlers (VFS + // glob/read/grep, function execute, ...) plus the server tool router + // fallback — the plain server-tool adapter alone rejects VFS tools + // with "Unknown server tool". + ensureHandlersRegistered() + const result = await executeTool(toolName, params, { userId, workflowId: workflowId ?? '', workspaceId,