判断外循环尾
The condition that keeps re-queuing your graph
- start
- ANY
- obj
OutDoWhileEnd ("判断外循环尾", outer do-while end) closes the loop that OutDoWhileStart opens. It takes the loop token, a condition value, and a payload, and decides whether to run the loop body again - by re-queuing the whole graph on the backend. If the condition is truthy, ComfyUI runs the loop body again; when it goes falsy, the loop ends and the graph proceeds.
Read that again: this is a node that re-queues your entire workflow from inside the queue. It's the mechanism the ComfyUI_Lam loop family is built on, and it's only possible because the pack patches ComfyUI's core execution.py (the "modify files" step in the README). That patch is the load-bearing wall here - without it, the loop never re-triggers and you're left with a graph that runs once and stops. It's also the wall that falls down on every ComfyUI update, and when it falls, it takes the whole app with it, not just this node.
How it works
You feed it three required inputs:
start- theOUTDOWHILEtoken from the matching OutDoWhileStart.ANY- the loop condition. Truthy = loop again, falsy = stop. This is the thing that makes it a do-while: the body runs at least once, then the condition decides.obj- the loop payload, typically the data you're refining or processing, passed back through.
When ANY is truthy, it re-queues the prompt with the loop counter bumped and the payload carried forward. It's an output node, so it also reports status to the UI - you get a running log of "第N轮结束" (round N ended) and a final "整个循环结束" (whole loop ended) when it stops. That status feed is genuinely useful; without it you'd have no idea how many passes ran.
Common issues
The big one: no built-in max-iteration guard. A condition that never goes falsy loops until you stop the queue manually. If you're using a countdown condition, make it one you can't accidentally feed a permanent truthy value into - a common trick is to terminate on i >= max_iterations, where i comes from the Start node's 循环次数.
Second: the execution.py patch. It's invasive, it breaks on updates, and the failure mode (ComfyUI won't boot or loops misbehave after an update) is the kind that sends people to reinstall. Back up execution.py before patching. Honestly, think hard about whether you need a do-while at all - for "run N times," a simple batch or iteration approach avoids the core patch entirely, and it won't break your whole install the next time ComfyUI ships an update. Use this only when the loop count genuinely depends on the result of the previous pass, which is the one thing the hack does that batching can't.
The pack's usual caveats apply: Chinese-language UI, minimal community presence, and on uninstall delete ComfyUI/web/extensions/lam to clear the leftover frontend popup.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| start | OUTDOWHILE | — | |
| ANY | * | — | |
| obj | * | — |
Outputs (0)
No outputs