Nodes/Boyonodes/Boyo Chain Bastard Loops
ComfyUI Node

Boyo Chain Bastard Loops

The node that re-runs your whole workflow from inside itself — powerful, and a little insane

By DragonDiffusionbyBoyo·Created 2 years ago·Updated 27 days ago· 16
Boyo Chain Bastard Loops
  • images
  • prompt_config
  • grid_image
  • individual_images
loop_count5

ComfyUI has a rule: a node's output can't feed back into its own input - no cycles. That rule is why looping feels like fighting the tool. Boyo Chain Bastard Loops doesn't fight the rule; it sidesteps it entirely by re-running your entire workflow from inside the node, N times, and collecting the results. Hence the name: it's a bastard of a loop, bolted onto the end of your chain.

The way this differs from the pack's other loop nodes matters. Boyo For Loop Start/End are proper graph-level loops using ComfyUI's graph expansion. This one is a different beast: it takes an image (the pack docs explicitly say "this connects to VAE Decode output!"), then re-executes the upstream part of the graph, updating the text in your CLIP Text Encode nodes with a new prompt each iteration, and collects every pass's output into a grid plus a list. It's the closest thing ComfyUI has to a "repeat this whole pipeline with different prompts" button.

How it works

The mechanics are borrowed from ttN (TinyTerra Nodes), which is where the "pull the upstream graph" trick comes from. At execution, the node:

  1. Walks backward from itself through the graph (_get_nodes_to_keep) to find every node the chain depends on.
  2. Builds a pruned copy of that sub-workflow with itself excluded.
  3. For each of loop_count iterations, rewrites the prompt text in the CLIP Text Encode nodes (optionally from a PROMPT_LOOP_CONFIG), validates and executes that sub-graph via ComfyUI's own execution engine, and captures the result.
  4. Emits all iterations as individual_images (a list) and stitches them into a single grid_image.

The loop_count (1–100, default 5) is simply how many times it runs the whole chain. The prompt_config optional input lets an external node drive per-iteration prompt changes; without it, it uses whatever prompts the workflow already has.

Inputs and outputs

  • images (IMAGE) - the anchor that defines the chain (wire the VAE decode output). This is what gets sampled for output.
  • loop_count - iterations.
  • prompt_config (PROMPT_LOOP_CONFIG, optional) - per-iteration prompt control.
  • Outputs: grid_image (single IMAGE) and individual_images (list of IMAGE).

Installation

No extra dependencies:

cd ComfyUI/custom_nodes && git clone https://github.com/DragonDiffusionbyBoyo/Boyonodes

restart, find it under boyo/bastardloops.

The honest caveats

This is the most fragile node in the pack, and the most powerful. Re-entering the execution engine from inside a node is inherently hacky: it works, and people run it, but the author's own docs for the family say the loops "patch ComfyUI's execution engine to support genuine cycles" and to "use with care in complex graphs." Things that break it in practice: branches with save nodes (they fire every iteration), nodes that aren't part of the pruned sub-graph but have side effects, and nested loops. If a workflow hangs or behaves oddly with this node, the first suspect is always the graph structure, not the node.

It's also a poor fit for ComfyUI versions that change their execution internals - this style of node is version-sensitive. If you're on a very new ComfyUI and it misbehaves, that's a known risk of the genre, not a mystery.

Reach for it when you genuinely need "run this whole pipeline N times with N prompts" and the graph-level loop nodes can't express it. Just don't make it the foundation of a workflow you can't afford to debug.

Categoryboyo/bastardloops

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
loop_countINT51–100
prompt_configoptPROMPT_LOOP_CONFIG

Outputs (2)

NameTypeDescription
grid_imageIMAGE
individual_imagesIMAGE