MASPO: Joint Prompt Optimization for LLM-based Multi-Agent Systems
Abstract
Large language model (LLM)-based Multi-agent systems (MAS) have shown promise in tackling complex collaborative tasks, where agents are typically orchestrated via role-specific prompts. While the quality of these prompts is pivotal, jointly optimizing them across interacting agents remains a non-trivial challenge, primarily due to the misalignment between local agent objectives and holistic system goals. To address this, we introduce MASPO, a novel framework designed to automatically and iteratively refine prompts across the entire system. A core innovation of MASPO is its joint evaluation mechanism, which assesses prompts not merely by their local validity, but by their capacity to facilitate downstream success for successor agents. This effectively bridges the gap between local interactions and global outcomes without relying on ground-truth labels. Furthermore, MASPO employs a data-driven evolutionary beam search to efficiently navigate the high-dimensional prompt space. Extensive empirical evaluations across 6 diverse tasks demonstrate that MASPO consistently outperforms state-of-the-art prompt optimization methods, achieving an average accuracy improvement of 2.9. We release our code at https://github.com/wangzx1219/MASPO.
Lay Summary
When we ask AI assistants to solve complex problems, sometimes a single AI isn't enough. Researchers often build "teams" of AI agents that work together. But getting these AI teammates to cooperate well is tricky: each agent needs the right instructions (called prompts), and a good instruction for one agent might accidentally confuse the next one in line. We developed MASPO, a method that automatically writes and refines instructions for every AI agent in a team so they work together smoothly. Our key insight is that an agent's instructions shouldn't just be judged by whether that agent does its own job well they should also be judged by whether they help the next agent succeed and whether the whole team reaches the right final answer. We also specifically hunt for "miscommunication" cases, where one agent looks like it did its part but actually misled its teammates, and use these examples to fix the problem. Tested across math, science reasoning, and coding tasks, MASPO consistently produced better results than existing methods. We have released our code so other researchers can build smarter, better-coordinated AI teams.