Most prompt optimization tools assume one model, one prompt, one answer. MASPO was built for a messier reality: teams of agents where each one's success depends on every other one's output.

The Local-Global Misalignment Problem

Multi-agent systems break in a specific and insidious way. An intermediate agent follows its instructions perfectly. Its output looks reasonable. But downstream peers read that output and head in the wrong direction. The system fails, and nobody can tell which prompt caused it.

This is local-global misalignment. Each agent optimizes for its own task. No agent optimizes for the chain.

Existing prompt optimization methods make this worse. They rely on labeled data to score prompt quality. But in a multi-agent pipeline, many agents do not produce final answers. They produce reasoning traces, summaries, or intermediate representations. There is no ground-truth label for "good summary that helps the next agent succeed." The credit assignment problem is severe.

Recent self-supervised strategies use comparative feedback to assess reasoning quality. They stay confined to isolated scopes. They cannot capture how a small change in one agent's output ripples through the chain and changes the final result.

Bayesian search methods select prompts from a fixed candidate pool. They cannot generate new prompts or make fine-grained adjustments. The combinatorial search space of multi-agent prompts is too large for this approach.

MASPO, accepted at ICML 2026, solves all three problems with a single framework.

What MASPO Does Differently

MASPO optimizes prompts jointly across all agents in a multi-agent system. It treats the pipeline as a directed communication graph where each agent's output feeds into the next. The framework iteratively refines every system prompt without requiring ground-truth labels for intermediate steps.

Three components make this work.

Multi-Granularity Joint Evaluation

Most prompt optimizers score one output at a time. MASPO scores along three dimensions simultaneously.

Local Validity measures whether an agent follows its own role-specific instructions. Does the summarizer actually summarize? Does the reasoner show its work?

Lookahead Potential measures whether an agent's output helps the immediate next agent succeed. This is the missing link in current methods. A prompt can produce locally valid output that is useless or harmful to the agent that reads it next.

Global Alignment measures whether the agent's output ultimately contributes to the correct final answer. This captures the full causal impact of one agent's behavior on the entire chain.

By combining these three scores, MASPO evaluates each prompt by its contribution to the entire causal chain rather than its isolated performance.

Misalignment-Aware Sampling

MASPO explicitly mines historical traces where coordination failed. These are cases where an agent fulfilled its local role but caused downstream or system-wide failure. The framework injects these "misalignment cases" as hard negatives into the search pool.

This is a targeted repair mechanism. Instead of randomly exploring prompt space, the optimizer focuses on the specific interaction breakdowns that actually happened. It learns from failure patterns, not just success patterns.

Evolutionary Beam Search with Beam Refresh

Prompt optimization in a multi-agent system is non-stationary. When you improve Agent A's prompt, Agent B's old prompt may no longer be optimal. The search space shifts as peer agents evolve.

MASPO uses a coordinate ascent-style scheduling protocol. It optimizes one agent at a time while holding others fixed, then cycles through. The Beam Refresh mechanism realigns each agent's search tree in real time as peer prompts change. This mitigates the non-stationarity problem that breaks naive joint optimization.

The Results

MASPO was evaluated across six diverse tasks. It achieved an average accuracy improvement of 2.9 percentage points over state-of-the-art prompt optimization methods.

The improvement is consistent, not isolated to one domain. The tasks span mathematical reasoning, code generation, and other collaborative scenarios. In each case, MASPO's joint evaluation mechanism found prompt combinations that local-only methods missed.

The 2.9pp figure is modest but meaningful. It represents a system-level gain across multiple task types, not a cherry-picked benchmark. For production multi-agent pipelines, consistent gains across diverse tasks matter more than single-task hero numbers.

Why This Matters Now

Multi-agent systems are moving from research demos to production deployments. Frameworks like AutoGen, CrewAI, and LangChain make it trivial to wire agents together. The hard part is getting them to cooperate.

Prompt engineering for multi-agent systems is currently done by hand. A developer writes prompts for each agent, tests the pipeline, tweaks one prompt, tests again, and repeats. This is combinatorial trial-and-error across N prompts with no clear signal about which one caused a failure.

MASPO automates this process. It treats the entire agent graph as the optimization target, not individual prompts in isolation. This is a shift from artisanal prompt tuning to systematic multi-agent engineering.

Getting Started

The MASPO code is available at github.com/wangzx1219/MASPO. The repository includes evaluation scripts, prompt files, and the full optimization pipeline.

The entry point is run_tbdspo.py with several key flags:

  • --optimize enables prompt optimization
  • --beam-refresh re-scores beam nodes when partner prompts update
  • --lookahead-score enables downstream performance scoring
  • --misleading-sampling injects misalignment cases into the search pool

The full MASPO configuration uses all four flags together.

python run_tbdspo.py --dataset aqua --graph reflect --optimize --fixed-rounds --beam-refresh --lookahead-score --misleading-sampling

The code is written in Python and runs against standard LLM APIs. No proprietary infrastructure is required.

The Bigger Picture

MASPO sits at the intersection of two trends. The first is prompt optimization moving from single-agent to multi-agent settings. The second is the growing recognition that agent interaction quality matters as much as individual agent capability.

Recent work on prompt optimization has produced impressive single-agent results. DSPy, GEPA, and TextGrad all optimize one prompt at a time. MASPO is the first major framework to treat the multi-agent pipeline as a unified optimization target.

The local-global misalignment problem is not a corner case. It is the default failure mode in any multi-agent system where agents pass intermediate outputs to each other. If you have ever built a pipeline where Agent A produces "reasonable" output that Agent B misinterprets, you have seen this problem.

MASPO gives you a way to measure and fix it. The multi-granularity evaluation tells you which agent's output is hurting the chain. The misalignment-aware sampling focuses optimization on the exact failure patterns you are seeing. The beam search with refresh keeps the optimization stable as agents co-evolve.

For teams building production multi-agent systems, this is the difference between hoping your prompts work together and knowing they do.

Citation

Zhexuan Wang, Xuebo Liu, Li Wang, Zifei Shan, Yutong Wang, Zhenxi Song, and Min Zhang. MASPO: Joint Prompt Optimization for LLM-based Multi-Agent Systems. arXiv:2605.06623, accepted at ICML 2026. Code: github.com/wangzx1219/MASPO.


Published May 22, 2026.