Nodes/comfyui-prompt-sequence/Prompt Sequence Filter
ComfyUI Node

Prompt Sequence Filter

Limit and shuffle without touching the source

By Localsmile·Created 3 months ago·Updated 3 months ago· 0
Prompt Sequence Filter
    • text
    prompts
    modesequential
    max_items0
    seed-1
    source

    Every other node in the comfyui-prompt-sequence pack makes a prompt list. This one stands downstream and edits it. It's the pack's post-process stage: shuffle an existing sequence, cap it, or both - without touching the node that generated it.

    The display name says it better than the class name does: Prompt Sequence Filter. You connect a source (the text list output of a Prompt Sequence Text, a Join, an image-sequence node - anything that emits a STRING list) and this node limits it, reorders it, or just passes it through. The honest description: it's the same engine as the plain Text node, repackaged to operate on a list that already exists instead of a box you type into.

    How it works

    The prompts box only does anything when source is not connected - wire in a source and the local box is hidden and ignored, exactly as its tooltip warns. That split is the whole personality of the node: unconnected, it's a mini Text node; connected, it's a filter. When the source is a list, the node takes its values in order, splits any multi-line strings it finds, then applies the mode.

    The controls are the pack's usual trio plus one:

    • mode - sequential keeps the source order, random shuffles before anything else happens.
    • max_items - 0 outputs everything available; a positive value trims the list to that many.
    • seed - random mode only. -1 (default) means a new order every queue; a fixed value repeats the same shuffle so you can debug a specific batch.

    Shuffle-before-trim is the ordering to remember: it always shuffles first and then cuts, so with max_items = 3 and five source prompts you get a random three, not the first three shuffled. And like its sibling, random + seed = -1 marks the node always-changed (the float("NaN") IS_CHANGED idiom), so it genuinely re-rolls each run instead of serving a cached shuffle.

    Output

    One text output, a STRING list, ready for CLIP Text Encode. It's a transparent pass-through in sequential mode - the practical use is chaining it behind a Join or a card-library node to add "pick N at random" to a workflow that otherwise just emits everything.

    Install

    ComfyUI Manager, search comfyui-prompt-sequence, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Localsmile/comfyui-prompt-sequence
    

    Restart after either. No extra dependencies, no models.

    Where it's a trap

    The most common stumble is connecting a source and still seeing the prompt box - it's hidden while connected, and if you typed into it earlier that text is silently ignored. Don't fight it; that's the designed behavior. This is also a genuinely small pack (single commit, no community presence), so while this node is simple enough to trust, it's worth a throwaway run to confirm your downstream graph handles the capped list the way you expect.

    Categoryprompt sequence

    Inputs (5)

    NameTypeDefaultDescription
    promptsSTRINGUsed only when source is not connected. Hidden and ignored while source is connected.
    modeCOMBOsequentialsequential: keep source order. random: shuffle before max_items is applied.
    max_itemsINT00–100000 outputs all available prompts. A positive value outputs up to that many prompts.
    seedINT-1-1–9223372036854776000For random mode: -1 makes a new order each queue; a fixed value repeats the same order.
    sourceoptSTRINGWhen connected, this source list replaces the local prompt box.

    Outputs (1)

    NameTypeDescription
    textSTRING