The Research Report
SEMAG: Self-Evolutionary Multi-Agent Code Generation That Actually Ships
Most multi-agent code generation systems share a flaw. They fix the architecture and hope the agents figure out the rest. SEMAG (arXiv 2603.15707) takes the opposite approach. It lets the system evolve its own structure. The results speak for themselves: 52.6% Pass@1 on CodeContests and SOTA across seven benchmarks.
The Three Innovations
SEMAG combines three mechanisms that work together. None is entirely new on its own. The combination is what produces the results.
Adaptive hierarchical prompting. Instead of flat prompting where every agent gets the same instruction style, SEMAG adapts the prompt structure based on the task's position in the solution hierarchy. Top-level decomposition gets one prompt style. Subtask implementation gets another. Integration and testing gets a third. The hierarchy is not fixed. The system decides how deep to decompose based on problem complexity.
Discussion-decision module. When agents disagree, most systems either pick a winner by authority or average the responses. SEMAG runs a structured discussion protocol. Agents present their reasoning. They critique each other's approaches. Then a decision agent picks the best path based on the discussion record. This is closer to how human engineering teams actually resolve design disagreements.
Automatic backbone switching. Different code generation subtasks have different demands. A planning task might benefit from a model with strong reasoning. An implementation task might benefit from a model with strong code generation. SEMAG switches the underlying backbone model dynamically based on the subtask profile. This is not manual routing. The system learns which backbone works best for which subtask type over multiple runs.
The Numbers
The headline number is 52.6% Pass@1 on CodeContests. For context, CodeContests problems are competitive programming challenges. They require algorithm design, correct implementation, and handling edge cases. Previous SOTA was substantially lower.
Across seven benchmarks including HumanEval, MBPP, LiveCodeBench, and CodeContests, SEMAG achieves SOTA. The gains are not marginal. The paper reports consistent improvements of 5-15 percentage points over prior multi-agent systems.
Why Evolution Matters
The "self-evolutionary" in the name is not marketing. SEMAG improves its own prompting strategies, discussion protocols, and backbone assignments through iterative feedback. After solving a set of problems, the system analyzes which strategies worked, which discussions led to correct solutions, and which backbone assignments produced the best code. It adjusts for the next iteration.
This creates a virtuous cycle. Better prompting leads to better discussion. Better discussion leads to better decisions. Better decisions lead to better code. Better code provides better feedback for the next round of evolution.
The key is that the evolution operates at the system level, not the model level. SEMAG does not fine-tune any backbone model. It evolves the orchestration layer. This means you can plug in new models as they become available and the evolutionary process will discover how to use them.
The Discussion Protocol in Detail
The discussion-decision module deserves attention because it addresses a real problem. In multi-agent systems, agents often produce contradictory solutions. Agent A says use dynamic programming. Agent B says use a greedy approach. How do you resolve this?
Most systems use a simple voting mechanism or a fixed authority hierarchy. SEMAG does something more structured:
- Each agent proposes a solution with reasoning
- Agents review each other's proposals and identify weaknesses
- Agents revise their proposals based on critique
- A designated decision agent evaluates the full discussion record and selects the approach
This adds compute cost but improves quality. The discussion surfaces assumptions and edge cases that individual agents miss. The paper shows that the discussion step alone contributes significant gains, even without the evolutionary loop.
Practical Implications
If you build code generation agents, three takeaways from SEMAG:
Adapt the prompt to the role. Stop using the same prompt template for planning, implementation, and review. Each role needs different context, different reasoning instructions, and different output formats.
Make disagreement productive. When agents disagree, do not just pick one. Run a structured discussion. The process of defending and critiquing approaches produces better solutions than any single agent could generate alone.
Match the model to the task. If you have access to multiple backbone models, route subtasks to the model best suited for them. Planning tasks to reasoning-heavy models. Implementation tasks to code-strong models. This is obvious in hindsight but rarely implemented.
Limitations
SEMAG is compute-intensive. The discussion protocol adds multiple LLM calls per problem. The evolutionary loop requires running the full pipeline many times. The paper does not fully address the cost-quality tradeoff. For competitive benchmark performance, the cost is justified. For production code generation with tight latency budgets, the overhead may be prohibitive.
The automatic backbone switching assumes access to multiple models. If you are locked into a single provider or model, this component degrades to a no-op. The other two mechanisms still work, but you lose one of the three pillars.
The Takeaway
SEMAG proves that multi-agent code generation improves when the system evolves its own orchestration. Fixed architectures hit ceilings. Adaptive systems break through them. The three mechanisms (hierarchical prompting, discussion-decision, backbone switching) are independently useful. Together, they set a new bar. If you are building a code generation pipeline, adopt at least one of these. The discussion protocol is the easiest win to implement first.
Based on arXiv 2603.15707. 52.6% on CodeContests is not a typo. The self-evolutionary architecture earns those numbers.