Nodes/FlowNodes/πŸ”Ί Get persistent dict
ComfyUI Node

πŸ”Ί Get persistent dict

Memory that survives between runs

By gitmyloΒ·Created 2 years agoΒ·Updated about a year agoΒ· 13
πŸ”Ί Get persistent dict
  • no_cache
  • Persistent dict

Every ComfyUI workflow starts fresh. Between one run and the next, everything resets - seeds reroll, counters zero out, accumulated values vanish. "πŸ”Ί Get persistent dict" is FlowNodes' deliberate exception: a single Python dict that lives in the server process and survives across runs. Run once, write to it, run again, read what you wrote. It's state, which ComfyUI doesn't normally give you.

The mechanism is unapologetically simple. In the pack's code:

persistent_object = {}

def get_persistent(self, **kwargs):
    global persistent_object
    return (persistent_object,)

A module-level dict. Every time you run, you get a reference to the same dictionary. That's it - no files, no serialization, no saving to the workflow. Which is exactly what the README wants you to understand: "This is a dictionary which is available between runs. Note that it resets when the server is restarted. And it's not stored in the workflow."

The lifecycle, stated plainly

Three rules define what this node can and can't do:

  1. Persists between runs - a counter that increments each queue, an accumulator of seeds, a place to stash the last prompt.
  2. Resets on server restart - stop ComfyUI, the dict is gone. It's not durable storage; treat it as session memory, not a database.
  3. Not in the workflow - sharing a workflow file doesn't share the dict. Anyone who loads your workflow starts from an empty one.

Because it's a shared object mutated in place, it's the same reference problem as Generic operation (write): anyone holding the dict sees every change.

How you use it

The node has one required input - the no_cache dummy socket, which forces it to re-fetch every run (critical, since the whole point is reading current state) - and one output, Persistent dict.

The write path: connect the dict into a πŸ“– Generic operation (write) node and set keys with f[s] = t. Or mutate it directly inside the 🐍 Execute Python node - because the script runs in the same process, it can reach in and change the same object. The README frames the read path the same way: it's specifically "for changing things between runs."

A realistic example: track how many images a batch run produced. After the sampler, an Execute Python increments a counter in the persistent dict; next run, a Get persistent dict + Generic operation reads it back and feeds a filename. You've just built memory into a stateless graph.

Install

Part of the FlowNodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/gitmylo/FlowNodes
# restart ComfyUI

or ComfyUI Manager β†’ search FlowNodes β†’ install. No Python dependencies, no models.

Troubleshooting

  • "It reset, where did my data go?" - you restarted the server, or the process crashed and came back. That's by design; the README says so.
  • Reads always empty - the writes must have happened in a previous run and the write node must have actually executed (check its no_cache socket). Also, ComfyUI caching can skip a write if nothing downstream demanded it.
  • Two workflows both get "the same" dict - yes, it's global to the server process, shared across all open workflows. That's usually fine; it's also why you should namespace your keys.
  • Need persistence across restarts - this isn't the tool. Write to a file from Execute Python instead.
CategoryπŸ”‚ FlowNodes/function

Inputs (1)

NameTypeDefaultDescription
no_cacheNO_CACHEβ€”

Outputs (1)

NameTypeDescription
Persistent dict*β€”