Skip to main content

Run Agent Code Node

warning

This node is in beta and may not be fully tested or documented. Use with caution.

Expose an execute_code tool that lets agents execute TypeScript code in a sandbox with access to all connected MCP tools.

Properties

LabelPropertyTypeDescriptionDefault ValueIs Required
Tool NametoolNameOverridebotdojo/types/stringOptional. If empty, defaults to "execute_code".null
Tool LabeltoolLabelbotdojo/types/stringOptional. If empty, defaults to "Execute Code".null
Tool InstructionstoolInstructionsOverridebotdojo/types/stringExecute TypeScript code in a sandboxed environment with access to all tools via resource.call().

Provide code inline via 'source' or reference a workspace file via 'sourceFile'.

Function signature:
typescript<br/>async function execute(input, resource) \{<br/> // input: your input data<br/> // resource: object with call() method for invoking tools<br/>\}<br/>

Calling tools:
typescript<br/>const result = await resource.call(\{<br/> mcp_uri: "agent://me/TOOLS.md", // Required: URI of the MCP providing the tool<br/> tool_name: "memory_list", // Tool name (with any prefixes)<br/> parameters: \{ // Tool-specific parameters<br/> path: "docs/"<br/> \}<br/>\});<br/>

Complete example:
typescript<br/>async function execute(input, resource) \{<br/> const processed = input.value * 2;<br/> const memoryFiles = await resource.call(\{<br/> mcp_uri: "agent://me/TOOLS.md",<br/> tool_name: "memory_list",<br/> parameters: \{ path: "docs/" \}<br/> \});<br/> console.log("Files found:", memoryFiles);<br/> return \{ processed, memoryFiles \};<br/>\}<br/>

Use dryRun: true to check for compile errors without executing.

Returns { output, logs } on success or { output: null, logs, error } on failure. logs contains any console.log/warn/error calls made during execution.
null
Hide Step in ChattoolHideStepbotdojo/types/booleanWhen enabled, the tool will not be shown to the user in the chat.false
Hide Step DetailstoolHideStepDetailsbotdojo/types/booleanWhen enabled, the tool step details will be hidden from the user.false

Output

LabelPropertyTypeDescriptionDefault Value
Tooltoolbotdojo/interface/toolThe execute_code toolnull