MetaAgent: Automatically Constructing Multi-Agent Systems Based on Finite State Machines

Yaolun Zhang, Xiaogeng Liu, Chaowei Xiao

Building effective multi-agent systems (MAS) usually requires a human engineer to sit down and painstakingly define roles, communication protocols, and error-handling logic. While "automated" design methods exist, they often produce rigid, linear pipelines that break the moment something goes wrong.

In their paper, "MetaAgent: Automatically Constructing Multi-Agent Systems Based on Finite State Machines," researchers introduce a framework that lets a Large Language Model (LLM) act as both the architect and the optimizer of its own multi-agent team. By modeling agent interactions as a Finite State Machine (FSM), MetaAgent gains the flexibility to handle complex, non-linear tasks that require tool use and error recovery.

TL;DR

MetaAgent is a framework that automatically designs and optimizes multi-agent systems by modeling them as Finite State Machines. This approach allows agents to dynamically refine their work or "trace back" to previous steps to fix errors, outperforming existing automated methods and rivaling hand-tuned human designs.

What Problem Does This Paper Address?

Most current multi-agent frameworks fall into two camps:

  1. Human-Designed: Highly effective but rigid and expensive to build. They are usually "hard-coded" for specific scenarios (like software development).
  2. Auto-Designed: Systems that generate agents on the fly but typically organize them in simple linear chains or "debates."

The gap lies in generalization and robustness. Linear systems cannot handle "traceback"—if a bug is found in step 5, the system cannot easily go back to step 2 to fix the underlying logic. Furthermore, many automated methods lack tool integration or require massive amounts of external training data to optimize their performance.

Methods

MetaAgent treats the problem-solving process as a series of states. Each state contains a specific task-solving agent, a state instruction, and a set of listeners (other agents who receive the output).

The framework operates in three main stages:

  1. Construction Stage: Given a task description, a "Designer" LLM identifies the necessary agents and tools. It then maps out an FSM where states represent sub-tasks and transitions represent the logic for moving between them.
  2. Optimization Stage: Initial FSMs are often redundant. MetaAgent uses an "Adaptor" LLM to perform pairwise comparisons of states, merging those that are functionally similar to reduce communication overhead and complexity.
  3. Deployment Stage: During execution, a "Condition Verifier" checks if an agent's output meets transition criteria.
The construction and optimization flow of MetaAgent

Two key features make this FSM structure powerful:

  • Null-Transition: If an agent fails a task, the system stays in the current state and provides feedback for self-refinement.
  • State Traceback: If a downstream agent detects an error caused by an earlier step, the FSM can transition backward to a previous state to correct the mistake.

Datasets

The authors evaluated MetaAgent across a diverse range of benchmarks:

  • Text-Based Tasks: Trivial Creative Writing and GPQA (Diamond), which test reasoning and creative constraints.
  • Machine Learning Bench (ML Bench): Tasks requiring agents to train models on real datasets (e.g., Titanic, House Prices).
  • Software Development: Building functional apps and games (e.g., 2048, Snake, Weather apps).

Key Insights and Ideas

  • FSM as a Universal Structure: The authors demonstrate that common MAS structures—like linear chains, decentralized debates, or orchestrator-led teams—are actually just restricted or "weakened" versions of an FSM. By using a full FSM, MetaAgent captures the best of all worlds.
  • The Power of Traceback: In software tasks, the ability to return to the "Requirement Designer" state after a "Tester" agent finds a bug is critical. This mimics human workflows much more closely than linear pipelines.
  • Efficiency through Merging: The optimization step isn't just about speed; it's about reducing "noise." By merging redundant states, the LLM avoids losing context in excessively long chains of information transfer.
An example of the FSM in action for building a game

Key Results

  • Superior to Auto-Designers: MetaAgent outperformed other automated frameworks like SPP and AutoAgents across the board. In text-based tasks, it surpassed prompt-based SOTA methods by 9%.
  • Competitive with Humans: On the Machine Learning Bench, MetaAgent achieved 97% of the performance of DataInterpreter, a system specifically hand-tuned by humans for data science.
  • Software Success: In software development tasks, MetaAgent passed 50% more checkpoints than the human-designed MetaGPT.
  • Cost-Effective: Despite the extra "design" step, MetaAgent often resulted in lower total token costs during deployment because the optimized FSM structure prevented agents from wandering off-task or repeating unnecessary steps.

Limitations and Future Work

  • Executor Dependency: The system's performance is heavily tied to the quality of the underlying LLM. While it excels with GPT-4o, performance drops significantly when using smaller models like GPT-3.5-Turbo as the "executor."
  • Design Overhead: While deployment is efficient, the initial design and optimization phase incurs a one-time token cost that might be high for very simple tasks.
  • Future Directions: The authors suggest exploring more complex state transition logic and expanding the toolset to include more specialized industrial APIs.

Summary updated

BibTeX
@inproceedings{zhang2025metaagent,
  author = {Yaolun Zhang and Xiaogeng Liu and Chaowei Xiao},
  title = {{MetaAgent: Automatically Constructing Multi-Agent Systems Based on Finite State Machines}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=vOxaD3hhPt},
}
Figure