TL;DR
Current multi-agent LLM systems often fail because they rely on loosely coupled prompts and informal role definitions. This paper introduces SEMAP, a protocol-layer middleware that applies classic software engineering principles—like behavioral contracts and state-machine lifecycles—to multi-agent coordination. By formalizing how agents communicate and execute tasks, SEMAP slashes system failures by up to 69.6% in code development and 47.4% in vulnerability detection.
What Problem Does This Paper Address?
Multi-agent systems (MAS) using Large Language Models (like AutoGen or MetaGPT) show immense promise for automating software engineering (SE) tasks by mimicking human workflows. However, in practice, these systems frequently break down.
According to the Multi-Agent System Failure Taxonomy (MAST), these failures typically fall into three buckets:
- Under-specification: Agents don't fully understand their role boundaries or task requirements.
- Coordination misalignment: Agents misinterpret messages from one another.
- Inappropriate verification: The system moves forward or terminates before ensuring the output is actually correct.
The authors argue that these issues are symptoms of a deeper flaw: current frameworks lack foundational SE structuring principles. Instead of using well-defined components and strict interfaces, they rely on fragile, ad-hoc natural language prompts, leading to chaotic interactions.
Methods
To bridge this gap, the authors propose the Software Engineering Multi-Agent Protocol (SEMAP). Implemented as a lightweight middleware layer atop Google’s Agent-to-Agent (A2A) infrastructure, SEMAP introduces three core SE design principles to LLM coordination:
- Explicit Behavioral Contract Modeling: Inspired by Design by Contract (DbC), each agent is governed by a verifiable schema. This "Agent Card" explicitly declares pre-conditions (required input artifacts) and post-conditions (expected output contributions), clearly defining role boundaries.
- Structured Messaging: To eliminate communication misalignment, inter-agent messages are strictly typed. Instead of free-form text, agents exchange schema-designated objects (e.g., specific code snippets, review logs, or comments).
- Lifecycle-Guided Execution with Verification: System workflows are modeled as a Finite State Machine (FSM). Transitions between stages (e.g., from implementing to reviewing) are strictly gated by verification outcomes (pass/fail), preventing premature or invalid task termination.
Datasets
The authors evaluated SEMAP across two primary SE tasks—software development and vulnerability detection—using four distinct datasets:
- HumanEval: 164 coding problems used to test function-level code generation from textual specifications.
- ProgramDev: A dataset for deployment-level development where agents must build a complete deployment starting from a single-sentence user requirement.
- devign100: A 100-sample balanced subset of the Devign dataset, containing short C/C++ functions (under 30 lines) to test localized vulnerability detection.
- vudenc100: A 100-sample balanced subset of the CVEFixes dataset, featuring longer, structurally complex Python functions containing real-world CVE patches.
Key Insights and Ideas
- LLMs Need Structure, Not Just Better Prompts: Simply optimizing prompts within an unstructured environment yields diminishing returns. Applying rigid, classical SE constraints (like FSMs and typed schemas) paradoxically makes flexible LLM agents far more reliable.
- Eradicating Error Recurrence: In standard multi-agent setups, failures often fluctuate wildly or reappear across collaboration rounds. SEMAP enforces a stable downward trend in errors because its state machine prevents agents from backtracking into previously resolved failure states.
- Architecture Agnostic: SEMAP successfully stabilizes both centralized "CEO-style" architectures (used in the development tasks) and decentralized peer voting setups (used in vulnerability detection).
Key Results
The framework was tested against a MetaGPT baseline using DeepSeek-V3 and GPT-4-nano as underlying models.
- Code Generation: In function-level development (HumanEval), SEMAP achieved up to a 69.6% reduction in total failures with DeepSeek and 64.1% with ChatGPT. For deployment-level tasks (ProgramDev), it cut failures by 56.7% using DeepSeek and completely eliminated inter-agent misalignment errors.
- Vulnerability Detection: SEMAP reduced failure counts by up to 47.4% on Python tasks and 28.2% on C/C++ tasks. Unlike development tasks, the reductions here were evenly distributed across all failure categories, showcasing balanced parallel collaboration.
Limitations and Future Work
While promising, the authors note several areas for improvement:
- Scale: The preliminary evaluation relied on relatively small datasets (100 samples for vulnerability tasks) and short workflows (up to 5 rounds). Performance on massive, repository-scale codebases remains unproven.
- Ablation Studies: The paper does not isolate the individual impacts of contracts vs. structured messaging vs. lifecycle controls to see which principle contributes the most to failure reduction.
- Overhead: Enforcing strict schemas and state transitions introduces computational and token overhead that needs to be quantified.
Future work will focus on scaling up agent populations, enabling cross-agent tool usage, and introducing formal protocol correctness verification.
Summary updated