- turning variables into the parameters of the next step;
- cutting a large record down to the brief one agent needs;
- comparing an agent’s findings with the submitted data;
- deciding an outcome from rules, and computing scores;
- reshaping a result into a table row, and checking it before it is saved.
Anatomy
The default export may be
async. Return any JSON-serialisable value; return an object when the next step reads fields from it.
The sandbox
Functions run in an isolated JavaScript runtime:
Functions cannot read data themselves. Load what a function needs in earlier workflow steps (a query, a configuration) and select those steps in its
input_filter.
What a function receives in a workflow
Inside a workflow, a function runs through thetrigger_message_processor node. Its input object holds:
- the fields of the selected upstream outputs, merged flat;
node_outputs: those outputs grouped by the node that produced them;- the run’s variables;
_wf_execution_id.
Creating and testing
- Console
- API
Go to Functions → Create Function. Enter a name and a description, paste the YAML into the editor, and click Create Processor. Open the function to test it with a sample input.
Updating a function changes it in place: every workflow that uses it picks up the new code on its next run. Functions are not versioned like agents and workflows. To change a function used by a live workflow safely, create a new function, point a new workflow version at it, and switch versions.
Writing good functions
- Fail loudly.
throw new Error('order_review output is missing')stops the run with that message. Returning a half-result lets a later step misread it. - Read inputs by node name through
node_outputswhen there is more than one upstream node. - Keep rules out of code when people other than developers should change them: read thresholds and tables from a configuration.
- Return reasons with decisions.
{decision, reasons}makes outcomes explainable to users and auditors. - Test with real outputs. Copy an agent’s actual output from a run into the function’s test input.

