OFA-MAS: One-for-All Multi-Agent System Topology Design based on Mixture-of-Experts Graph Generative Models

Shiyuan Li, Yixin Liu, Yu Zheng, Mei Li, Quoc Viet Hung Nguyen, Shirui Pan

TL;DR

OFA-MAS introduces a "one-for-all" framework for multi-agent system (MAS) topology design, moving away from rigid, domain-specific models. By combining a task-aware graph encoder with a mixture-of-experts generative model, it dynamically designs optimal agent collaboration structures for any natural language query across diverse domains.

What Problem Does This Paper Address?

When building Multi-Agent Systems (MAS) powered by Large Language Models (LLMs), performance hinges heavily on topology—the structural design dictating which agents communicate, when they interact, and how information flows. An optimal topology ensures the right expert agent is queried at the right time, whereas a poor layout leads to coordination bottlenecks and errors.

Currently, automated topology design relies on a "one-for-one" paradigm: a specialized graph-learning model is trained exclusively for a single domain (e.g., solving math word problems). This approach suffers from three major flaws:

  1. Impractical Domain Assumptions: Real-world applications face unpredictable, cross-domain queries; forcing users to pre-categorize requests is unrealistic.
  2. Poor Scalability: Maintaining separate data collection and training pipelines for every new domain creates an intractable maintenance burden.
  3. Overlooked Shared Knowledge: Isolated models cannot leverage abstract, reusable collaboration patterns that span across domains (e.g., an "Analyst $\rightarrow$ Inspector $\rightarrow$ Solver" workflow applies equally well to both theorem proving and software debugging).

OFA-MAS solves this by pioneering a "one-for-all" paradigm, utilizing a single universal model capable of generating customized collaboration graphs from scratch for any task described in natural language.

Methods

The authors frame topology design as an autoregressive graph generation problem, building the agent network step-by-step (first selecting an agent role, then predicting its incoming communication edges). The architecture consists of two primary innovations:

  1. Task-Aware Graph State Encoder (TAGSE): Traditional graph neural networks ignore global task context during message passing. TAGSE uses context-gated message passing modulated by a global task vector (derived from the user's query via Sentence-BERT). This applies a sparse gating mechanism to filter out task-irrelevant node information, ensuring the representation is highly tuned to the specific query.
  2. Mixture-of-Experts (MoE) Generation Module: To handle diverse domains without sacrificing universality, the model routes generation decisions through an ensemble of specialized sub-networks (experts). An expert gating network takes the task vector and dynamically weights the contributions of different experts to predict the next node role and edge connections.
Architecture and training pipeline of OFA-MAS

Three-Stage Training Curriculum

To train this universal model without suffering from catastrophic forgetting or unstable convergence, the authors implement an easy-to-hard training strategy:

  • Stage 1: Unconditional Graph Pre-training: The model learns the basic "grammar" of valid graph structures by training on canonical topologies (Chains, Stars, Trees) without any task text.
  • Stage 2: LLM-Driven Task-Topology Alignment: To bypass the high cost of human annotation, the authors use GPT-4o-mini as a "proxy designer" to synthesize a large pseudo-labeled dataset of diverse query-topology pairs.
  • Stage 3: Supervised Generative Fine-tuning: The model is refined on a small fraction of real-world data where topologies have been empirically validated through actual MAS execution.

Datasets

The framework was evaluated across six diverse in-distribution benchmarks and one pure out-of-distribution (OOD) benchmark:

  • General Reasoning: MMLU (subset of 153 multiple-choice questions).
  • Math Reasoning: GSM8K (1,000 problems), MultiArith (600 problems), SVAMP (1,000 problems), and AQuA (254 algebraic problems).
  • Code Generation: HumanEval (164 programming problems evaluated via Pass@1).
  • Out-of-Distribution (OOD): GAIA (General AI Assistants benchmark), which requires multimodal reasoning, tool use, and web search. GAIA was completely unseen during training to test true zero-shot transfer capability.

Key Insights and Ideas

  • Cross-Domain Synergy: The core "aha moment" is that a single model trained across multiple domains actually outperforms specialized models. By exposing the network to diverse tasks, it learns to abstract and transfer structural problem-solving patterns across domains.
  • Universal Role Pools Enable Flexibility: Instead of restricting the model to a small, domain-specific set of agents, OFA-MAS draws from a universal pool of 19 roles. This allows it to compose unique cross-domain teams—for instance, injecting a general "Critic" agent (typically used in knowledge tasks) into a math-solving pipeline to verify steps.
  • Curriculum Overcomes Data Scarcity: Bootstrapping the model's structural knowledge via unconditional pre-training and LLM-driven synthesis makes training a universal graph foundation model feasible without requiring thousands of expensive, human-verified multi-agent trial runs.

Key Results

  • State-of-the-Art Performance: OFA-MAS achieved an average success rate of 93.02% across the six benchmarks, outperforming the best specialized "one-for-one" baseline, EIB-LEARNER (91.38%).
  • Strong Zero-Shot Generalization: On the unseen GAIA benchmark, OFA-MAS demonstrated superior out-of-distribution transfer, achieving an 8.79% average accuracy and comfortably beating specialized baselines that struggled to adapt.
  • High Token Efficiency: OFA-MAS achieves its high accuracy while maintaining competitive or superior token efficiency. On GSM8K, it achieved 95.30% accuracy at the lowest token cost ($6.3 \times 10^6$ tokens) among all competing methods.
Token cost comparison on MMLU and GSM8K
  • Exceptional Robustness: When subjected to adversarial attacks (where a key agent role is replaced with a malicious prompt designed to mislead), OFA-MAS experienced only a minor 2.2% performance drop, proving highly resilient compared to fixed or domain-specific topologies.

Limitations and Future Work

  • Graph Size Constraints: During inference, the maximum graph size is safeguarded at 6 nodes to prevent over-generation. While efficient, this constraint might limit its application to massive, highly complex enterprise workflows requiring dozens of agents.
  • Static Universal Pool: The framework relies on a predefined pool of 19 roles. A promising future direction is allowing the model to generate open-ended, entirely novel agent role descriptions on the fly based on the query context.

Summary updated

BibTeX
@inproceedings{li2026ofa,
  author = {Shiyuan Li and Yixin Liu and Yu Zheng and Mei Li and Quoc Viet Hung Nguyen and Shirui Pan},
  title = {{OFA-MAS: One-for-All Multi-Agent System Topology Design based on Mixture-of-Experts Graph Generative Models}},
  booktitle = {The Web Conference},
  year = {2026},
  doi = {10.1145/3774904.3792537},
}
Figure