Nodes/Akatz-Loop-Nodes/Accumulation Tail | akatz-loops
ComfyUI Node

Accumulation Tail | akatz-loops

Pop the last value off an accumulation

By akatz-ai·Created about a year ago·Updated 8 months ago· 23
Accumulation Tail | akatz-loops
  • accumulation
  • ACCUMULATION
  • *

AccumulationTailNode | akatz-loops is the "last element" accessor for this pack's ACCUMULATION type. It's the sibling of the pack's Accumulation Head (first element) and one of the two ways you'll pull values out of an accumulated list - this one gives you the final item, plus the list with that item removed.

How it works

Feed it an accumulation and you get two outputs:

  • ACCUMULATION - the original list minus its last element (a fresh object; the input is untouched).
  • * - the last value itself, of whatever type you accumulated.

That dual output is what makes it useful in two different situations. In a loop, you can use the ACCUMULATION output as the "state so far" that gets threaded back into the next iteration - effectively building a stack where the tail pops off the most recent result. Or, after the loop finishes, you just want the last image or last float, and the * output hands it straight to a preview or sampler.

The pattern that matters

After a ForLoopOpen/ForLoopClose run that accumulated N values, the final accumulation is still the full list - the last frame is buried at the end. Wire it through here and the * output is the last frame, ready for preview or save. If you'd rather grab a specific slot, Accumulation Get Item with an index does that; if you want everything as a plain Python list for another pack's nodes, Accumulation To List is the converter.

One quirk worth knowing: if the accumulation is empty, the node returns None as the tail value rather than crashing. That's a small mercy, but it means the * output can be None - wire it into a node that expects a real value and you'll get a type error downstream.

Installing it

Same pack, same routine:

cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Execution-Inversion
# restart ComfyUI

Or ComfyUI Manager → "Akatz-Loop-Nodes". Only dependency is opencv-python; nothing to download.

Gotchas

This pops from the end, not the front - that's Accumulation Head's job, and mixing the two up is the usual mistake. And remember the "copy, don't mutate" rule: the ACCUMULATION output is a new object, so if you wire the input into two places expecting two different tails, both get the same full list. For a true stack where each iteration sees a shrinking list, thread the ACCUMULATION output back through the loop's pass-through value.

CategoryAkatz Loop Nodes/Lists

Inputs (1)

NameTypeDefaultDescription
accumulationACCUMULATION

Outputs (2)

NameTypeDescription
ACCUMULATIONACCUMULATION
**