Loop Metadata
See inside your loop without sprinkling debug nodes
- metadata
- current_iteration
- index
- iterations_completed
- limit
- accumulated_count
- accumulated_as
- mode
- stopped_reason
Loop Metadata takes the single metadata wire a WAS For or While loop carries and splits it into plain numbers you can actually act on - which iteration is running, how many have finished, why the loop stopped. ComfyUI loops are famously opaque: you wire the body, it runs N times, and unless you instrumented it you have no idea where it is or whether it ended the way you expected. This node is the instrument.
It's part of WAS Node Suite's new logic layer (menu WAS Suite/Logic/Loop), the v3 set that finally gives ComfyUI real For/While pairs, booleans, and condition chains. You'll only need it once you've started building loops at all, but when you do, it's the difference between guessing and reading.
How it works
The single required input, metadata, is a DICT - and it comes from either end of a loop. An Open node's metadata describes the iteration about to run; a Close node's describes the finished loop. Wire whichever end you care about into the socket and eight outputs come out the other side:
- current_iteration - which iteration this is, counting from 1.
- index - the loop's counter: from
start_indexon a For Loop, from 0 on a While. This is the one that reads a position in a list. - iterations_completed - how many have finished.
- limit - what the loop is counting toward: the iteration count, the frame target, or the safety limit, whichever it's set to.
- accumulated_count - frames collected so far (0 while accumulation is off).
- accumulated_as - how values leave the loop:
final(last value only),batch(one joined batch), orlist(every value). - mode - what ends the loop:
iterations,total_frames, orconditionon a While. - stopped_reason - why it stopped. Never empty: it reads
Still running(with the iteration) while the loop is going andNot startedbefore anything ran.
That last one is the sleeper. stopped_reason gives you a human-readable "why did this stop" without having to reverse-engineer the loop's settings, and it distinguishes "still going" from "not started", which is exactly the state you can't see from outside a loop.
Where it fits
Practically, this node is for two jobs. The first is a progress readout: wire current_iteration, iterations_completed, and limit into a text assembly or display node and you've got a live "frame 12 of 30" without touching the console. The second is decisions: feed accumulated_count into a Logic Compare Numbers to stop a loop that's collected enough frames early, or gate a save node on stopped_reason so you only write output when the loop actually finished rather than hitting its safety limit.
Installing it
Standard WAS Node Suite v3 install - ComfyUI Manager search "WAS Node Suite v3", or:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git
restart. ComfyUI 0.14.0+ and Python 3.10+, no pip dependencies to worry about.
Where people get burned
The easy mistake is wiring the wrong end of the loop. An Open node reports on the iteration about to run, a Close node on the finished loop - if your metadata reads current_iteration 1 forever, you're probably tapped into the Open node of a loop whose body you're watching after the fact. And stopped_reason reads Still running in between, which surprises people who expected a final answer from a mid-loop tap: check it at the Close node for the settled verdict. Otherwise this node has no failure modes of its own - it's just a window.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| metadata | DICT | The metadata output of a loop's Open or Close node; DICT. An Open node describes the iteration about to run, a Close node the finished loop. |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| current_iteration | INT | Which iteration this is; INT, counting from 1. |
| index | INT | The loop's counter; INT. Counts from start_index on a For Loop and from 0 on a While Loop, for reading a position in a list. |
| iterations_completed | INT | How many iterations have finished; INT. |
| limit | INT | What the loop is counting towards; INT. The iteration count, the frame target, or the safety limit, whichever the loop is set to. |
| accumulated_count | INT | Frames collected so far; INT, read from the first slot holding frames. 0 while accumulate is off. |
| accumulated_as | STRING | How the values left the loop; STRING. 'final' for the last value alone, 'batch' for one joined batch, 'list' for every value. |
| mode | STRING | What ends the loop; STRING. 'iterations', 'total_frames', or 'condition' for a While Loop. |
| stopped_reason | STRING | Why the loop stopped; STRING. Never empty: it reads 'Still running' with the iteration while the loop is going, and 'Not started' before anything has run. |