凤希AI - 循环结束(计数)
The node that decides whether your loop goes round again
- flow
- initial_value1
- initial_value2
- initial_value3
- initial_value4
- initial_value5
- initial_value6
- initial_value7
- initial_value8
- initial_value9
- initial_value10
- initial_value11
- initial_value12
- initial_value13
- initial_value14
- initial_value15
- initial_value16
- initial_value17
- initial_value18
- initial_value19
- value1
- value2
- value3
- value4
- value5
- value6
- value7
- value8
- value9
- value10
- value11
- value12
- value13
- value14
- value15
- value16
- value17
- value18
- value19
It's the bottom of the loop, and the brain
The start node owns the counter; the end node does the thinking. FxAiForLoopEnd (凤希AI - 循环结束(计数)) is where each pass reports its results, and it's the node that decides whether ComfyUI expands the graph one more time or hands the accumulated values downstream.
If you're wiring these for the first time, this is the one to understand first - the failure modes all live here.
How it works
When it executes, it does four things. It follows flow back to the matching FxAiForLoopStart and reads that node's total out of the dynamic prompt (the live copy of the graph being executed). It takes your initial_value1..19 inputs as this pass's results. It builds the next state: index + 1, plus your values, plus a condition of index + 1 < total. And then it hands all of that to a FxAiWhileLoopEnd node, which clones the body into a subgraph and recurses.
That last part is the actual loop: ComfyUI's executor accepts a returned subgraph and keeps running it. Depth equals iterations, queue entry stays singular.
There are two short circuits worth knowing. If total is a constant 0 or less, the node returns execution blockers instead of values, so the entire downstream chain - including any save node - is silently skipped rather than fed a None it would choke on. And if total arrives over a wire rather than as a typed-in number, it can't be known before execution, so the node wraps the result in a lazy FxAiIfElse that selects between the loop result and the start node's seed values.
Inputs and outputs
flow (required) comes from FxAiForLoopStart's flow output. It's the tether: everything about the pairing is discovered through this one link.
initial_value1 … initial_value19 (all optional) are the loop-carried values coming back from your body. This is the reporting channel. Whatever you plug into slot 3 today comes out of the start node's value3 tomorrow.
The outputs are value1 … value19 - the final state after the loop has finished. These are what leave the loop; wire them into the save/merge stage that runs once, after the last iteration.
The frontend labels the incoming slots 过程值 and the outgoing ones 输出值, and prunes unused slots, so a loop carrying two values shows two sockets and not nineteen.
Wiring order that works
- start
flow→ this node'sflow - start
value1..N→ your body → this node'sinitial_value1..N, same numbers - this node's
value1..N→ the post-loop stage
If a value needs to survive from iteration to iteration (an accumulating frame list, a running index, a previous-frame image for continuity), it takes a slot and goes round the circle. If it only needs to leave the loop at the end, it goes out of the end node's outputs without coming back in.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit
Restart after cloning, or install via ComfyUI Manager search fxai-toolkit (publisher fxai). The pack auto-installs soundfile and psutil at import time; the loop nodes themselves have no model requirements and no extra dependencies.
Where it bites
Wrong start node, hard error. The node checks class_type on whatever flow points at and raises if it isn't FxAiForLoopStart. Mixing a for-end with a while-start is the single most common wiring error here, since the two pairs look identical in the canvas.
Slot numbers must match on both ends. initial_value7 here pairs with value7 upstream. Number them once and stay consistent; the graph won't complain if you carry three different things on mismatched slots, it'll just quietly pass the wrong data next round - which is far worse to debug.
Results that never come back in are lost. An image produced in the body and wired only to a save node leaves the loop and becomes an output file; it won't appear on this node's outputs. Want the last frame of segment 12 to seed segment 13? That's an initial_value slot, not a save.
Zero iterations means zero save nodes. With total at 0 (or a wired-in total that evaluates to 0), the whole body is blocked. That's deliberate and useful - a queue of 0 segments shouldn't produce a run - but if you were expecting the seed values to fall through to your output, note that with a constant 0 they become blockers, not values.
Node not in the menu? The pack loads each node in its own try/except and prints ❌[凤希AI] 节点加载失败 on the console when one fails, so a broken sibling module doesn't take everything down - but it also doesn't shout. Console first, then restart.
Inputs (20)
| Name | Type | Default | Description |
|---|---|---|---|
| flow | FLOW_CONTROL | — | |
| initial_value1opt | * | — | |
| initial_value2opt | * | — | |
| initial_value3opt | * | — | |
| initial_value4opt | * | — | |
| initial_value5opt | * | — | |
| initial_value6opt | * | — | |
| initial_value7opt | * | — | |
| initial_value8opt | * | — | |
| initial_value9opt | * | — | |
| initial_value10opt | * | — | |
| initial_value11opt | * | — | |
| initial_value12opt | * | — | |
| initial_value13opt | * | — | |
| initial_value14opt | * | — | |
| initial_value15opt | * | — | |
| initial_value16opt | * | — | |
| initial_value17opt | * | — | |
| initial_value18opt | * | — | |
| initial_value19opt | * | — |
Outputs (19)
| Name | Type | Description |
|---|---|---|
| value1 | * | — |
| value2 | * | — |
| value3 | * | — |
| value4 | * | — |
| value5 | * | — |
| value6 | * | — |
| value7 | * | — |
| value8 | * | — |
| value9 | * | — |
| value10 | * | — |
| value11 | * | — |
| value12 | * | — |
| value13 | * | — |
| value14 | * | — |
| value15 | * | — |
| value16 | * | — |
| value17 | * | — |
| value18 | * | — |
| value19 | * | — |