For the curious. Your AI agent handles template variables automatically. This explains how data flows between nodes and what’s happening when you see
${variable} syntax in workflows or traces.${variable} syntax in a workflow, it’s pulling data from previous nodes, workflow inputs, or nested structures.
Basic syntax
The${variable} syntax accesses values from the shared store:
${read.content} pulls the content output from the read node.
Nested access
Template variables can traverse deeply nested structures:apinode’s outputresponsekeyitemsarray- First element (
[0]) namefield
Type preservation
Template variables preserve the original data type when used alone. When combined with text, they become strings.
| Template | Original value | Result | Type |
|---|---|---|---|
"${count}" | 42 (int) | 42 | int |
"Count: ${count}" | 42 (int) | "Count: 42" | string |
"${config}" | {"key": "val"} | {"key": "val"} | dict |
"Prefix ${config}" | {"key": "val"} | "Prefix {\"key\": \"val\"}" | string |
${var}) preserve type. Complex templates (any surrounding text) become strings.
Inline objects
This type preservation makes inline object construction intuitive:settings is {"timeout": 30} and results is {"status": "ok"}, the resolved stdin is:
JSON auto-parsing
When a template accesses nested fields on a JSON string, pflow automatically parses it:fetch.stdout is a string containing JSON, the nested access ${fetch.stdout.results[0].name} works because pflow:
- Sees you’re trying to access
.results - Attempts to parse
stdoutas JSON - Traverses the parsed structure
- Returns the value at
results[0].name
Workflow inputs
Template variables also reference workflow inputs declared in the workflow definition:Stdin input
Inputs can receive piped data by addingstdin: true. See Stdin input for details.
Array notation
Array elements are accessed using bracket notation:Batch processing
In batch nodes, a special template variable (${item} by default) represents the current item:
as: "file" creates ${file} as the item variable. See Batch processing for details.
Escaping
Literal${...} text (not a template variable) uses double dollar signs to escape:
Price: ${PRICE} instead of trying to resolve a variable.
Validation
pflow validates template variables at workflow creation time:- Unknown variables → Error: “Unresolved variable:
${typo}” - Type mismatches → Warning: “Expected string, got dict”
- Invalid syntax → Error: “Invalid template:
${foo.}”
Compile-time vs runtime validation
Compile-time vs runtime validation
Most validation happens when the workflow is created (compile-time). Some validations happen during execution (runtime):
- Compile-time: Variable existence, type compatibility, syntax
- Runtime: JSON parsing success, nested access on dynamic values
Related
- Nodes overview - How nodes use template variables
- Batch processing - Item variables in batch nodes
- Debugging - Troubleshooting template issues

