nebulaflow

Variables & State

NebulaFlow provides mechanisms for storing and manipulating data across workflow execution. Variables allow you to persist values, accumulate results, and reference data in different parts of your workflow.

Variable Node

The Variable Node (variable) stores a single value that can be referenced by other nodes.

Configuration

Execution

  1. Collects outputs from connected parent nodes (in connection order)
  2. Evaluates the template expression using parent outputs and existing variables
  3. Stores the result in the variable map under the given variable name
  4. Outputs the stored value (can be used by downstream nodes)

Example

[LLM Node] → [Variable Node: name="summary"]

The LLM output is stored in the variable summary. Later nodes can reference ${summary}.

Accumulator Node

The Accumulator Node (accumulator) appends to a variable across multiple inputs or loop iterations.

Configuration

Execution

  1. Retrieves the current accumulated value (or initial value if first time)
  2. Evaluates the template expression using parent outputs
  3. Appends a newline and the new value to the accumulated value
  4. Stores the updated value in the variable map
  5. Outputs the accumulated value

Use Cases

Variable Storage & Scope

Execution Context

During workflow execution, NebulaFlow maintains several runtime contexts:

Lifetime

Scope

Template Variables

NebulaFlow uses a template syntax for substituting values in node content.

Parent Output Variables

Reference outputs from connected parent nodes by order:

Variable References

Reference stored variables by name:

Loop Variables

Loop Start nodes automatically create a loop variable:

Accumulator Variables

Accumulator variables are referenced the same way as regular variables:

Evaluation Order

Template evaluation follows this order:

  1. Parent output substitution (${1}, ${2}, …)
  2. Loop variable substitution (${i}, ${loopVar}, …)
  3. Accumulator variable substitution (${accumulatorVar})
  4. Variable substitution (${variableName})

All substitutions happen in a single pass; later substitutions cannot reference earlier ones.

Environment Variables

Environment variables are not substituted in template expressions. However, they can be used in CLI nodes:

CLI Node Environment Mapping

CLI nodes can expose parent outputs as environment variables:

Static Environment Variables

CLI nodes can also define static environment variables with template substitution:

{
  "static": {
    "MY_VAR": "${variableName}",
    "PATH": "/usr/local/bin:${PATH}"
  }
}

System Environment Variables

The extension can read system environment variables (like AMP_API_KEY) for configuration, but these are not available in template expressions.

Examples

Storing LLM Output

Start → LLM Node → Variable Node (name="summary") → Preview Node

The LLM’s response is stored in summary and can be referenced later.

Accumulating Loop Results

Loop Start → CLI Node → Accumulator Node (name="log") → Loop End

Each iteration appends CLI output to the log variable.

Using Variables in CLI Commands

Variable Node (name="filename") → CLI Node (content="cat ${filename}")

The CLI command uses the variable value.

Conditional Branching with Variables

Variable Node (name="status") → If/Else Node (condition="${status} == 'success'")

The variable value determines the branch.

Troubleshooting

Variable Not Found

Symptom: ${variableName} appears unchanged in output.

Causes:

Solution:

Accumulator Not Accumulating

Symptom: Accumulator variable only contains the last value, not all values.

Causes:

Solution:

Loop Variable Not Available

Symptom: ${i} or custom loop variable not substituted.

Causes:

Solution:

Template Syntax Errors

Symptom: Template substitution fails or produces unexpected results.

Causes:

Solution:

Best Practices

  1. Descriptive Names: Use meaningful variable names (userSummary vs var1)
  2. Initialize: Set initial values for variables that may be referenced before assignment
  3. Avoid Conflicts: Don’t reuse variable names for different purposes
  4. Test Incrementally: Use Preview nodes to verify variable values at each step
  5. Document: Add comments to nodes explaining variable usage
  6. Scope Awareness: Remember variables are global; consider prefixing for subflows