MARS$^2$: Scaling Multi-Agent Tree Search via Reinforcement Learning for Code Generation

Pengfei Li, Shijie Wang, Fangyuan Li, Yikun Fu, Kaifeng Liu, Kaiyan Zhang, Dazhi Zhang, Yuqiang Li, Biqing Qi, Bowen ZhouarXiv 2026

TL;DR

MARS$^2$ (Multi-Agent Reinforced Tree-Search Scaling) is a novel reinforcement learning framework that overcomes the exploration limits of single-policy models by embedding multiple independently optimized AI agents within a shared, learnable tree-search environment. By combining multi-agent collaboration with structured tree search and tree-consistent reward shaping, MARS$^2$ significantly boosts both trajectory diversity and performance on complex reasoning tasks like code generation.

What Problem Does This Paper Address?

Reinforcement learning (RL) algorithms like Group Relative Policy Optimization (GRPO) have driven massive breakthroughs in LLM reasoning. However, they face a fundamental bottleneck: diminishing exploration returns. Because a single agent samples from its own prior distribution, its exploration space is implicitly bounded. Over time, the model prematurely converges to local optima, repeatedly visiting the same high-probability branches.

While search-augmented RL (e.g., using Monte Carlo Tree Search) helps expand the search space, it still relies on a single policy distribution. Conversely, multi-agent RL introduces diverse perspectives but typically relies on shallow interaction paradigms like multi-round dialogue or voting, which are completely disconnected from structured search operations like branching and backtracking.

MARS$^2$ bridges this gap by integrating multi-agent collaboration directly into a structured tree-search training loop.

Methods

MARS$^2$ treats the search tree not just as a static sampling tool, but as a structured, learnable multi-agent environment where heterogeneous agents collaboratively generate and refine solutions.

Overview of the MARS$^2$ framework

The core mechanics include:

  1. Agent-Node Selection via Thompson Sampling: At each expansion step, the framework uses Beta priors to select the most promising agent and node pair. Nodes are categorized into generation nodes (for horizontal expansion/new solutions) and refinement nodes (for vertical refinement of existing code branches).
  2. Tree-Consistent Reward Shaping: To handle the non-stationarity of multiple policies updating simultaneously, MARS$^2$ introduces a hierarchical baseline that balances vertical improvement (over the parent node) and horizontal competition (against sibling nodes).
  3. Optimization Objective: The framework extends GRPO to tree nodes. Each agent is optimized independently using a path-level group advantage formulation calculated from these shaped rewards.

Datasets

  • Training: A filtered subset of the open-source code generation dataset released by DeepCoder, resulting in 7,992 code generation prompts. Filtering removed prompts where models always achieved perfect scores or always received zero rewards to ensure high-quality optimization signals.
  • Evaluation: LiveCodeBench (v6, 01/2025–05/2025) was utilized to evaluate code generation, ensuring zero data contamination since the benchmark was released after the base models were developed.
  • Generalization: The MATH dataset was used to test the framework's transferability to mathematical reasoning tasks.

Key Insights and Ideas

  • Heterogeneity Drives Exploration: Maintaining multiple agents with distinct policy biases prevents the search tree from collapsing into a narrow set of branches, preserving a richer pool of candidate solutions.
  • Structured Collaboration > Simple Debate: Instead of just talking to each other, agents physically build upon, branch from, and refine each other's code trajectories within the shared search topology.
  • Intermediate Supervision Stabilizes Training: Without tree-consistent reward shaping, training is highly unstable and slow to improve. Introducing a mixed baseline provides dense, intermediate feedback that reduces gradient variance and accelerates convergence.
Training curves showing the stabilizing effect of reward shaping

Key Results

MARS$^2$ consistently outperformed both vanilla GRPO and single-agent tree search ($RS^2$) across various model scales (8B and 14B) and architectures (Qwen3 and AReaL).

Figure 2: Pass@1 accuracy over training steps for multi-agent MARS2 training on paired models. Results are shown for Qwen-8B + AReaL-8B and Qwen-14B + AReaL-14B.
  • Single-Model Capability: For Qwen3-8B, MARS$^2$ achieved a Pass@1 score of 58.3%, representing an 8.0% absolute improvement over the base model, 4.4% over Vanilla GRPO, and 2.9% over single-agent tree search ($RS^2$).
  • System-Level Collaboration: A multi-agent system of Qwen3-8B & AReaL-8B trained via MARS$^2$ achieved a Pass@1 (MCTS) score of 61.7%, clearly outperforming the base system (57.2%) and Vanilla GRPO (56.0%).
  • Robustness to Weaker Agents: Even when a significantly weaker model (DeepCoder-14B) was introduced into a 14B multi-agent ensemble, the system-level performance continued to improve monotonically, proving that MARS$^2$ effectively aggregates complementary information without being dragged down by weaker peers.

Limitations and Future Work

The primary limitation of MARS$^2$ is training efficiency. Because multi-agent tree search relies on sequential interactions and expansions among agents, it reduces rollout parallelism. This increases overall training time compared to standard single-agent parallel sampling methods, even though it consumes the same amount of data and total tokens.

The authors note that developing more efficient, parallelized search mechanisms that preserve these multi-agent collaborative advantages is a vital direction for future research.

Summary updated

BibTeX
@misc{li2026mars,
  author = {Pengfei Li and Shijie Wang and Fangyuan Li and Yikun Fu and Kaifeng Liu and Kaiyan Zhang and Dazhi Zhang and Yuqiang Li and Biqing Qi and Bowen Zhou},
  title = {{MARS$^2$: Scaling Multi-Agent Tree Search via Reinforcement Learning for Code Generation}},
  year = {2026},
  eprint = {2604.14564},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.14564},
}

Loading related content...

Figure