Nodes/Prompt Stash/Every Nth Queue (Prompt Stash)
ComfyUI Node

Every Nth Queue (Prompt Stash)

Hold your LLM's prompt for N runs instead of re-rolling it every press

By phazei·Created 2 years ago·Updated about 17 hours ago· 69
Every Nth Queue (Prompt Stash)
    • boolean
    ◄every3►
    ◄valuefalse►

    The problem this thing exists for

    You put an LLM in your graph. It rewrites your rough idea into something structured, you get one good image, and then you hit queue again - and the model rewrites the prompt from scratch. New wording, new subject drift, and if it's an API node, a new charge. You're no longer exploring the seed, you're exploring the language model. What you want is to freeze that prompt, run it twenty times while you fiddle with denoise, and go back to the LLM when you're bored.

    Every Nth Queue outputs True once every N queued runs and False the rest of the time. Wire that into the "Use Input" toggle of a Prompt Stash Saver or Passthrough and the LLM only gets consulted on the True runs; in between, the stash keeps feeding the text it already captured.

    Why the hand-rolled version of this is a trap

    The obvious DIY build is an INT set to increment, a modulo, a compare, a boolean switch. People do this and get stuck, because the increment fires after the run, so the comparison is off by one. Same ghost as every control_after_generate surprise. This node is essentially control_after_generate for a boolean - except the value is decided before the prompt is built.

    How it works, which matters more than it sounds

    The countdown doesn't live in Python. It lives in the node's frontend properties, saved with the workflow. Just before ComfyUI builds each queued prompt, the extension ticks it and writes the resulting True/False into a hidden value widget. The Python side is four lines returning bool(value).

    That buys two things. Off runs are cache-identical - every False run sends the same boolean, so nothing downstream has a reason to re-execute, and ComfyUI keeps the graph warm. And the LLM node doesn't even run: the Savers and Passthroughs read the boolean out of the queued prompt and, when it's definitively False, drop the linked text input before sending. The branch is disconnected, so it never executes.

    The countdown survives restarts because it's stored in the workflow, not in the server session.

    Inputs and outputs

    The only input a beginner touches is every - an INT, default 3, range 1 to 100000. How many queued runs per True.

    The other input, value, is hidden: the frontend sets it at queue time and deletes its socket. Leave it alone.

    The lone output, boolean, wires into a boolean input that reads at queue time - the Saver's "Use Input" toggle is the intended target, since it's the node that knows how to drop its text link. A core Boolean switch works too; it just gets a plain False.

    Below the widgets sit a status line - "True next run" or "True in 3 runs", green when the next run fires - and three buttons: Next, Delay +1, Reset. UI, not inputs. Delay is the one you'll live in: you just got a great image and don't want the prompt to shift.

    Installing it

    It's on the registry, so ComfyUI Manager → search Prompt Stash → install → restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/phazei/ComfyUI-Prompt-Stash
    # restart ComfyUI
    

    No requirements.txt, no models. A few Python files, a js/ folder of frontend extensions, a registry pyproject.toml. The only import worth naming is ComfyUI's own bundled aiohttp/server, already present.

    Where people get burned

    A batch of four counts as four runs. Every batch item is its own queued prompt, so every = 3 with a batch of 4 burns more than one cycle per press.

    Partial and muted don't count. "Run" on a single output node leaves the countdown alone, and a muted or bypassed node never consumes a tick. Handy - but it makes the counter look broken during node-by-node debugging.

    No browser, no countdown. Run it from the API and the frontend never resolves anything: it's a plain Boolean node returning False forever. Set value yourself there.

    A fresh node fires immediately. New nodes start at a countdown of 1, so your first queue is a True. Intentional - nothing's captured yet - but it surprises people expecting to wait three runs.

    Your held text won't run wildcards. A prompt containing {red|blue|green} goes into the encoder literally; the stash doesn't re-process it per run. Holding text constant and expecting it to still rotate tokens inside is a common misread.

    Status line missing after an update? The countdown, status, and buttons are all JavaScript. Hard-refresh the browser (Ctrl/Cmd-Shift-R) or you're running the old extension against new Python.

    Is it worth installing

    If you run an LLM or any non-deterministic text node upstream of your sampler, yes - it's the difference between one good prompt and a new prompt every press. Want a prompt library with no LLM in the loop? The Saver covers that and this node is extra furniture.

    Categoryutils

    Inputs (2)

    NameTypeDefaultDescription
    everyINT31–100000Output True once every this many queued runs.
    valueoptBOOLEANfalse—

    Outputs (1)

    NameTypeDescription
    booleanBOOLEANTrue on every Nth queued run, False otherwise.