凤希AI - 循环开始(条件)
Loop until the condition says stop
- initial_value0
- 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
- flow
- value0
- value1
- value2
- value3
- value4
- value5
- value6
- value7
- value8
- value9
- value10
- value11
- value12
- value13
- value14
- value15
- value16
- value17
- value18
- value19
Loops that end on a condition, not a count
A counted loop is easy to reason about: run it 20 times. But half the real cases don't know the number in advance - keep generating until the accumulated frames exceed the target, keep refining until the likeness score clears a threshold, keep going until the queue of unprocessed files is empty.
FxAiWhileLoopStart (凤希AI - 循环开始(条件)) is the top of the condition-driven pair. It's also the primitive: the pack's counted for-loop is a while-loop whose condition happens to be index + 1 < total.
How it works
Two things happen at the start node, and only one is obvious.
It outputs the current values of your state - value0 through value19, twenty slots, wildcards - and a flow link that identifies the loop. That's the visible half.
The invisible half is gating. The node takes a condition boolean, and if it's false it replaces every value output with an execution blocker. Blockers aren't None: they're the engine's "this branch doesn't run" marker, so the entire body downstream of the start node simply doesn't execute, no error, no half-run. Turn the condition off and the loop body is skipped as a unit.
The actual repetition lives in the end node, which clones the body and recurses - the pack does this with ComfyUI's subgraph-expansion mechanism, so iteration depth is handled by the executor rather than the Python stack.
Inputs and outputs
condition(BOOLEAN, defaults true) - whether this pass should do anything at all. Wire the end node's condition output back here when the loop should re-check itself, or feed it aFxAiComparefor the first pass.initial_value0…initial_value19- twenty seed slots. Note the numbering starts at 0 here, unlike the counted loop's start node which starts at 1.
Outputs: flow (to the end node), then value0 … value19.
The frontend labels the sockets 条件, 初始值 and 过程值 and only shows the slots you're using, growing one when you connect the last.
How to build one
The shape is: a state value goes in on initial_valueN, comes out of valueN, gets transformed by the body, and the transformed version goes into the end node's initial_valueN - same number. The end node's outputs are the final state when the loop finishes.
The condition is the tricky bit, and the clean split is: the start node's condition gates the current pass, the end node's condition decides whether there's another one. In practice you compute a FxAiCompare on your state (frames accumulated ≥ target, segment index ≥ total, score ≥ threshold), feed it into the end node's condition, and - if the initial state should also be checked - into the start node's condition as well. Two separate sockets, two separate jobs; conflating them is how you get a loop that runs one time too many.
Accumulating state is the other design decision. If the loop needs to know "how much have I done so far", that has to travel in a slot: an int you add to each pass, a list you append to, whatever the body can produce. The loop carries it; it does not keep score for you.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit
Restart ComfyUI, or install through ComfyUI Manager by searching fxai-toolkit (registry publisher fxai). The pack pip-installs soundfile and psutil on first import. No models needed for the loop nodes.
There's no alias layer, so a workflow written against another pack's loop nodes won't resolve here.
Where it bites
Nothing guarantees termination. There's no iteration cap on this pair - the condition is whatever you wired, and if it never goes false you get a run that keeps expanding the graph. The counted pair is the safe choice whenever you know the number; use this one when the condition genuinely can't be a count.
Cross-wiring the pairs. A while-start into a for-end raises flow 接的不是循环开始节点. Both pairs look identical on the canvas; check the class name in the properties panel when a loop mysteriously refuses to run.
Off-by-one slots. While uses value0..19, for uses value1..19. If you're porting a graph between them, the numbers don't line up and your state quietly goes to the wrong place.
The body has to feed the end node. The end node discovers what to repeat by walking upstream from its own inputs. Nodes in the canvas that don't contribute to it aren't in the loop and won't re-run - save nodes inside the body are picked up, orphan branches aren't.
Node missing. Each node loads inside its own try/except with ❌[凤希AI] 节点加载失败 on the console, so a failed import hides one node rather than the pack. Console first, then restart.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | BOOLEAN | true | 为真才跑这一轮。接结束节点的条件输出,或自己接一个比较节点。 |
| initial_value0opt | * | — | |
| 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 (21)
| Name | Type | Description |
|---|---|---|
| flow | FLOW_CONTROL | — |
| value0 | * | — |
| value1 | * | — |
| value2 | * | — |
| value3 | * | — |
| value4 | * | — |
| value5 | * | — |
| value6 | * | — |
| value7 | * | — |
| value8 | * | — |
| value9 | * | — |
| value10 | * | — |
| value11 | * | — |
| value12 | * | — |
| value13 | * | — |
| value14 | * | — |
| value15 | * | — |
| value16 | * | — |
| value17 | * | — |
| value18 | * | — |
| value19 | * | — |