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

Accumulation Head | akatz-loops

Pop the First Value Off a Loop's Accumulation

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

AccumulationHead is the "give me the first thing in this accumulation" node, and unlike AccumulationGetItem it does something smarter than index into the list: it splits the accumulation into the first value and everything after it. Two outputs, one move. It's the pop(0) of Akatz-Loop-Nodes, minus the destructive part.

Here's the shape of it:

  • accumulation (input, required) - an ACCUMULATION from a loop body's AccumulateNode.
  • ACCUMULATION (output) - the same accumulation minus its first item.
  • * (output) - the first item itself, in whatever type it was.

The two outputs are meant to be used together. Grab the head, then feed the shrunken accumulation back into the loop or into another AccumulationHead to walk the whole series front-to-back one element at a time. That "reduce the list by one each pass" pattern is exactly what a head/tail pair exists for in functional programming, and it maps cleanly onto the loop mechanics this pack is built around.

When you actually need it

Honestly? Most of the time you don't. If you want a single known item, AccumulationGetItem with an index is simpler. AccumulationHead earns its keep in two scenarios:

  • Processing an accumulation in order. You have a series of loop results (frames, refinement passes) and you want to consume them one at a time, first to last, while keeping the remainder flowing through the graph. Head gives you both halves in one node.
  • Detecting the "first run" case. An empty accumulation returns (accumulation, None) - the first item comes out as None, which any downstream * socket will accept and a first-non-null switch or condition can react to. That makes head a cheap "was this the first iteration?" probe.

One caveat from the source: the node returns the head value as a plain value, not a list. If your loop accumulated batches of images, the head is the first image tensor, and the shrunken accumulation still holds the rest as individual items. Keep that in mind when you wire the * output into something that expects a batch.

Install

Part of Akatz-Loop-Nodes (akatz-ai). Through ComfyUI Manager, search "Akatz-Loop-Nodes"; or:

cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/Akatz-Loop-Nodes

Restart ComfyUI. The only Python dependency in the pack is opencv-python (used by the image nodes), and there are no model files to fetch. The custom_nodes.ComfyUI-Execution-Inversion module path shown on listings is the pack's ancestry from BadCafeCode's execution-inversion demo - you don't install that repo separately.

The one thing that trips people up: expecting the * output to be a list when the accumulation held one value per iteration. It's the raw value. If you want the whole thing back as a proper list, that's what AccumulationToList is for.

CategoryAkatz Loop Nodes/Lists

Inputs (1)

NameTypeDefaultDescription
accumulationACCUMULATION

Outputs (2)

NameTypeDescription
ACCUMULATIONACCUMULATION
**