Nodes/Boyonodes/Boyo While Loop Start
ComfyUI Node

Boyo While Loop Start

Open a while loop the EasyUse way, without installing EasyUse

By DragonDiffusionbyBoyo·Created 2 years ago·Updated 26 days ago· 16
Boyo While Loop Start
  • initial_value0
  • initial_value1
  • initial_value2
  • initial_value3
  • initial_value4
  • initial_value5
  • initial_value6
  • initial_value7
  • initial_value8
  • initial_value9
  • flow
  • value0
  • value1
  • value2
  • value3
  • value4
  • value5
  • value6
  • value7
  • value8
  • value9
conditiontrue
loop_id1
reset_signal0

ComfyUI doesn't do loops. Its execution model is a directed graph that runs once, and anything that wants to iterate - generate video chunk by chunk, keep refining until a quality score clears a threshold, chain passes until a condition flips - has to smuggle the cycle in through custom execution logic. That's exactly what the Boyo while-loop pair does. Boyo While Loop Start is the opening parenthesis: it declares the loop, carries a condition, and initializes the values that flow around it.

This is a faithful reimplementation of EasyUse's whileLoopStart/whileLoopEnd pair - the docstring says "exact replication ... with reset capability" - for people who don't want EasyUse's whole dependency tree. If you've seen EasyUse loops in a workflow you downloaded, you'll recognize the shape immediately: a Start node feeding a chain of processing nodes whose results loop back to an End node, with the End deciding whether to run it all again.

How it works

The loop is keyed by an integer loop_id. Internally, Boyonodes keeps an in-memory cache per loop_id and passes a flow token (under the hood, that cache key) out of the flow output so the matching End node knows which loop it's closing. The condition input (a BOOLEAN, default true) is what the Start presents to the graph; the End re-evaluates it each iteration. The ten initial_value0 through initial_value9 inputs are wildcard pass-throughs - images, latents, strings, whatever your iteration actually changes - and they come back out as value0value9 so you can feed them forward into your loop body.

The reset_signal input (INT, default 0) is the escape hatch: when its value changes between runs, the loop's cache is wiped, so a fresh loop starts clean instead of resuming from wherever the last queue left it. Pair it with the pack's Boyo Loop Reset node or drive it from a save node's completion signal.

The inputs that matter

  • condition - the continue flag. This is what your loop body's logic feeds back into.
  • loop_id - must match the End node's loop_id, or the two won't know they're a pair.
  • reset_signal - bump it to force a clean start.
  • initial_value0–9 - any type; these are what make the loop useful.

Outputs are flow (the loop token, wired to the End node's flow input) plus value0–9.

Install

It's in ComfyUI Manager under "Boyonodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/DragonDiffusionbyBoyo/Boyonodes

Restart ComfyUI. No extra dependencies - this is pure Python execution logic, no models, no ffmpeg, nothing to download.

Where people get burned

Loops are the sharpest edge in ComfyUI, and the pack's own notes warn to use them carefully in complex graphs. The classic mistakes: mismatched loop_id between Start and End (silent weirdness rather than a clean error), and forgetting that the cache lives in memory - a ComfyUI restart mid-loop loses state, so a loop that was "running" may start over. And because these replicate EasyUse's approach, don't mix a Boyo Start with an EasyUse End; the flow tokens won't line up. If your iteration count is fixed rather than conditional, the pack's for-loop nodes are the simpler tool - reach for those instead.

CategoryBoyo/Logic/While Loop

Inputs (13)

NameTypeDefaultDescription
conditionBOOLEANtrue
loop_idINT11–999
reset_signaloptINT0
initial_value0opt*
initial_value1opt*
initial_value2opt*
initial_value3opt*
initial_value4opt*
initial_value5opt*
initial_value6opt*
initial_value7opt*
initial_value8opt*
initial_value9opt*

Outputs (11)

NameTypeDescription
flowFLOW_CONTROL
value0*
value1*
value2*
value3*
value4*
value5*
value6*
value7*
value8*
value9*