Skip to content
Agentic Workflowdocs
v0.9.0Install free

nodes / builtin / flow

Loop

Execute a set of actions repeatedly based on conditions

Flow ExtensionWeb app

Repeat a group of steps while your conditions hold, up to a safety limit.

Loop has two inputs and two outputs:

  • Input (top): where the data first comes in.
  • Loop Back (bottom input): connect the last step of the repeated part here.
  • Loop (output): the steps to repeat start here.
  • Done (output): the workflow continues here once the loop ends.

Each time data reaches the node, it checks the Conditions. While they hold, it sends the data out of Loop; your steps run and come back through Loop Back, and the check runs again. As soon as the conditions fail, or the pass count reaches Max Iterations, the data leaves through Done.

Every pass sends { done, currentIndex, inData }, where currentIndex counts the passes from 1 and inData is the data that arrived. Use {{ $input.currentIndex }} in the repeated steps, for example as a page number.

  • Page through an API until it returns no more results.
  • Retry a step until it reports success.
  • Repeat an action a set number of times.

To work through a long list a few items at a time, Split in Batches is simpler. Most nodes already run once per item, so you rarely need Loop just to handle every item of a list.

SettingTypeWhat it does
Max Iterations NumberMaximum number of loop iterations. Default: 100
Conditions (required)ConditionsThe conditions to evaluate.
Collect results ToggleOutput everything that came back through Loop Back, in order, on Done. Default: Off
One entry per item ToggleUsed with Collect results: a pass that returns a list adds its items one by one. Off: one entry per pass. Default: On

Max Iterations accepts 1 to 1,000. The limit stops a loop whose conditions never fail from freezing the tab.

Turn on Collect results to get, on Done, everything that came back through Loop Back during the passes, in order, as results (one entry per item, or per pass). Without it, Done only carries the last data, as before. Up to 10,000 entries (about 2 MB) are kept; beyond that the list is cut, resultsTruncated is set and the run log warns you. Nested loops each keep their own results.

A Loop with no conditions fails with a clear message. When Max Iterations ends it while the conditions still hold, the run log warns you and the output carries stoppedEarly: true.

  • Done
  • Loop

Each output item has these fields:

FieldTypeWhat it holds
done True/falseTrue when the loop exits through Done
currentIndex Number
inData AnyThe incoming data, unchanged
stoppedEarly True/falseTrue when Max Iterations ended the loop while its condition still held
results ListWith Collect results: what came back through Loop Back on every pass
resultsTruncated True/falseTrue when Collect results stopped at its limit
Shape of an output item
{
"done": true,
"currentIndex": 0,
"inData": null,
"stoppedEarly": true,
"results": [],
"resultsTruncated": true
}

When the loop exits through Done, its pass counter resets, so a loop nested inside another loop starts again from 1 on the next outer pass.

None. This node needs no connection and has no slots for other nodes.

Fetch every page of a paginated API:

  1. A Set Variable node sets hasMore to true.
  2. Loop with the condition {{ $run.hasMore }} (Boolean) is true, Max Iterations 50.
  3. From Loop: Http Request to https://api.example.com/items?page={{ $input.currentIndex }}, then Set Variable stores the response’s hasMore flag. Connect it back to Loop Back.
  4. From Done: continue with the collected data.
  • The loop stops after one pass. The conditions were false on the second check. Make sure the repeated steps update the value the condition reads, and that the last step is connected to Loop Back, not to the top input.
  • The loop always runs exactly Max Iterations times. The conditions never become false. Check the field and operator, or raise the limit if the work really needs more passes.
  • Nothing runs after the loop. Connect the next steps to Done, not to Loop.
  • Split in Batches: work through a list a batch at a time.
  • IF: the same kind of conditions, without repeating.
  • Poll Until: call a URL repeatedly until the response says it is done.
  • Wait: pause between passes.
Edit page

Last updated:

Was this page useful?
Ask Aria about Loop