TL;DR
COMFYCLAW is a novel agentic framework that allows Large Language Models (LLMs) to autonomously build and refine complex image generation pipelines in ComfyUI. By combining a vision-language model (VLM) verifier for closed-loop feedback with a self-evolving skill library, the system distills successful generation strategies into reusable "Agent Skills," significantly improving image quality and prompt alignment over static baselines.
What Problem Does This Paper Address?
While text-to-image models have advanced rapidly, prompt-only interfaces (like standard ChatGPT or Midjourney boxes) act as a black box. They obscure critical pipeline decisions such as how conditioning is applied, how visual elements are composed, and how rendering errors are repaired. Advanced users turn to node-based workflow systems like ComfyUI to gain fine-grained control over these steps.
However, managing these complex, graph-based workflows is highly demanding. When AI agents are tasked with operating them, they frequently break execution with invalid node connections or repeat the same mistakes across different runs. Existing agent frameworks typically lack a long-term memory mechanism to turn a successful, hard-fought workflow repair from one run into a reusable procedure for future tasks.
Methods
COMFYCLAW introduces an agentic skill evolution harness that treats workflow construction as a skill-augmented Markov Decision Process (MDP). The framework consists of three core components:
- Typed Graph Editing Harness: The agent interacts with an unmodified ComfyUI runtime through a stage-gated harness (Planning $\rightarrow$ Construction $\rightarrow$ Enhancement). It uses specific tools to insert nodes, adjust hyperparameters, or stack LoRAs, while the harness automatically catches and reverts invalid edits to prevent execution crashes.
- Verifier-Guided Refinement: When a workflow renders an image, a region-level Vision-Language Model (VLM) acts as a verifier. It decomposes the original prompt into a binary checklist of visual requirements, evaluates the image, and provides localized, actionable feedback (e.g., "apply regional prompting to isolate the throwing arm") to guide the agent's next iteration.
- Skill Library Evolution: Instead of treating each prompt in isolation, COMFYCLAW clusters successful and failed execution traces. A skill-evolver agent proposes mutations (
create,revise,reinforce,merge,delete) to a library of explicitSKILL.mdfiles. Crucially, these skills are only committed after passing validation on held-out prompts. To keep the LLM's context window clean, the system uses progressive disclosure, showing the agent only lightweight skill metadata until the full procedure is explicitly requested.
Datasets
The authors evaluated COMFYCLAW across four text-to-image benchmark splits, totaling roughly 4,300 prompts:
- GenEval 2: Focuses on compositional reasoning, evaluating objects, attributes, and spatial/numerical relationships.
- DPG-Bench: Contains dense English prompts featuring multiple objects and intricate relationships per sentence.
- OneIG-Bench (English split - OneIG-EN): Evaluates subject-element alignment, text rendering, stylization, and diversity.
- OneIG-Bench (Chinese split - OneIG-ZH): Tests cross-lingual generalization and Chinese-specific anime conventions.
Key Insights and Ideas
- Beyond Prompt Engineering: A key finding is that workflow control is fundamentally different from simple prompt rewriting. Approximately 61% of the agent's actions involved non-prompt modifications, such as tuning sampler hyperparameters, altering graph topology for regional masking, and managing multi-pass upscaling.
- Task-Specific Skill Evolution: The evolved skills were highly specialized to the demands of each benchmark. For instance, GenEval 2 induced spatial-binding and object-counting skills, whereas DPG-Bench favored material texture and lighting refinements.
- The Power of Reusable Knowledge: Rather than rediscovering solutions from scratch, the agents heavily relied on their evolved skill library, which accounted for roughly 50% of all skill invocations in later runs.
Key Results
The authors evaluated COMFYCLAW using three foundation models (Claude Sonnet 4.5, Qwen-3.6-35B, and Gemma-4-E4B) acting as the agents, paired with two image generation backbones (z-image-turbo and LongCat-Image).
- Quantitative Performance: COMFYCLAW achieved the highest average image-evaluation score across all six agent-model configurations, outperforming the no-refinement baseline by an average of 10 absolute points.
- Human Preference: In a blind user study spanning 2,400 images, human annotators consistently gave higher visual quality and text-alignment ratings to images generated via COMFYCLAW compared to the baseline.
Limitations and Future Work
Currently, COMFYCLAW is strictly tailored to image-generation workflows. The authors note that extending this framework to video-generation workflows represents a significant challenge. Video pipelines introduce much higher node complexity, require strict frame consistency, demand temporal conditioning, and suffer from long execution times. These factors increase the risk of timeouts and latency, meaning future iterations will require even more compact context management and highly efficient skill retrieval strategies.
Summary updated