Using Sandbox Nodes

Run a Bash or Python script, or an agent working towards a goal, on a Linux machine as a workflow step.

Overview

A Sandbox node runs real code as a workflow step, on a small Linux machine with internet access, Python and common command-line tools. It either runs a script you write (Bash or Python) or, in agent mode, lets a model reach a goal by running commands. Use it for work no connector or transform can do: building an Excel file or a zip, reading a format no connector reads, or talking to a service through a command-line tool.

Every sandbox step in one run shares the same machine and working folder, so a file one step writes is there for the next. Values from earlier steps reach the sandbox only as inputs, and credentials only through the connections you assign to the step. Nothing carries over to the next run.

Steps

  1. In the workflow designer, add a Sandbox node from the node palette and connect it after the step whose data it needs.
  2. Under Runs, pick A script you write or An agent working towards a goal.
  3. Under Inputs, add each value the step needs, for example orders = {{ fetched.rows }}. In Python it is data["orders"]; in Bash, $INPUT_ORDERS.
  4. If the step needs credentials, click Add connection under Connections, pick a connection and give it a short name such as FTP. Its settings arrive as FTP_HOST, FTP_PASSWORD and so on.
  5. Write the script (Python or Bash), or describe the goal in plain words.
  6. Set an Output Variable, such as report, and reference the result in later steps as {{ report.result }} or a file as {{ report.files[0] }}.
  7. Save the workflow and run it. The step's output shows the result, files, exit code and the end of its output.

Script or Agent

  • Script - runs exactly what you write, the same way every run. Up to 15 minutes per step. Prefer it whenever you know the steps.
  • Agent - a model works out the commands each run. Up to 4 minutes per step, and its model use is billed in credits like an agent step. Use it when the steps cannot be known in advance, such as an unfamiliar file format.

Credentials and Secret Values

Never type a password or API key into a script, goal or input. Assign a connection instead: only the connections listed on the step reach it, as environment variables named <NAME>_<KEY>. For credentials no connector holds, such as a database password, create a Secret connection on the Connections page and enter key/value pairs; a Secret named VENDOR with the key API_KEY arrives as $VENDOR_API_KEY. Saved values are never shown again: the form lists the saved keys, a blank value keeps what is saved, and a new value replaces it.

Secret values are shown as *** in the step's output and logs. Each connection has a Sandbox allowed setting on the Connections page; switch it to Block sandbox steps to keep a connection out of every sandbox step.

Two kinds of connection never reach a sandbox step: Private connections (make the connection visible to the organization to use it), and connections under a governance policy that requires approval, blocks changes or limits tools or hosts, either on the connection or for the whole workspace. A step assigned one fails with a message naming it.

Limits

  • One sandbox runs at a time per workspace. Another run's sandbox step waits up to 10 minutes for it.
  • A run has 15 minutes of sandbox time across all its sandbox steps, and it counts towards your plan's monthly execution time.
  • Up to 20 output files and 50 MB per step.
  • In a test run, sandbox steps are not run; they return a placeholder.

Tips

  • Use a Transform node or the Code connector for simple reshapes and calculations; they start instantly.
  • Write one output file per step and pass it on with {{ <output>.files[0] }} to a File Store save step or an email attachment.
  • Install a package at the start of a Python script with pip install -q; later sandbox steps in the same run can use it.
  • Turn off Fail on a non-zero exit when a later step should read exitCode and decide what to do.

Common Pitfalls

  • Templates in the script - {{ }} inside a script or goal is never filled in. Add the value as an input and read it from data or $INPUT_<NAME>.
  • A connection not picked - a step built by the AI chat names the connection it needs but leaves the choice to you. The run fails until you pick one.
  • Files lost after a wait - if a run waits more than an hour at a Human Approval step, files left on the machine by earlier sandbox steps are gone. Pass files on through outputs.
  • Printing secrets - masking hides values in the output, but a script can still send them anywhere. Only use a credential for the service it belongs to.
  • Agents with credentials - text an agent reads (a web page, a file, an email) could steer it into misusing a credential. Use a script step for work with connections.

Related Articles

Learn More

Ready to build this?

Start on the free plan: 500 AI credits a month, no card needed.

Start free

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.