Skip to main content
View source

Python

View as Markdown

A RocketRide tool node that lets an agent run small Python calculations or transformations when a built-in tool is not enough. Pick it for bounded code execution, not for integrations that need filesystem, network, or subprocess access.

About RestrictedPython

RestrictedPython is a Python library for defining and enforcing a restricted execution environment. This node uses it to compile agent-supplied source with restricted guards and safe builtins.

What it does

The node exposes one sandboxed execution tool and has no data lanes. It is suited to calculations, data reshaping, text processing, and other code that can run with the allowlisted imports; choose a purpose-built integration when the task needs an external system. The registered tool validates its input before passing it to the sandbox and returns the sandbox result rather than raising for an ordinary script error.

As a tool

The server-name prefix defaults to python, so the registered function is python.execute.

FunctionDescription
python.executeRun Python source in the restricted sandbox.

code is required and must be a non-empty string. Use print() for visible output and assign a JSON-compatible value to result to return it structurally. The response has stdout, stderr, exit_code (0 success, 1 exception, -1 timeout), timed_out, and result; blocked imports or invalid code are reported through that result.

Configuration

Start with the default timeout and no additional modules. The server name is normally only changed to avoid a tool-name collision.

Execution timeout (seconds)

The value is clamped to 1–1200 seconds; absent or invalid input uses the sandbox default. Raise it only for a computation that genuinely needs longer, because an agent call remains occupied until the sandbox returns or times out.

Additional Allowed Modules

Each configured module name is added to the sandbox's import allowlist. Keep this list empty for the narrowest environment; add a module only when the agent needs it and you accept the capabilities that module exposes. The tool description tells the agent the effective allowed-import list, and every other import raises ImportError.

Notes

Sandbox boundary

The node uses RestrictedPython's restricted compiler and safe builtins. A tool call requires a JSON object; a missing, blank, or non-string code value raises a validation error before execution.

Upstream docs

Schema

FieldTypeDescriptionDefault
tool_python.allowedModulesarrayAdditional Allowed Modules
Modules the agent is allowed to import, in addition to the built-in defaults (math, json, re, collections, datetime, etc.).
tool_python.moduleNamestringModule name""
tool_python.serverNamestringServer name
Namespace prefix for the tool: .execute
"python"
tool_python.timeoutintegerExecution timeout (seconds)
Maximum seconds a script may run before it is killed. Useful for long-running operations like network scans. Default is 20s, max is 1200s.
20