FormAct: Agentic Source Editing for Rich-Format Document Generation

Eugene J. Yu, Xingxing Zhang, Yuan Xia, Tao Ge, Xun Wang, Fnu Kartik, Vishwas Suryanarayanan, Cheng Yang, Amanda Jiang, Jiayu Ding, Xiangyu Wong, Tengchao Lv, Lei Cui, Si-Qing Chen, Furu Wei, Sujian LiICML 2026

Creating "rich-format" documents—such as regulatory forms, technical reports, or multi-column business proposals—remains a surprisingly difficult task for AI. While Large Language Models (LLMs) excel at generating text, they struggle with the complex "ripple effects" of layout design. A minor adjustment to a font size or table column can break an entire page's alignment.

Current approaches typically attempt to generate the entire document in a single pass, which often results in hallucinated or broken HTML. Alternatively, they rely on limited library APIs (like python-docx) that lack the expressive power needed for truly professional designs. To solve this, researchers introduce FormAct, an agentic framework that treats document generation as an iterative software engineering task: writing source code (HTML), rendering it, and debugging visual glitches.

The FormAct Framework

FormAct bridges the gap between abstract user requests and polished PDFs using a hierarchical, multi-agent approach.

  • The Editing Agent: Rather than rewriting the entire file for every change, this agent utilizes a syntax-aware source editor. It can view specific line ranges and apply targeted patches. If an edit breaks the HTML structure, the system automatically rolls it back, creating a fail-safe refinement loop.
  • Template Retriever: To overcome the "blank page" problem, the agent searches a pool of millions of human-authored documents. By retrieving high-quality templates to use as structural "priors," the system ensures the output maintains a professional, print-native aesthetic rather than resembling a generic webpage.
  • The Reviewing Agent: Acting as the system's eyes, a Vision-Language Model (VLM) inspects the rendered PNG of the document. It identifies visual bugs—such as text overlapping a border or a table overflowing the page—and sends natural language feedback back to the Editing Agent for correction.
  • Edit-Triggered Context Compression: Multi-round editing typically bloats an LLM's context window. FormAct manages this by masking previously inspected snippets after a successful edit. This forces the agent to "re-view" the document to obtain fresh line numbers, preventing it from hallucinating edits on stale code.

New Benchmarks for Document Generation

To support development and evaluation, the researchers introduced two major datasets to move the field forward:

  1. RichDocBench: A suite of 500 evaluation cases derived from a massive crawl of 3 million public Microsoft Word documents (converted to HTML). It tests end-to-end generation from short user queries.
  2. RichDocFuzz: A diagnostic stress test containing 150 documents with intentionally injected formatting errors (e.g., misaligned table cells, occluded elements, or "mojibake" text). This dataset specifically evaluates how well different VLMs can visually detect document defects.

Key Insights and Results

FormAct was rigorously tested against strong baselines, including Codex and Direct Generation (DG) models, yielding several critical insights:

  • Superior Rendering Correctness: FormAct achieved a rendering correctness score of 4.81 out of 5.0, significantly outperforming Codex (4.39) and producing nearly zero broken layouts.
  • Human Preference: In blind studies, human annotators ranked FormAct's output as the best in 76% of cases compared to other multi-pass agents.
  • The Power of Iteration: The iterative refinement process improved rendering correctness by +11.1% for direct generation models, proving that visually "reviewing the work" is essential for high-quality layouts.
  • Direct HTML vs. Rigid APIs: The authors discovered that using library-based tools actually hinders performance. Direct HTML source editing, while inherently riskier, allows for much finer control over professional styling that rigid APIs simply cannot match.
  • Cost Efficiency: Despite multiple rounds of editing and review, context compression kept the average cost to roughly $3.28 per document—a highly cost-effective alternative to manual human authoring.

Limitations and Future Work

While FormAct represents a significant leap forward, challenges remain. The system's effectiveness is currently bottlenecked by the Reviewing Agent's vision capabilities; current VLMs still miss subtle styling inconsistencies or "vibe" issues. Additionally, the framework relies on high-end proprietary models, leaving its performance on smaller, open-source models as an open question.

Finally, while theoretically format-agnostic, FormAct's current tools are optimized for HTML. Extending the system to support LaTeX for academic papers or native OOXML for Word files will require the development of new specialized editors and benchmarks.

Summary updated

BibTeX
@inproceedings{yu2026formact,
  author = {Eugene J. Yu and Xingxing Zhang and Yuan Xia and Tao Ge and Xun Wang and FNU Kartik and Vishwas Suryanarayanan and Cheng Yang and Amanda Jiang and Jiayu Ding and Xiangyu Wong and Tengchao Lv and Lei Cui and Si-Qing Chen and Furu Wei and Sujian Li},
  title = {{FormAct: Agentic Source Editing for Rich-Format Document Generation}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=n7Ta0YEcgw},
}
Figure