ComfyUI Node

[Book Tools] Loop End

Where your loop hands its result back

By Big-Idea-Technology·Created 2 years ago·Updated 8 months ago· 40
[Book Tools] Loop End
  • send_to_next_loop
  • loop

    BTLoopEnd is the sink at the bottom of a Book Tools loop - the node that takes whatever your loop body produced and hands it back to the top for the next pass. On its own it's a nothing node with no outputs; inside a loop it's what keeps the cycle alive. If you're building a page-by-page book renderer and the previous page should influence the next one, this is where that handoff happens.

    How it works

    Two required inputs:

    • send_to_next_loop (type * - an image, conditioning, seed number, anything) - the value your loop body finished with.
    • loop - the shared LOOP wire that came from BTLoop (via BTLoopStart).

    The code is one line of substance: loop.next = send_to_next_loop. It stashes your result onto the loop object. On the next pass, BTLoopStart checks for that next attribute - if it's there, the loop body receives your previous result instead of the initial first_loop value. On the very first pass, next hasn't been set yet, so BTLoopStart correctly falls back to first_loop. That fallback is what makes the whole thing start without you having to special-case iteration one.

    It's an output node with no return values, so ComfyUI treats it as a valid endpoint of the graph - but think of it as a wire through the graph rather than a terminal: the same LOOP object keeps traveling.

    Wiring it up

    BTLoop ──LOOP──► BTLoopStart ──► [loop body] ──► BTLoopEnd (send_to_next_loop)
                                                        ▲            │
                                                        └── LOOP ─────┘
    

    The critical detail: loop on BTLoopEnd must be the same LOOP wire that feeds BTLoopStart, not a second BTLoop node. Two separate BTLoop nodes means two separate objects, and the feedback never closes.

    What a beginner should actually use it for

    Say you're rendering a book where each page should stay roughly consistent with the last - same character, same mood. Route the previous page's conditioning into send_to_next_loop, and on pass two the sampler gets the prior conditioning blended with the current page's prompt. Or keep it simpler: carry the previous page's image forward and feed it to an img2img pass so pages evolve rather than restart.

    Pair it with the iteration counter from BTLoop to advance BTPromptSelector through your prompt schedule at the same cadence, and you have a self-driving per-page pipeline.

    Installing

    cd ComfyUI/custom_nodes
    git clone https://github.com/Big-Idea-Technology/ComfyUI-Book-Tools
    # restart ComfyUI
    

    Or search "ComfyUI-Book-Tools" in ComfyUI Manager. No models, no extra pip dependencies - the pack is plain Python on top of what ComfyUI already ships.

    Honest caveat

    Remember this loop family isn't a hard for loop: each pass is a fresh graph execution driven by a changing global counter, so a loop body containing expensive model loads re-runs them every pass. And the counter is shared across the whole workflow - one loop per workflow, unless you enjoy debugging weird interference.

    Categoryloopback

    Inputs (2)

    NameTypeDefaultDescription
    send_to_next_loop*
    loopLOOP

    Outputs (0)

    No outputs