{"record":{"id":"ba47c893573c076d","repo":"n8n-io/n8n","slug":"sandbox-does-not-support-command-execution","errorCode":null,"errorMessage":"Sandbox does not support command execution","messagePattern":"Sandbox does not support command execution","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/agents/src/workspace/tools/execute-command.ts","lineNumber":28,"sourceCode":"\t\t.input(\n\t\t\tz.object({\n\t\t\t\tcommand: z.string().describe('The shell command to execute'),\n\t\t\t\tcwd: z.string().optional().describe('Working directory for the command'),\n\t\t\t\ttimeout: z.number().optional().describe('Timeout in milliseconds'),\n\t\t\t}),\n\t\t)\n\t\t.output(\n\t\t\tz.object({\n\t\t\t\tsuccess: z.boolean(),\n\t\t\t\texitCode: z.number(),\n\t\t\t\tstdout: z.string(),\n\t\t\t\tstderr: z.string(),\n\t\t\t\texecutionTimeMs: z.number(),\n\t\t\t}),\n\t\t)\n\t\t.handler(async (input, ctx) => {\n\t\t\tif (!sandbox.executeCommand) {\n\t\t\t\tthrow new Error('Sandbox does not support command execution');\n\t\t\t}\n\t\t\tconst env = sandbox.getDefaultCommandEnv?.();\n\t\t\tconst result = await sandbox.executeCommand(input.command, undefined, {\n\t\t\t\tcwd: input.cwd,\n\t\t\t\t...(env ? { env } : {}),\n\t\t\t\ttimeout: input.timeout,\n\t\t\t\tabortSignal: ctx.abortSignal,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tsuccess: result.success,\n\t\t\t\texitCode: result.exitCode,\n\t\t\t\tstdout: result.stdout,\n\t\t\t\tstderr: result.stderr,\n\t\t\t\texecutionTimeMs: result.executionTimeMs,\n\t\t\t};\n\t\t})\n\t\t.build();\n}","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/agents/src/workspace/tools/execute-command.ts#L10-L46","documentation":"The execute-command tool checks `sandbox.executeCommand` (truthiness) before invoking it. Some sandbox implementations only provide `processes.spawn` and don't implement executeCommand; the tool requires the higher-level executeCommand API, so it refuses to run on such sandboxes rather than calling a missing method.","triggerScenarios":"Registering the execute-command tool against a sandbox whose executeCommand is undefined (a sandbox that only implements processes.spawn). Mixing a spawn-only sandbox with the execute-command tool.","commonSituations":"A custom WorkspaceSandbox implementation that omits executeCommand; using a minimal/local sandbox shim that only implements spawn; version skew between the tool registry and a sandbox adapter.","solutions":["Use a sandbox that implements executeCommand (e.g. DaytonaSandbox), or don't register the execute-command tool.","If building a custom sandbox, implement executeCommand(command, args, options) returning {success, exitCode, stdout, stderr}.","Route command execution through runInSandbox() which falls back to processes.spawn when executeCommand is absent."],"exampleFix":"// before: custom sandbox only implements spawn\nclass MySandbox implements WorkspaceSandbox {\n  processes = new ProcManager();\n  // no executeCommand\n}\n\n// after\nclass MySandbox implements WorkspaceSandbox {\n  processes = new ProcManager();\n  async executeCommand(cmd, _args, opts) {\n    return /* delegate to processes.spawn */;\n  }\n}","handlingStrategy":"type-guard","validationCode":"function supportsExec(sandbox: unknown): sandbox is { executeCommand: NonNullable<unknown> } {\n  return typeof sandbox === 'object' && sandbox !== null && 'executeCommand' in sandbox && typeof (sandbox as { executeCommand?: unknown }).executeCommand === 'function';\n}\nif (!supportsExec(sandbox)) throw new Error('this sandbox cannot run execute-command');","typeGuard":"function supportsExec(sandbox: unknown): sandbox is { executeCommand: (...args: unknown[]) => unknown } {\n  return Boolean(sandbox) && typeof (sandbox as { executeCommand?: unknown }).executeCommand === 'function';\n}","tryCatchPattern":null,"preventionTips":["Only register the execute-command tool against sandboxes that implement it (Daytona).","For spawn-only sandboxes, route through runInSandbox() which falls back to processes.spawn.","Implement executeCommand in custom sandbox adapters."],"tags":["tools","sandbox","capability","agents"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}