Skip to main content

Custom Nodes

When no catalog node does what a step needs, write your own. A custom node is a Python function with an editor, inputs and outputs you define; once saved it appears in the builder's node list beside the catalog nodes.

Open Workflows > Node Manager. The counts at the top are the nodes you can see: the platform catalog (System nodes) and the custom nodes you own or that are shared with you.

Creating a Node​

Click Create Node and fill in the tabs:

TabWhat it holds
Basic InfoCategory and Label (as the node shows in the builder), Type (the identifier workflows use: letters, numbers, hyphens and underscores, fixed once the node is created), Description, an MCP Description STAN reads to decide when to use the node, tags, the node's Version (semantic, starting at 0.0.1) and its icon (chosen from the Lucide set; through the API or SDK, its exact PascalCase name such as Scissors)
Python CodeThe node's code: upload a .py file, or click Or write the code here and write it in the editor. Requirements (pip packages, one per line) go below it
DocumentationA README for people using the node, in Markdown
Input / OutputThe fields the node takes and returns, which the builder offers when you map one node's output to another's input
PermissionsWho else may use or edit the node
ResourcesThe CPU, memory and GPU the node runs with

Click Save. The code is required.

Reading settings from the workflow​

A node reads a key or setting that belongs to the workflow, not to the node (an encryption key, a mode), from the workflow's environment variables, with os.environ:

import os

key = os.environ["MYZOE_DATA_KEY"]

The node gets the variables of the workflow it runs in, in every run, and nothing of the platform's own environment. The workflow's secrets and a run's secret inputs (secretInputs of POST /workflows/:id/execute, for that run only) are read the same way, by name. A node that takes a secret should take its name as a setting and read os.environ[name], failing with the name (never the value) when it is not set, as File Extractor's Passwords Secret does. Credentials for an add-on or data source reach the node through its settings instead: name the add-on or data source there.

Changing a Node​

Edit any tab and click Save. When the change touches the node's code, requirements or documentation, the node's Version must be raised first (+ bump): published code never changes under the same version. A change to anything else (description, label, input and output fields, resources) saves under the same version.

Where a Custom Node Runs​

A custom node's code is yours, so it never runs inside the platform's workflow worker. Every workflow pod has a separate sandbox container, and each call of your node runs there in a process of its own:

  • Its own user, no platform identity. The sandbox has no cloud or cluster credentials and none of the worker's settings or secrets. Platform functions your node calls (storage, workflow state, metrics, progress, connected nodes such as a model) work as before: the worker carries them out for the call.
  • Only the services your node names. self.get_addon(...) and self.get_datasource(...) see the add-ons and data sources your node's configuration names (a field such as addonId, dataSourceId, or any field ending in AddonId or DataSourceId), and nothing else of your account's services.
  • Requirements install in the sandbox. The pip packages you list are installed there, once per pod for each version of the node.
  • Resources. The worker and the sandbox share the pod's size: your node can use what its Resources tab sets.

The catalog nodes that run code you supply run it in the same sandbox: Code (code-transform, 1.5.0 and later), Execute Command (exec, 1.2.0 and later: each command or script gets a directory of its own and only PATH, LANG, LC_ALL, TERM, TMPDIR, USER and the node's env setting, so it has no cwd setting), Code Interpreter (code-interpreter, 1.2.0 and later), Web Agent (web-agent, 1.4.0 and later) and SSH (ssh, 1.2.0 and later: its ssh and scp clients; upload takes the file's content and download answers it, since no worker path is read or written, and a connection username or host beginning with - is refused). A node added to a workflow takes the latest version and keeps it; an older version of these nodes is refused when a run loads it (remove the node and add it again).

Logging metrics from a node​

A node records a number about its run by calling self.log_metric(name, value, unit) in its process (an optional fourth argument level is span, the default, trace or execution):

class Grader(BaseNode):
def process(self, inputs):
score = self.grade(inputs["answer"])
self.log_metric("answer_score", score, "score")
return self.success_response(data={"score": score}, inputs=inputs)

This is the only way a metric is saved: nothing a node returns, and no time or token count the platform measures, becomes a metric unless the node logs it. The metric is stored on the node's span and shows on the run's Execution Metrics card with the node as its source. Do not log token counts: the AI Gateway records every model call a run makes, and the run's AI Gateway Usage card shows its tokens.

log_metric returns once the metric is recorded. While the platform cannot take it (for example while its message queue restarts), the call waits and sends it again; a metric the platform refuses fails the node with an error naming the metric. A metric is never lost without the run showing it.

Version History​

Every save records a version of the node, numbered from 1 (the node as it was created). Click the Version button at the top of the node to open its history: each version with its name, type (minor or major), tag, when it was made and by whom; the node's current version is marked Current.

  • Create Version records the node's present state as a named version, with an optional description, type and tag (for example stable). Search finds versions by name, description or tag.
  • Select a version to see the node as it was then (category, type, label, author, node version, inputs and outputs).
  • Restore makes that version's state the node's next version, named Restored from vN. Nothing is lost: the state it replaces is the version it was saved as, and you can restore that in turn. If the node changed since you opened its history (someone else saved it), the restore is refused; reopen the history and try again.

Deleting a Node​

Delete removes the node, its published files and its version history. A node a workflow or agent still uses cannot be deleted; remove it from those first.