计次内循环尾
The in-process loop tail that collects every iteration's result into one batch
- start
- obj
- objs
- endObj
ForInnerEnd (计次内循环尾) is the interesting half of the pack's inner counted loop, and the reason it exists is the word "inner": this loop runs inside a single ComfyUI queue entry, in-process, instead of re-queuing the whole graph every iteration the way the older ForStart/ForEnd pair does. Faster, cleaner, no queue spam - and it collects every pass's result into one batch as it goes.
That last part is the real headline. The end node accumulates whatever your loop body produced into an output called objs, so after N iterations you get one combined result - a stacked image batch, a list of strings, whatever you were generating - instead of N separate queue jobs you have to stitch yourself.
How it works
Each time the loop body runs, the value you feed into obj comes back to ForInnerEnd, which appends it to the running collection. If the objects are image tensors it actually concatenates them along the batch dimension (resizing mismatched sizes to match), so a loop that generates one image per pass hands you one batched IMAGE at the end. Non-tensor objects just get appended into a list. The endObj output is the value from the last iteration - useful when you only care about the final state, like the last step of an iterative refinement.
The "inner" bit has a price: this node works via the pack's patch to ComfyUI's execution.py. No patch, no inner loop. The patch script (修改文件.bat / 修改文件.sh) adds the loop control straight into the executor, which is exactly why it breaks when ComfyUI updates.
The inputs and outputs
- start (DOWHILE) - the loop token from ForInnerStart's DOWHILE output. Identifies which loop you're closing.
- obj (*) - the current iteration's result. This is the one you wire with care: whatever you want accumulated goes here.
- objs (*) - the accumulated batch of all iterations. This is the output you'll actually use.
- endObj (*) - the final iteration's value.
Install and the gotcha
cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam
then restart, then apply the execution.py patch - this node won't function without it. And treat that patch as a liability to be re-applied: ComfyUI core updates routinely overwrite hand-edits to execution.py, and your loop workflow will start erroring with no obvious cause. Keep the patch script somewhere you remember, and re-run it after every update. If that maintenance sounds like a dealbreaker, the unpatched ForStart/ForEnd pair still loops - it just re-queues and won't batch for you.
Common issues
- "objs" comes back empty - the body never fed anything back into
obj, so there was nothing to collect. - Batch of wrong shape - mixing image sizes across iterations makes the node upscale to match, which can silently change resolution. Keep the body producing consistent sizes.
- Errors right after a ComfyUI update - the execution.py patch was overwritten. Re-apply it. This is the pack's most common failure mode with this node.
Use it when you want a real loop with a usable combined result. It's the node that makes "generate 8 faces, then detail them all" a single workflow instead of a queue-management exercise.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| start | DOWHILE | — | |
| obj | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| objs | * | — |
| endObj | * | — |