Knowledge-Centric Agents for Workflow Generation in ComfyUI
Abstract
Workflow generation in visual creation systems such as Com-fyUI demands not only syntactic accuracy but also expert-level reason-ing over modular compositions. Existing large language model (LLM)approaches often treat this as a direct text-to-JSON generation task,struggling with structural brittleness and lacking the experiential knowl-edge required for effective design. We argue that successful workflowgeneration requires modeling knowledge itself, including its structure,hierarchy, and reasoning dynamics. To this end, we propose a knowledge-centric framework that learns to invert, inject, and infer with knowl-edge across multiple abstraction levels. We first perform knowledge in-version to distill hierarchical representations, ranging from full pseudo-codes and skeletons to high-level strategies, from large collections of real-world workflows. We then conduct knowledge injection through super-vised fine-tuning, teaching the model to reason from task descriptionsto strategies and from strategies to executable structures. During infer-ence, the model performs reversible reasoning to synthesize executableworkflows, augmented by self-refinement for structural coherence. Ex-tensive experiments demonstrate that our method produces workflowswith richer node diversity, more coherent structures, and higher execu-tion success rates than existing systems, establishing a new foundationfor knowledge-driven, agentic workflow generation.