‹ All posts

comfyui-loop-mcp: a ratchet that survives context, and every tool under test

comfyui-loop-mcp got the work that actually makes it trustworthy over the last few days — the loop discipline moved from prose in the tool descriptions to state on disk. repo.

The ratchet is the whole idea: hold a best-so-far, keep a change only if it beats it, otherwise revert. Before this, that lived in the model's head — which means one context compaction wipes it and the agent quietly starts handing back regressions. Now the best graph and the decision ledger sit in a file. A revert is a tool call, not an act of recall.

One real loop where the objective seam score overruled the model's own claim and reverted to the better pass

Proof matters more than the claim, so there's a run in the repo where the ratchet caught the model lying about its own work. Pass 3 of a tiling texture read as "better" to the model; the objective seam score said otherwise, and it reverted to pass 2 on its own. An agent that wants to be finished will call a regression an improvement — the gate is what stops it.

The unglamorous half was correctness. Every one of the MCP tools now has a passing test — the ones that install nodes, the ones that look at the rendered image, the ratchet itself. Two bugs fell out of writing them: restart_comfyui was reporting success even when the restart failed, and the litegraph→API converter dropped connections that passed through Reroute nodes instead of resolving them. Both are the kind of thing that only shows up when you run the tool and read what it returns, not when you eyeball the code.

loop_report also landed: a finished run renders to one self-contained HTML page — every pass, what moved, what got kept or reverted — so the loop leaves a trail you can read after the fact.

‹ Back to the devlog