Agent commands. Your AI agent uses this node in workflows. You don’t configure it directly.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
code | str | Yes | - | Python code (or path to .py file, e.g., ./scripts/transform.py) with type-annotated inputs and a result variable |
inputs | dict | No | {} | Variable name to value mapping (template variables go here) |
timeout | int | No | 30 | Maximum execution time in seconds |
requires | list | No | [] | Package dependencies (documentation-only, not enforced) |
Output
| Key | Type | Description |
|---|---|---|
result | any | Value of the result variable after execution |
stdout | str | Captured print() output |
stderr | str | Captured stderr output |
error | str | Error message (only on failure) |
Type annotations
Every input variable and theresult variable must have a type annotation. pflow uses these to validate inputs before your code runs — so a wrong type gets caught immediately with a fix suggestion, not as a cryptic Python error mid-workflow.
Supported types
Supported types
| Annotation | Python type | Notes |
|---|---|---|
int | int | |
float | int, float | Integers are accepted where float is declared |
str | str | |
bool | bool | |
list | list | Generic params like list[dict] check outer type only |
dict | dict | Generic params like dict[str, Any] check outer type only |
set | set | |
tuple | tuple | |
bytes | bytes | |
object | — | Skips type validation entirely |
list[dict] validates that the value is a list, but doesn’t check whether the elements are dicts.Template placement
inputs dict get resolved before your code runs. By the time Python sees data, it’s already a native object — no parsing needed.
Inputs are native objects
Upstream JSON is auto-parsed before your code runs. If the source node produced a JSON string, declaredict or list, not str — you get real Python objects, not strings.
| Upstream output | Declare as | You get |
|---|---|---|
JSON string '{"a": 1}' | dict | {"a": 1} |
JSON array '[1, 2, 3]' | list | [1, 2, 3] |
| Plain text | str | The text string |
| Number | int or float | The number |
Examples
Simple transformation
Multiple inputs
${merge-sources.result.items}, ${merge-sources.result.count}.
No inputs
Using subprocess
Imports
Standard library imports work without restrictions —json, re, subprocess, pathlib, datetime.
Third-party packages work too, but they need to be installed in pflow’s environment.
Installing third-party packages
Installing third-party packages
pflow runs in an isolated environment, so uv tool (replaces the full environment — list existing extras first):A simpler way to manage code node dependencies is coming in a future release.
pip install pandas won’t work. How you add packages depends on how you installed pflow:pipx (simpler — additive, doesn’t touch existing packages):Security
External code file
For larger scripts, reference an external Python file. The file is read and used as the code block. Path is relative to the workflow file.Error handling
Errors include line numbers, the actual source line, and a suggestion for how to fix it. For example, a type mismatch looks like:| Error | Cause | What you see |
|---|---|---|
| Missing annotation | Input or result has no type annotation | Which variable needs an annotation |
| Type mismatch | Input value doesn’t match declared type | Expected vs actual type, with fix suggestion |
NameError | Undefined variable | Variable name, suggestion to add to inputs |
ImportError | Module not installed | Module name, install command |
| Timeout | Code exceeded time limit | Current timeout, suggestion to increase |
SyntaxError | Invalid Python | Line number from Python parser |
| Runtime error | Any other exception | Exception type, line number, source line |

