Nodes/ComfyUI_KaleidiaNodes/Sequential Prompt
ComfyUI Node

Sequential Prompt

The Sequential Prompt node

By Kaleidia·Created 12 months ago·Updated 2 days ago· 0
Sequential Prompt
    • STRING
    template
    sequence_mode
    sequential_passes2
    index_offset0
    join_styleperiod
    reset_counterfalse
    debugfalse
    clear_cachefalse

    Sequential Prompt is the sibling of KaleidiaNodes' Dynamic Prompt node, and the difference is the whole point: where Dynamic Prompt rolls dice, this one walks a list. Given {blue|red|yellow|green} {car|cat|tree}, Dynamic Prompt might hand you "green cat" three runs in a row; Sequential Prompt methodically produces every combination before it starts over. That makes it the node you reach for when you're not gambling on variety but guaranteeing it - batch a character reference sheet and know the same combo never lands twice in the same 32-image run.

    It uses the exact same wildcard engine, so everything from the Dynamic Prompt article applies: __folder/file__ wildcards from ComfyUI/wildcards/, .txt/.yaml/.json support, weighted {0.7::a|b}, and repetition blocks like {2$$a|b}. Same install, same zero dependencies. What's new is the scheduling.

    How the ordering works

    The engine advances an internal counter - the "index" - one step per generation. How that index maps onto your template depends on sequence_mode:

    • Nested (Slow -> Fast), the default, fixes the outer choice and runs through all inner ones before advancing. "blue car, blue cat, blue tree, red car, red cat…" The README's example: a {{blue|red} car|{yellow|green} bike} rolls out "a blue car, a red car, a yellow bike, a green bike" before looping.
    • Flat (Fast -> Slow) behaves like an odometer - the rightmost option changes fastest, so "blue car, red car, yellow car, green car, blue cat…".

    Two more inputs tune it. sequential_passes (1–5, default 2) is the failsafe for templates with nested wildcards: only the first N levels advance sequentially, everything deeper falls back to random. That's the setup for "female/male character category + random details" workflows - you sweep the categories in order but keep the incidental details varied. index_offset shifts the starting point if you want to begin mid-list.

    The counter gotcha

    This is where Sequential Prompt will bite you, and it's worth reading twice. The index is a class-level counter that persists for the whole ComfyUI session - it does not reset when you change the template or restart a batch. Run a 10-item list once and the next run starts at item 10. There's a reset_counter toggle to force it back to zero, and index_offset to start elsewhere, but the README calls out the real trap: every active node runs even if it isn't wired up. A leftover disconnected Sequential Prompt keeps advancing the shared counter, silently throwing your output "off by a few" until you disable (not just disconnect) the node.

    The node also sets its change-detection to the counter value, so it re-runs on every pass without you touching anything. If that's not happening - say you're in a workflow that caches nodes - hit reset_counter and watch the console with debug on; the log tells you exactly which index got used and what it picked.

    What it's for

    The classic use, grounded in the same community pattern as the bracket trick that KB's prompt-engineering notes: batch 20-30 images of one subject across systematically varied settings, no training involved, and no repeats to sort through later. One output, a STRING, straight into the CLIP Text Encode positive input. If your goal is exhaustive coverage rather than random sampling, this is the node in the pack you'll actually keep coming back to.

    CategoryKaleidiaNodes/PromptNodes

    Inputs (8)

    NameTypeDefaultDescription
    templateSTRING
    sequence_modeCOMBO2 options: Nested (Slow -> Fast), Flat (Fast -> Slow)
    sequential_passesINT21–5
    index_offsetINT00–18446744073709550000Adds to the internal counter to shift the starting point.
    join_styleCOMBOperiod4 options: space, period, comma, and
    reset_counterBOOLEANfalse
    debugBOOLEANfalse
    clear_cacheBOOLEANfalseClears the wildcard cache on every run. Good if you work on the wildcards on the side during image generation and do not want to completely reboot comfy. Bad as it does disk operations on every run, that might not be needed. Default is false which has the cache build once per comfy run and reused then.

    Outputs (1)

    NameTypeDescription
    STRINGSTRING