Nodes/EBU Workflow/EBU File List Cache
ComfyUI Node

EBU File List Cache

A growing prompt pool that samples itself

By burnsbert·Created about a year ago·Updated 12 months ago· 0
EBU File List Cache
    • selected_items
    • input_items
    • combined_items
    directory_namestore
    file_nameoutput.txt
    num_return_items5
    input_items
    limit_list_size100
    seed0

    EBU File List Cache is the most interesting node in the EBU Workflow pack, and it's easy to miss because its name sounds like a caching afterthought. It's actually a persistent, self-maintaining pool: you feed it new lines of text each run, it merges them into a file-based library, and it hands back a random sample from that library. Think of it as a memory for your workflow - you keep dropping prompts (or tags, or seeds) in, and it keeps a deduplicated, capped collection that it samples from on demand.

    How it works

    The mechanism is worth walking through because it's stateful - this node writes to disk, and understanding the order of operations saves you from surprise. On every run it:

    1. Loads existing lines from directory_name/file_name (defaults store/output.txt).
    2. Takes your new input_items (multiline string), strips each line, and merges them into the existing set - deduplicated, since it's a set under the hood.
    3. Shuffles the combined list. If seed is set, it reseeds the RNG first, so a fixed seed gives reproducible shuffles (and thus reproducible sampling, given the same file contents).
    4. Trims to limit_list_size (default 100) and rewrites the file, backing up the previous version to output.txt.bk first.
    5. Samples num_return_items (default 5) randomly excluding the lines you just fed in, and returns three outputs: selected_items (the sample), input_items (an echo of what you added), and combined_items (your inputs plus the selection).

    The .bk backup is a thoughtful touch - the file is mutated in place, so if a run goes sideways you've got the prior state.

    There's a subtle behavior: if input_items is empty, the node doesn't touch the file - it just samples from what's already stored. That means you can run the same workflow repeatedly with a blank input and keep getting fresh random picks from your library, without growing it.

    Inputs that matter

    • input_items (STRING, multiline) - new lines to add to the pool. Leave empty to just sample.
    • directory_name / file_name - where the pool lives. Relative to ComfyUI's working directory.
    • num_return_items (INT, default 5) - how many to sample.
    • limit_list_size (INT, default 100) - cap on the stored pool.
    • seed (INT) - reseeds the shuffle when new items are added.

    Outputs: selected_items, input_items, combined_items - all STRING, newline-joined.

    Where it fits

    The obvious use is a growing prompt library: every run, drop in a couple of new prompt lines (say, from a batch-generation node), and get a random subset back to feed a sampler. Over time the pool accumulates the best of what you've tried, and the sampling means you're not stuck in one pattern. It's also a reasonable poor-man's "LoRA shuffle" - put tag combinations in and let it pick.

    Installing

    Standard EBU Workflow install - no dependencies beyond Python's standard library. ComfyUI Manager (search "EBU Workflow"), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/burnsbert/ComfyUI-EBU-Workflow
    

    then restart ComfyUI.

    Gotchas

    • It's stateful and mutating: running with new input rewrites your pool file (after backing up to .bk). That's the feature, but don't point it at a file you care about as a source of truth.
    • The sample excludes your just-added lines - so a first run with 3 new items and num_return_items of 5 returns at most 0 new items plus whatever was already in the file. If the pool is empty, you get back an empty sample.
    • Dedup is exact-line matching after stripping whitespace. "a cat" and "a cat " merge; "A cat" and "a cat" don't.
    • Relative paths resolve against ComfyUI's working directory, not your workflow folder.
    CategoryUtility

    Inputs (6)

    NameTypeDefaultDescription
    directory_nameSTRINGstore
    file_nameSTRINGoutput.txt
    num_return_itemsINT50–1000
    input_itemsSTRING
    limit_list_sizeINT1001–10000
    seedINT0

    Outputs (3)

    NameTypeDescription
    selected_itemsSTRING
    input_itemsSTRING
    combined_itemsSTRING