Nodes/Wildcard Pipeline/WP Context Loop
ComfyUI Node

WP Context Loop

N Coherent Prompts From One Generate (and It Pairs Seeds for You)

By DumiFlex·Created 5 months ago·Updated 19 days ago· 9
WP Context Loop
  • wp_context_loop_config
  • context
  • loop_config
seed0
count1

Re-rolling a wildcard workflow by hand is the comfiest of all the easy traps: click Generate, squint, click again. WP Context Loop is the "stop doing that" button. It runs your whole wildcard chain N times in a single Generate and hands each iteration its own $iteration and $iteration_total, so one click gives you a batch of distinct coherent prompts instead of one prompt you keep rerolling.

How it works

Mechanically it's elegant: the node's context output is a list of PIPELINE_CONTEXT payloads (is_list=True). ComfyUI's own execution engine sees a list output, notices the downstream nodes accept a single context, and automatically iterates the entire chain after it - every iteration gets the Context, runs the modules, samples, decodes. You get N full renders from one queue click.

Three inputs matter, and two are boring:

  • seed - the starting point for the series. Same seed reproduces the same batch.
  • count - 1 to 999 iterations. Set it to 1 and the loop is effectively disabled without deleting the node, which is a nice touch for A/B testing.
  • wp_context_loop_config - the one widget that hides real power. It's a JSON blob the node parses recovery-style (unknown keys ignored, missing keys backfilled from defaults), controlling seed strategy (hash_index, sequential, prime_stride), whether the loop overrides the context's seed, the iteration variable name, per-index seed_locks, and a bypass mode.

The seed strategy is worth understanding because it's what makes a batch feel like a batch. With hash_index (the default) each iteration's seed is a hash of base + index - unrelated values, maximum variety. sequential just increments (base+0, base+1, ...), and prime_stride steps by 1000003, which looks random but stays deterministic. All derived seeds are masked to 50 bits, matching ComfyUI's own randomize range, so you can paste them into a stock seed widget and they look normal. seed_locks lets you pin specific iterations to specific seeds - useful when iteration 3 is your "hero shot" and you don't want it drifting.

The loop_config side output is the other half of the trick: wire it into WP Seed List and the seed list mirrors the loop's count and strategy, so iteration N's prompt always pairs with seed N. Without that pairing you'd render N prompts and N random seeds that have no relationship, which defeats the whole point. (You can skip WP Seed List entirely if you just want variety - the loop already varies per-iteration via effective_chain_seed - but then you lose prompt↔seed reproducibility.)

Installing and using

ComfyUI Manager → Wildcard Pipeline → install, or the manual git clone + pip install -e . + pnpm build path. Needs ComfyUI ≥ 0.3.36, no model downloads.

A practical loop chain looks like: WP Context LoopWP ContextWP Prompt AssemblerCLIP Text EncodeKSampler, with the loop's loop_config also feeding WP Seed List → KSampler seed. Type frame $iteration of $iteration_total - a $subject in the assembler and every image labels itself. The one trap: put the loop before the context, not after - it has to be upstream of the chain it's multiplying. And if iterations come out with identical prompts, check whether something upstream is re-seeding per iteration or whether your wildcards are all fixed values; a loop multiplies the chain, it doesn't invent randomness where the chain has none.

Categorywildcard-pipeline

Inputs (3)

NameTypeDefaultDescription
seedINT00–18446744073709550000Starting point for randomisation. Change for a different roll; keep the same to reproduce. Right-click → Convert widget to input to drive from another seed node.
countINT11–999How many iterations the series runs (1–999). Set to 1 to disable looping without removing the node.
wp_context_loop_configWP_CONTEXT_LOOP_WIDGET{}

Outputs (2)

NameTypeDescription
contextPIPELINE_CONTEXT
loop_configWP_CONTEXT_LOOP_CONFIG