AQ_Increment
A counter that ticks up every run — for seeds, indices, and rotating variants
- INT
The dumbest useful node in the pack: return an integer, and make it bigger by one every time the graph runs. No randomness, no math, just a counter that lives for the whole ComfyUI session. It sounds trivial until you want a different seed per run without touching the seed node, or a file index that doesn't overwrite itself.
How it works
It keeps a counter as a class-level variable. On the first run - or whenever force_initial is switched on - it sets the counter to initial and returns that. After that, each execution returns the current value and increments it. force_initial is your reset button: flip it true, run once, flip it back, and the count restarts from initial.
Inputs
initial- where the count starts, default 0.force_initial- boolean, default false. True forces a reset toinitial.
Output
INT.
What to use it for
Feed it into a seed node (with control_after_generate set to fixed) so every run gets a different seed automatically. Or drive a save prefix / index so outputs don't overwrite. Pair it with AQ_ImageMaskSwitch (same pack) and it rotates through image variants on every run.
Install
Part of AQnodes:
cd ComfyUI/custom_nodes
git clone https://github.com/2frames/ComfyUI-AQnodes
cd ComfyUI-AQnodes
pip install -r requirements.txt
or search "AQnodes" in ComfyUI Manager and restart.
Gotchas
The state is class-level and shared across all workflows in your ComfyUI session. Two AQ_Increment nodes are the same counter - there's a single underlying variable - so you can't have two independent counters without editing code. It keeps counting across workflows, so running workflow B and coming back to A means A continues from B's number. And it resets when you restart ComfyUI. None of that is a bug; it's just what "session-persistent counter" means in practice. If you need a one-shot random integer instead, the same file registers AQ_Random.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| initial | INT | 0 | — |
| force_initial | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |