nebulaflow

Loop Nodes

Loop nodes enable iterative execution within workflows, allowing you to repeat a block of nodes multiple times. NebulaFlow supports two loop modes: fixed iteration count and while variable not empty (foreach-style).

Configuration

Loop Start Node

The Loop Start node initiates a loop block. It must be paired with a Loop End node to define the loop body.

Iterations (Fixed Mode)

Loop Variable Name

Loop Mode

Two modes are available:

  1. Fixed iterations (fixed)
    • Executes the loop body a predetermined number of times.
    • Uses the Iterations field.
    • Optionally, the iteration count can be overridden by connecting a parent node to the special Iterations Override input port.
  2. While variable not empty (while-variable-not-empty)
    • Executes the loop body as long as a collection variable contains items.
    • Useful for processing lists, queues, or dynamic data.
    • Requires a Collection Variable to be specified.

Collection Variable (While Mode Only)

Max Safe Iterations (While Mode Only)

Override Iterations (Fixed Mode Only)

Loop End Node

The Loop End node marks the end of a loop block. It has no configuration options.

Execution Behavior

Fixed Iteration Mode

  1. The loop start node initializes a counter (currentIteration = 0) and a maximum (maxIterations).
  2. For each iteration, the loop body (nodes between Loop Start and Loop End) is executed sequentially.
  3. The loop variable (loopVariable) is updated with the current iteration index (starting from 0).
  4. After the last iteration, execution continues to the node after Loop End.

While Variable Not Empty Mode

  1. The loop start node checks the specified collection variable.
  2. If the variable is empty (or undefined), the loop body is skipped entirely.
  3. If non‑empty, the loop body executes once, then re‑checks the variable.
  4. The loop continues until the variable becomes empty or the Max Safe Iterations limit is reached.
  5. The loop variable (loopVariable) holds the current iteration index (starting from 0) but is not directly tied to the collection items.

Loop Variable Substitution

Within the loop body, the loop variable is available as a template variable. For example, if the loop variable is i, you can use ${i} in:

Nested Loops

Nested loops are not currently supported. If you need nested iteration, consider using a single loop with a composite data structure.

UI Components

Loop Start Node Visuals

Loop End Node Visuals

Property Editor

The Loop Start node’s property editor provides fields for all configuration options. The Loop End node has no editable properties.

Examples

Fixed Iterations (Simple Counter)

Start → Loop Start → LLM (Generate) → CLI (Save) → Loop End → End

While Variable Not Empty (Task Queue)

Start → Variable (tasks = ["task1", "task2", "task3"]) → Loop Start → CLI (Process) → Loop End → End

Dynamic Iteration Count

Start (output = "5") → Loop Start (override enabled) → ... → Loop End → End

Troubleshooting

Loop Never Terminates (While Mode)

Loop Variable Not Available

Override Iterations Not Working

Loop Body Executes Only Once (Fixed Mode)

Loop Body Not Executing at All (While Mode)

Performance Issues with Large Iterations