Accumulation Get Length | akatz-loops
How Many Iterations Did Your Loop Actually Run?
- accumulation
- INT
This is the smallest node in the pack and one of the most useful for keeping loops honest. AccumulationGetLength takes an ACCUMULATION in and gives you one INT out: the number of values it currently holds, i.e. how many times the loop has actually appended. It's the len() of Akatz-Loop-Nodes' loop bookkeeping.
You reach for it in two places. First, as a guard: before you GetItem or index into an accumulation, check the length so you never ask for item 7 of a 5-item list and blow up with an IndexError. Wire length into a PrimitiveInt-style comparison or an ExecutionBlocker condition, and the workflow skips gracefully when the loop produced fewer results than you planned for.
Second, as a number that drives things. The length of an accumulation is a loop iteration count, which makes it a natural input to a scheduler choice, a filename, or the quantity of a subsequent loop. If a run appends once per iteration, length is your honest "it ran this many times" counter - more reliable than trusting what you typed into remaining before the run, since a WhileLoopOpen/WhileLoopClose loop can exit early on its condition.
What it does
Mechanically there's nothing to it - the node returns len(accumulation["accum"]). One required input (accumulation, ACCUMULATION type), one output (INT), no knobs, no defaults to misread. If you've built an accumulation that's empty, it correctly reports 0 rather than erroring, which the item-pulling nodes can't say for themselves.
Install
Part of the Akatz-Loop-Nodes pack (akatz-ai). Install once via ComfyUI Manager - search "Akatz-Loop-Nodes" - or:
cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/Akatz-Loop-Nodes
Restart ComfyUI afterward. The pack's only dependency is opencv-python (needed for its image nodes, not this one), and there are no model downloads. You'll occasionally see this node filed under custom_nodes.ComfyUI-Execution-Inversion in listings - that's the pack's lineage from BadCafeCode's execution-inversion demo, not a separate package you need to install.
Not much troubleshooting to offer for a one-input node that can't fail on empty input. The only real mistake is wiring an ACCUMULATION socket into it before the loop body has run at least once - which yields 0, and if that surprises you, that's the node working as intended: your loop body genuinely hasn't appended yet. If you want to know what's in there at a given index, pair it with AccumulationGetItem.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| accumulation | ACCUMULATION | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |