Nodes/ComfyCollectorNodes/Random Select (CCN)
ComfyUI Node

Random Select (CCN)

Pick one of five inputs, rerolled every run

By valkymaera·Created 4 months ago·Updated 10 days ago· 1
Random Select (CCN)
  • input_1
  • input_2
  • input_3
  • input_4
  • input_5
  • output
  • selected_index
seed-1
debugfalse

You have five LoRAs, or five styles, or five reference images, and you want a workflow that rolls the dice on which one gets used this run. Random Select (CCN) is that dice: up to five ANY-typed inputs, one chosen at random each execution, plus an integer telling you which one won.

The ANY typing is what makes it broadly useful - it doesn't care whether you're shuffling models, strings, images, or latents. Only connected inputs are considered, so you can leave slots empty and the pool shrinks automatically. Outputs are output (the picked value, passed through untouched) and selected_index (1–5, handy if you want to also pick a matching parameter).

The seed logic is the interesting part

seed defaults to -1, meaning a fresh random pick on every execution - even if you change nothing, re-running the queue gives you a new result. That's the point for variety-driven workflows, but it's also the classic footgun: because ComfyUI caches aggressively, a node that promises to re-roll needs to opt out of that cache. It does, via the NaN IS_CHANGED idiom from the engine's own docs (return a value not equal to anything, so it's always "changed"). The cost is that anything downstream of it re-executes every run - that's the feature, but it makes the whole branch uncacheable.

Set seed to a non-negative number and it becomes reproducible: same seed, same pick, and ComfyUI can cache it again. That's the switch between "surprise me" and "reproduce that exact roll."

Install

Part of ComfyCollectorNodes, one install:

cd ComfyUI/custom_nodes
git clone https://github.com/valkymaera/ComfyCollectorNodes

then restart, or install via ComfyUI Manager ("ComfyCollectorNodes"). No models, no extra dependencies.

Where people get burned

Three things. First, the unseeded re-roll: expect every run to change, and don't be surprised when a "stable" workflow suddenly varies - that's the node doing its job. Lock a seed when you need reproducibility. Second, no inputs connected raises a clear error (connect at least one input) rather than silently failing downstream - connect at least one slot. Third, the randomness uses a local RNG instance rather than seeding the global Python random module, which is a thoughtful detail (it won't corrupt other nodes' randomness), but it does mean results aren't tied to the KSampler's seed - selected_index is the only reproducible trace.

CategoryComfyCollectorNodes/Utils

Inputs (7)

NameTypeDefaultDescription
input_1opt*
input_2opt*
input_3opt*
input_4opt*
input_5opt*
seedoptINT-1-1–2147483647
debugoptBOOLEANfalse

Outputs (2)

NameTypeDescription
output*
selected_indexINT