Skip to content

Loop Close

Terminates or continues an iterative Loop. It evaluates a condition each pass: if the condition is false or the loop has reached its end, it outputs FINISHED? = True and returns the final Data/Aux values; otherwise it schedules the next iteration, passing through the current Data/Aux state.
Preview

Usage

Use with a Loop Open node to repeat a section of your workflow. Connect the LOOP output from Loop Open into this node's LOOP input. Wire any Data/Aux values you want to carry across iterations from Loop Open to this node (and back into the next iteration via Loop Open). Set the condition to control when the loop should continue; leave it as True to rely solely on the Loop Open's range/step controls, or specify an expression that becomes false to stop the loop.

Inputs

FieldRequiredTypeDescriptionExample
LOOPTrueANYLoop state dictionary coming from Loop Open. It contains the current index and status used to manage iterations.{ "id": 123, "index": 0, "finished": false, "last_id": 456 }
conditionTrueSTRINGExpression that must evaluate to True to continue iterating. When it evaluates to False, the loop finalizes and FINISHED? becomes True.index < 10 and data['loss'] > 0.01
dataFalseANYPrimary data carried through the loop. Provide the current iteration's value; it will be output when the loop finishes.{"loss": 0.123, "epoch": 2}
auxFalseANYAuxiliary data carried through the loop.["step1", "step2"]
aux2FalseANYSecond auxiliary data slot.42
aux3FalseANYThird auxiliary data slot.true
aux4FalseANYFourth auxiliary data slot."running-total"

Outputs

FieldTypeDescriptionExample
FINISHED?BOOLEANTrue when the loop has completed (either condition is false or the loop reached its end).true
dataANYFinal Data value after the loop completes.{"loss": 0.008, "epoch": 10}
auxANYFinal Aux value after the loop completes.["step1", "step2", "step3"]
aux2ANYFinal Aux2 value after the loop completes.84
aux3ANYFinal Aux3 value after the loop completes.false
aux4ANYFinal Aux4 value after the loop completes."complete"

Important Notes

  • Condition evaluation: The condition is evaluated each iteration with access to loop variables (such as index and finished) and the provided Data/Aux inputs.
  • Finish behavior: FINISHED? becomes True when the loop is done; at that point, the outputs hold the final Data/Aux values.
  • Data passthrough: To preserve state across iterations, wire Data/Aux outputs from Loop Open to the corresponding inputs of Loop Close, and ensure Loop Open is configured to feed these values back into the next iteration.
  • Empty condition: An empty condition is treated as True, which continues the loop until the Loop Open’s range logic finishes it.
  • Engine requirements: Requires a runtime that supports dynamic execution of looped subgraphs. Keep your Salt runtime up-to-date.

Troubleshooting

  • Loop never ends: Ensure the condition eventually evaluates to False or that Loop Open’s range (start/step/end) will complete. Verify that step is not zero unless you rely solely on the condition.
  • FINISHED? never True: Confirm the LOOP output from Loop Open is connected to the LOOP input of this node and that the condition can become False. Check that Loop Open’s termination criteria are reachable.
  • Data/Aux not preserved: Make sure Loop Open outputs for data/aux are wired into this node’s corresponding inputs (and that Loop Open receives them again for the next iteration).
  • Condition errors: If the loop immediately stops or behaves unexpectedly, check the condition expression for syntax issues or undefined variables.
  • Runtime/version errors: If you see errors about unsupported loop execution, update your Salt environment to a version that supports dynamic loop execution.