Nodes/Dynamic Prompt Nodes/Dynamic Prompt (Cyclical)
ComfyUI Node

Dynamic Prompt (Cyclical)

The Same Rolls, in the Same Order, Every Time

By cesasol·Created 6 months ago·Updated 4 months ago· 0
Dynamic Prompt (Cyclical)
    • prompt
    template

    Random is a gamble, Combinatorial is a flood. Dynamic Prompt (Cyclical) is the third option nobody talks about: it walks through your options in order, one step per run, and wraps around. Template {day|dusk|night} gives you day on the first run, dusk on the second, night on the third, then back to day. Same sequence, forever, with no dice involved.

    This is the node for anything that wants a fixed rotation rather than a random draw - A/B testing two styles, cycling through your three favorite LoRA setups across a session, or rotating lighting schemes so a comparison set is fair. It's the least flashy node in the pack and arguably the most boring, which is exactly why it's useful: boring and predictable is a feature when you're methodical.

    How it works

    The node keeps a per-instance counter dict (cycle_counters). Each execution advances the counter and picks the next option - the explicit {@a|b|c} syntax marks a group as cyclical, though plain {a|b|c} in this node also cycles. A few details worth knowing:

    • Counters reset when the template string changes. Edit the prompt and the cycle restarts from the first option, which saves you from mentally tracking where you were.
    • IS_CHANGED always returns nan, so the node re-executes on every queue run rather than being cached by an unchanged input. That's what makes the counter actually advance - without it, ComfyUI would consider the node "unchanged" and skip it.
    • It's deterministic: the RNG is seeded with 0, so nothing here is left to chance.

    Because the counters live in the node instance's memory, a full restart of ComfyUI also resets the cycle. If your rotation spans sessions, start counting again.

    The inputs that matter

    There's exactly one: template (multiline STRING). No seed, no index - you don't get to pick the position, the node does, and that's the point. The single prompt (STRING) output feeds your CLIPTextEncode like any other prompt source. For a full pass through the sequence, queue the workflow N times (or wire the output into a batch path and drive it per item); each execution advances one step.

    Installing it

    Part of the same pack as Random and Combinatorial: search Dynamic Prompt Nodes in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cesasol/dynamic_prompt_nodes
    cd dynamic_prompt_nodes
    pip install -e .
    

    Just lark and pyyaml as dependencies, no models to download. Wildcard files in ComfyUI/custom_nodes/dynamic_prompt_nodes/wildcards/ or ComfyUI/models/wildcards/ work here too, and cyclical wildcards are marked with __@name__.

    Where people get burned

    The one real surprise: because the counter lives in the node instance, you get one step per workflow execution. If you're expecting a batch of eight images to each advance the cycle, that's not what happens - the batch shares a single execution. Queue repeatedly or drive the output through a per-item batch mechanism to step through the sequence. And if your rotation seems to restart mid-session, check whether you touched the template - any edit resets the counter by design.

    CategoryDynamic Prompts

    Inputs (1)

    NameTypeDefaultDescription
    templateSTRING

    Outputs (1)

    NameTypeDescription
    promptSTRING