Nodes/Akatz-Loop-Nodes/Accumulation Set Item | akatz-loops
ComfyUI Node

Accumulation Set Item | akatz-loops

Edit one element of an accumulation without touching the rest

By akatz-ai·Created about a year ago·Updated 8 months ago· 23
Accumulation Set Item | akatz-loops
  • accumulation
  • value
  • ACCUMULATION
index0

AccumulationSetItemNode | akatz-loops is the "replace one value" utility for this pack's ACCUMULATION type. You've built up a list with Accumulate, you want to swap the value at position 3 for something else, and you don't want to rebuild the whole list from scratch - this node is that. It's the kind of small, unglamorous tool you don't reach for every day, but when a loop's output needs one element corrected (a bad frame, a wrong seed, a value that came out None), it beats re-running the loop.

How it works

It takes an accumulation, an index (INT, default 0), and a value of any type. It makes a shallow copy of the list, sets list[index] = value, and hands back a brand-new ACCUMULATION. Because it copies before mutating, the input accumulation is untouched - which is the right behavior in ComfyUI's stateless graph world, and also why you'll want to wire the output into whatever reads the result, not keep reading the old wire.

The output is the updated ACCUMULATION, ready to flow into the pack's other list nodes or back through a loop.

When you'd actually use it

The realistic case is a loop where one iteration produced garbage. Collect the per-iteration results, and instead of re-running the whole thing, route the accumulation through this node with index set to the bad iteration and value wired to a replacement (say, the previous good frame). Everything else survives untouched.

It also pairs with Accumulation Tail and Get Float From List when you're hand-tweaking a list before feeding it to a downstream consumer.

Installing it

Part of the Akatz-Loop-Nodes pack (repo ComfyUI-Execution-Inversion):

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

Or via ComfyUI Manager, searching "Akatz-Loop-Nodes". opencv-python is the only Python dependency; no model files.

Gotchas

Index out of range is a hard IndexError - there's no clamping or wrap-around. If you're setting an index based on a loop counter, remember the counter runs 0-based against the accumulation's length; Accumulation Get Length is there if you need to check first.

Also keep in mind the type is pack-private: the value socket accepts anything, but the node never re-types, so put a float in and a float comes out at that slot. If the downstream node expected an IMAGE and you replaced slot 2 with a float, the failure shows up downstream, not here.

CategoryAkatz Loop Nodes/Lists

Inputs (3)

NameTypeDefaultDescription
accumulationACCUMULATION
indexINT0
value*

Outputs (1)

NameTypeDescription
ACCUMULATIONACCUMULATION