Skip to main content
Execution variables allow nodes to access and share data during workflow execution. They’re resolved using Jinja2 templating before node execution, enabling dynamic data flow throughout your workflow.

Variable Sources

Four main sources of variables are available in any node:

Input Variables

{{$input}}

Access the original input passed to the workflow. Workflow Definition:
Workflow Execution:
Usage in Node:
Resolved to:

Access Nested Input

Usage:

Access Array Elements

Usage:

Node Output Variables

{{$nodes}}

Access outputs from any previously executed node. General Pattern:

plai_agent Node Output

Output Structure:
Access in Downstream Node:

firecrawl Node Output

Output Structure:
Access:

http Node Output

Output Structure:
Access:

markdown_report Node Output

Output Structure:
Access:

loop Node Output

Output Structure: Array of results from each iteration:
Access:

subworkflow Node Output

Output Structure: Same as the subworkflow’s outputs
Access:

Workflow Variables

{{$workflow}}

Access workflow metadata.
Example:

Loop Variables

{{loop}}

Inside loop nodes, access iteration data.
Example Loop:
If input contains: {"items": ["apple", "banana", "cherry"]} Executes three times:
  • Iteration 0: Process item 0: apple
  • Iteration 1: Process item 1: banana
  • Iteration 2: Process item 2: cherry

Variable Interpolation Syntax

Jinja2 Expressions

PLai Framework uses Jinja2 templating, supporting various expressions: String Interpolation:
Filters:
Conditionals:
Arithmetic:

Complete Example

Workflow Definition

Execution Input

Variable Resolution


Variable Resolution Timing

Variables are resolved just before node execution:
  1. Node is selected for execution
  2. All {{...}} expressions are evaluated
  3. Variables are replaced with actual values
  4. Node executes with resolved parameters
Important: Variables must be available at execution time or node fails.

Null/Missing Values

If a variable is missing:
Result: Variable is empty/null, which typically causes node failure. Solution: Verify dependencies and variable names.

Best Practices

DO:
  • Use explicit node dependencies before accessing outputs
  • Use Jinja2 filters for data transformation
  • Test variable interpolation in simple cases first
  • Document complex variable references
  • Use meaningful node IDs for clarity
DON’T:
  • Access node outputs without depending on the node
  • Use undefined variables (causes failures)
  • Over-complicate expressions
  • Depend on variable execution order

Next Steps