Skip to main content

Module loop_node

Module loop_node 

Source
Expand description

"loop" node — while-loop over an inline sub-flow.

Repeatedly executes a sub-flow until either a break_condition is satisfied or max_iterations is reached. The last iteration’s collected output is returned. Each iteration receives the previous one’s output as a variable, enabling accumulation and chaining patterns.

§Config schema

{
  "flow":            { "nodes": [...], "edges": [...] },
  "output_selector": "step.result",
  "max_iterations":  10,
  "break_condition": { "from": "step", "path": "done", "op": "eq", "value": true }
}
FieldTypeRequiredDescription
flowobjectInline sub-flow definition ({ "nodes", "edges" })
output_selectorstringDot path into sub-flow outputs to collect each iteration ("node_id" or "node_id.field")
max_iterationsintegerSafety cap (default 10, minimum 1)
break_conditionConditionIf provided, the loop stops when this condition evaluates to true against the sub-flow’s outputs; without it the loop always runs max_iterations times

§Variables injected into each iteration’s sub-flow

VariableValue
iteration_index0-based iteration counter
loop_outputThe previous iteration’s collected output (null for the first iteration)

§Output schema

{ "output": <last_output_selector_result>, "iterations": 3 }

§Example — retry until success

{
  "id": "retry",
  "type": "loop",
  "data": {
    "max_iterations": 5,
    "output_selector": "check.ok",
    "break_condition": { "from": "check", "path": "ok", "op": "eq", "value": true },
    "flow": {
      "nodes": [
        { "id": "fetch", "type": "http-request", "data": { "url": "https://api.example.com/status" } },
        { "id": "check", "type": "if-else", "data": { "cases": [
          { "id": "ok", "conditions": [{ "from": "fetch", "path": "status", "op": "eq", "value": 200 }] }
        ]}}
      ],
      "edges": [{ "source": "fetch", "target": "check" }]
    }
  }
}

Structs§

LoopNode
Loop node — while-loop over a sub-flow.