Skip to main content
The Loop node creates iterative cycles in your workflow. It’s the most powerful control flow primitive: with it, you can build retry logic, iterative refinement, convergence loops, and multi-pass agents.

How it works

The Loop node has an input on the right (receives data), a loopback output also on the left (sends data back upstream), and an exit output on the right (fires when the loop ends). The only configuration is max iterations – the safety limit on how many times the Loop node runs. It loops back at most one time fewer: with 1 it never loops back; with 2 it loops back at most once. When data reaches the loop body before the Loop node, as in the example below, that’s also the most passes the body gets. When it reaches the Loop node first, the body gets one pass fewer. When data arrives at the loop:
  • If iterations remain, the loopback output fires, sending the data back into the loop body
  • On the final iteration, the exit output fires instead, releasing the data downstream
Nodes after the loop wait until it has finished. A node that reads from inside the loop gets that node’s result from every pass: one value as it is, several as a JSON list in pass order.

Two wiring patterns

Pattern 1: Feed back into an input. Wire the loopback output to a node’s regular input handle. The node re-runs with the new data. Everything between that node and the loop re-runs too. Pattern 2: Trigger re-execution. Wire the loopback output to the trigger handle (bottom) of a Prompt, Workflow, or Script node. This re-runs that specific node with fresh context while preserving its other inputs.

A real-world example

Iterative summarisation: “Keep summarising until it’s short enough.” Wire it like this: Input → Prompt → String (Length) → If (length > 200) → Loop → back to Prompt. The If node’s false output (short enough) goes to Output. The Loop’s exit output also goes to Output as a safety valve. The prompt summarises the text. If the summary is still too long, the loop feeds it back for another pass. When it’s short enough, the If node routes it to the output. If somehow it never gets short enough, the max iterations limit catches it.

Several loops in one workflow

A workflow can hold as many loops as you need, one after another: say, a research prompt with one retry, then a writing prompt with one rewrite. Each loop re-runs only its own nodes, and a node between two loops runs once.
The Loop’s exit output is your safety net: it carries a value only when the loop hits max iterations. Wire it to the same Output node as your success path, so even then you get the best result so far rather than nothing.