NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

AFlow: Automating Agentic Workflow Generation

Jiayi Zhang, Jinyu Xiang, Zhaoyang Yu, Fengwei Teng, Xiong-Hui Chen, Jiaqi Chen, Mingchen Zhuge, Xin Cheng, Sirui Hong, Jinlin Wang, Bingnan Zheng, Bang Liu, Yuyu Luo, Chenglin Wu

TL;DR

AFlow is a novel framework that automates the tedious process of designing "agentic workflows"—the sequences of instructions and LLM calls used to solve complex tasks. By treating workflow design as a search problem and utilizing Monte Carlo Tree Search (MCTS), AFlow discovers optimized structures that allow smaller, cheaper models to outperform giants like GPT-4o at less than 5% of the cost.

The Problem: The Bottleneck of Manual Prompt Engineering

While Large Language Models (LLMs) are incredibly powerful, they often struggle with complex, multi-step tasks when given a single prompt. To overcome this, researchers and developers use "agentic workflows": structured sequences where the model might brainstorm, critique its own work, write code, and then verify the output.

Currently, these workflows are almost entirely hand-crafted by human engineers. This manual approach to prompt engineering is slow, scales poorly to new domains, and often results in sub-optimal performance. Previous attempts to automate this process were either too linear (searching in a straight line without backtracking) or required a human-designed starting point. The authors of AFlow aimed for "full automation"—a system capable of starting from a blank slate to discover the optimal way for an LLM to "think" through a specific problem.

Methods: Workflow Generation as a Search Problem

To achieve full automation, the authors reformulate workflow generation as a search problem over code-represented workflows.

AFlow Search Process

Key components of the AFlow framework include:

  • Workflow as Code: Instead of simple graphs, AFlow represents the logic connecting LLM nodes as Python code. This allows the system to seamlessly explore complex structures like loops, conditional branching (if/else), and error handling.
  • Monte Carlo Tree Search (MCTS): To navigate the nearly infinite space of possible code structures, AFlow uses MCTS. This algorithm balances "exploration" (trying entirely new workflow ideas) with "exploitation" (refining versions of workflows that are already performing well).
  • Operators: These are predefined, reusable building blocks for common agentic patterns, such as Ensemble (voting), Review & Revise, and Programmer (writing and executing code).
  • Iterative Refinement: In each round, an LLM acts as an "optimizer" to modify the workflow code based on "experience" (logs of past successes and failures) and execution feedback from a validation dataset.

Key Insights and Results

The researchers evaluated AFlow across six diverse benchmarks covering three major domains: Mathematical Reasoning (GSM8K, MATH), Code Generation (HumanEval, MBPP), and Question Answering (HotpotQA, DROP).

Performance across benchmarks
  • State-of-the-Art Performance: AFlow yielded a 5.7% average improvement over existing state-of-the-art automated methods (like ADAS). On particularly tough tasks like MATH and MBPP, it outperformed previous automated baselines by a staggering 57%.
  • Extreme Cost Efficiency: One of the most striking findings is that a "weaker" model using an AFlow-optimized workflow can significantly outperform a "stronger" model using a standard approach. On the HumanEval benchmark, AFlow enabled a workflow using GPT-4o-mini to achieve parity with the much larger GPT-4o at only 4.55% of the inference cost.
  • Tree-Structured Experience is Key: Unlike previous methods that merely kept a flat list of past prompts, AFlow’s MCTS structure preserves the "ancestry" of a workflow. This prevents the optimizer from repeating past mistakes and helps it identify which specific modifications actually drove performance gains.
  • Model-Specific Optimization: The paper finds that the "best" workflow is often specific to the model being used. A strategy that helps a DeepSeek model might not be optimal for a Claude model, proving that automated design is necessary to unlock the unique strengths of different LLMs.
  • Emergent Complexity: In ablation studies where predefined "Operators" were removed, AFlow was still able to autonomously "reinvent" complex structures like multi-solution ensembles from scratch.

Limitations and Future Work

While highly effective, AFlow currently relies on tasks with clear, numerical evaluation functions (e.g., "is the math answer correct?"). Extending this to open-ended tasks (like novel writing) requires an "LLM-as-a-judge," which introduces potential biases from the judge model itself. Additionally, while the resulting workflows are cheap to run, the initial MCTS search process requires many iterations and LLM calls, making it computationally expensive upfront.

The authors suggest that future work could involve "meta-optimization," where the system learns to transfer successful workflow patterns from one domain to another, drastically reducing the initial search cost.

Summary updated

BibTeX
@inproceedings{zhang2025aflow,
  author = {Jiayi Zhang and Jinyu Xiang and Zhaoyang Yu and Fengwei Teng and Xiong-Hui Chen and Jiaqi Chen and Mingchen Zhuge and Xin Cheng and Sirui Hong and Jinlin Wang and Bingnan Zheng and Bang Liu and Yuyu Luo and Chenglin Wu},
  title = {{AFlow: Automating Agentic Workflow Generation}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=z5uVAKwmjf},
}
Figure