AnyMAC: Cascading Flexible Multi-Agent Collaboration via Next-Agent Prediction

Song Wang, Zhen Tan, Zihan Chen, Shuang Zhou, Tianlong Chen, Jundong Li · DOI

Introduction

The deployment of Large Language Model (LLM) agents in collaborative teams has emerged as a powerful strategy for solving complex reasoning tasks. However, traditional multi-agent frameworks are often constrained by their underlying communication topologies—typically structured as chains, trees, or Directed Acyclic Graphs (DAGs). These static structures impose significant limitations on the flexibility and information flow of agent interactions. AnyMAC (Any-Agent Multi-Agent Collaboration) addresses these challenges by reframing multi-agent coordination as a sequential "Next-Agent Prediction" task, enabling dynamic agent reuse and global context retrieval.

The Constraints of Graph-Based Topologies

Current multi-agent systems generally rely on fixed or learned communication graphs. While effective for certain structured tasks, these approaches suffer from two primary drawbacks:

  1. Structural Rigidity: Static topologies prevent agents from being revisited once their position in the graph is passed. For instance, a "Python Expert" used early in a reasoning chain cannot be re-invoked later to debug a final output if the graph does not explicitly permit a cycle.
  2. Information Bottlenecks: In a DAG or tree, an agent typically only receives information from its immediate predecessors. This "local context" restriction prevents agents from accessing critical insights generated in parallel branches or much earlier steps, often leading to fragmented reasoning.

The AnyMAC Framework: Sequential Collaboration

AnyMAC moves beyond the "graph ceiling" by treating collaboration as a step-by-step sequence generation process. The framework utilizes a transformer-based router to manage the interaction flow through three core components:

1. Contextual Encoding

The process begins with a lightweight router (utilizing a GPT-2 Small backbone) that tokenizes the initial task query, the descriptions of available agent roles, and the ongoing conversation history. A Transformer encoder produces contextualized embeddings that fuse the user's intent with the evolving dialogue state.

2. Next-Agent Prediction (NAP)

Rather than following a predefined edge, AnyMAC computes compatibility scores between the current state and all available agent roles. The system then selects the most appropriate agent for the next step. This mechanism naturally supports agent reuse, allowing the same expert to be called multiple times as the problem-solving process evolves.

3. Next-Context Selection (NCS)

To overcome the limitations of local context, AnyMAC employs a gating mechanism for "global context" retrieval. This allows the system to selectively pull relevant information from any previous step in the sequence, ensuring that the active agent has the most pertinent data regardless of when it was generated.

Optimization via Reinforcement Learning

The router is trained using Reinforcement Learning (RL) with a multi-faceted reward function. An Efficiency-Aware Reward penalizes excessively long reasoning paths, while a Sparsity Penalty prevents the context from becoming overloaded, ensuring the LLM agents receive concise and relevant inputs.

Experimental Evaluation

The authors evaluated AnyMAC across a diverse set of benchmarks, including general reasoning (MMLU), mathematics (GSM8K, MultiArith, SVAMP, AQuA), and code generation (HumanEval). AnyMAC was compared against a wide array of baselines, including single-agent methods (CoT, Self-Consistency) and multi-agent frameworks like AutoGen, DyLAN, and G-Designer.

Performance and Accuracy

AnyMAC achieved a state-of-the-art average accuracy of 90.62% across all benchmarks, surpassing existing learners like G-Designer. Notable gains were observed in specialized domains, including a +10.26% improvement on GSM8K and a +18.44% increase on HumanEval compared to base LLM performance.

Efficiency and Robustness

A specialized variant, AnyMAC-Eff, demonstrated that high accuracy can be maintained with significantly reduced communication overhead. By being highly selective with context, it achieved the lowest token consumption among all tested multi-agent frameworks.

Furthermore, AnyMAC proved remarkably robust to adversarial conditions. When "malicious" or distracting agents were introduced into the pool, AnyMAC’s performance dropped by only 1.3%, whereas traditional graph-based methods saw declines of up to 11%. This suggests that the router effectively learns to identify and bypass unreliable contributors.

Discussion and Future Work

While AnyMAC sets a new standard for flexible collaboration, it faces challenges in high-complexity tasks like coding, where the model occasionally selects overly long contexts that can overwhelm the agent. Future research will focus on improving RL sample efficiency and exploring the integration of smaller, specialized LLMs as agents to further optimize the cost-to-intelligence ratio. By breaking the constraints of fixed topologies, AnyMAC paves the way for more adaptive and resilient multi-agent intelligence.

Summary updated

BibTeX
@misc{wang2025anymac,
  author = {Song Wang and Zhen Tan and Zihan Chen and Shuang Zhou and Tianlong Chen and Jundong Li},
  title = {{AnyMAC: Cascading Flexible Multi-Agent Collaboration via Next-Agent Prediction}},
  year = {2025},
  eprint = {2506.17784},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.17784},
}
Figure