GenClaw: Code-Driven Agentic Image Generation

Junyan Ye, Jun He, Zilong Huang, Dongzhi Jiang, Xuan Yang, Rui Chen, Weijia LiarXiv 2026

TL;DR

GenClaw is a novel code-driven agentic framework that transforms image generation from a black-box "prompt lottery" into a structured, human-like artistic workflow: conceptualizing, sketching, and coloring. By leveraging LLMs to generate executable code (SVG, HTML, Three.js) as an intermediate structural canvas, it gives the agent a precise "digital brush" before a diffusion model handles the final photorealistic rendering.

What Problem Does This Paper Address?

While modern text-to-image models generate stunningly realistic pixels, they remain notoriously difficult to control. When users attempt to specify exact object counts, absolute spatial coordinates, complex typographical layouts, or physical interactions (like mirror reflections), standard models often fail.

Existing AI image generation agents try to fix this by iteratively rewriting prompts. However, this keeps the agent trapped in a blind trial-and-error cycle because natural language is inherently too ambiguous to communicate precise spatial and structural layouts. The authors argue that agents lack a genuine "paintbrush"—a native, structured modality through which an LLM can directly plan and manipulate a canvas.

Methods

GenClaw mimics the authentic human creative process by decoupling image comprehension from pixel generation across three distinct layers:

  1. Cognitive Structuring Layer (Think): The agent uses a Vision-Language Model (VLM/LLM) alongside web search and reasoning tools to understand user intent and gather real-time or long-tail world knowledge. The output is a clean, structured JSONL record of the scene's requirements.
  2. Executable Canvas Layer (Sketch): Instead of drawing pixels directly, the agent writes executable code tailored to the task. It generates SVG for spatial layouts and object counts, HTML/CSS for text-heavy graphics, or Three.js/Python scripts for 3D and physical simulations. Executing this code produces a precise visual layout sketch.
  3. Visual Generation and Review Layer (Color): An off-the-shelf image generation model (acting as a "colorist") takes the code-rendered sketch as a visual condition. It infuses the final image with textures, materials, lighting, and photorealism. Finally, a VLM-based review module verifies the output against the original prompt.
Overall architecture of the proposed framework.

Datasets

The authors evaluated GenClaw across four rigorous benchmarks targeting different capabilities:

  • GenEval++: For evaluating complex scene composition, object counting, and spatial relations.
  • LongText-Bench: For measuring long-text rendering accuracy in both English and Chinese.
  • ImgEdit: For testing localized image editing consistency and preservation of unedited areas.
  • Mind-Bench: For assessing knowledge-grounded and reasoning-driven generation tasks.

Key Insights and Ideas

  • The Logic-Pixel Symbiosis: The core "aha moment" is the natural complementarity between code and diffusion models. Code is exceptionally strong at logic, structure, and deterministic placement but terrible at high-frequency realistic details (like hair or natural textures). Diffusion models excel at textures but struggle with structure. Marrying them solves both bottlenecks.
  • Code as a Physical Simulator: For scenes governed by intuitive physics, GenClaw uses code to calculate exact geometries beforehand. For instance, rather than hoping a diffusion model "guesses" how a mirror reflection works, GenClaw uses Three.js to mathematically render the reflection block first, ensuring physical accuracy.
  • Traceable Debugging: Because the generation pipeline is broken into explicit, transparent stages, failures are highly interpretable. If a final image is incorrect, a user or system can trace the error back to its exact root cause: faulty search data, a coordinate bug in the SVG code, or a rendering failure by the diffusion model.
Image generation governed by physical laws.

Key Results

GenClaw achieved state-of-the-art performance across all evaluated benchmarks, outperforming both standard end-to-end models and prompt-rewriting agents:

  • Compositional Control (GenEval++): GenClaw scored an overall 0.878, substantially beating top-tier prompt-rewriting agents like Mind-Brush (0.782) and advanced closed-source models like GPT-Image-1.5 (0.750). It showed massive gains in strict object counting and spatial attribute binding.
  • Flawless Typography (LongText-Bench): By rendering text deterministically via HTML/SVG before coloring, GenClaw achieved near-perfect scores of 0.989 (EN) and 0.988 (ZH), completely eliminating the gibberish text artifacts common to traditional generators.
Qualitative comparison of long-text poster design.
  • Precise Image Editing (ImgEdit): Thanks to its layer-wise code representation, GenClaw achieved a PSNR of 27.87 and SSIM of 0.718 on unedited regions, proving it can modify specific image elements without causing unintended pixel corruption elsewhere.

Limitations and Future Work

Despite its strengths, the authors note three primary limitations:

  • High Dependency on the Visual Decoder: Abstract code sketches are highly stylized. Translating them into photorealistic images requires a powerful underlying foundation model (like Gemini 3.1 Flash). Weaker open-source models often fail to break away from the flat, vector-like appearance of the initial SVG sketch.
  • Efficiency Overhead: The multi-step agentic pipeline (search, code generation, rendering, coloring, and reviewing) introduces significant inference latency and computational cost, making it overkill for simple, straightforward prompts.
  • Code Generation Stability: LLMs are prone to occasional code bugs, such as coordinate calculation errors or incorrect layer ordering (z-index), which directly manifest as layout flaws in the final output.

Summary updated

BibTeX
@misc{ye2026genclaw,
  author = {Junyan Ye and Jun He and Zilong Huang and Dongzhi Jiang and Xuan Yang and Rui Chen and Weijia Li},
  title = {{GenClaw: Code-Driven Agentic Image Generation}},
  year = {2026},
  eprint = {2605.30248},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.30248},
}
Figure