MARS: Multi-Specialist LLM Relay System for Competitive Programming
For competitive programming, a relay of topic-specialist AIs beats one generalist model handing coding work off in sequence
MARS replaces the generic planner-coder-debugger roles used in existing multi-agent coding pipelines with topic specialists—dynamic programming, graphs, strings, geometry, and more—each grounded by retrieval over an algorithm-theory corpus. A small team of relevant specialists is selected per problem, a starter writes an initial C++17 draft, and each subsequent specialist runs the code against public tests before deciding to keep, repair, or hand it off. On Gemma 4 with the CodeContests test split, MARS reached a 0.624 pass rate, 14.4 points above direct prompting, closing most of the gap to CodeSIM (0.731) at 3.3x lower wall-clock cost.
METAL LAB explanatory visual
MARS Relay Pipeline Structure
Evidence statusMeasured results reported
- Specialist Pool & Team SelectionEleven topic-specialist agents self-assess against a shared cp-algorithms retrieval corpus; up to three relevant specialists are shortlisted as the team.
- Starter DraftA starter agent selected from the team writes the initial C++17 solution.
- Execute-Check-Handoff TurnsEach turn runs the current draft against public test examples in a sandbox, and the active specialist decides to keep, repair, or hand off the code.
- Relay TerminationThe relay stops on an explicit stop signal, when specialists run out, at the 8-step budget, or after a no-progress streak.
- Infrastructure Fixer & ResultA final boilerplate-only fixer pass normalizes I/O and compilation issues, yielding a 0.624 pass rate on CodeContests with Gemma 4.
What they did
- Existing multi-agent coding pipelines split work into generic planner, coder, and debugger roles and leave actual algorithmic technique selection entirely to the underlying LLM, providing no mechanism for real domain expertise.
- MARS builds a small team of up to three relevant specialists out of a pool of eleven topic experts using retrieval-based self-assessment; a starter agent writes an initial C++17 solution, and each following turn runs the draft against public test examples in a sandbox before the active specialist decides to keep, repair, or hand off the code.
- On 165 CodeContests test tasks with the Gemma 4 backbone, MARS reached 0.624±0.006 pass rate at an average of 2.3 recorded pipeline stages per task, beating direct prompting by 14.4 points, single-specialist Single-RAG by 9.5 points, and the Parallel ensemble baseline by 6.0 points.
- MARS still trails the heavier plan-simulate-debug system CodeSIM (0.731) but closes most of that gap while using 3.3x lower wall-clock cost and substantially smaller variance in per-task token spend.
- The ordering Direct < Single-RAG < MARS held when swapping in other backbones (Qwen3.5-27B, GPT-5.4-mini) and when switching to Python, and removing the retrieval component cost 2.0 points in pass rate.

| Method | Pass rate | Sec | Tokens | Calls |
|---|---|---|---|---|
| Direct | 0.48± 0.02 | 34.9± 49.6 | 1.8± 1.2 | 1.0± 0.0 |
| Single-RAG | 0.53± 0.01 | 59.8± 21.2 | 25.0± 3.2 | 12.0± 0.0 |
| Parallel ens. | 0.56± 0.00 | 360.9± 172.9 | 29.8± 5.1 | 17.6± 0.8 |
| Base relay | 0.55± 0.00 | 191.6± 91.5 | 34.1± 10.2 | 17.1± 1.7 |
| MARS | 0.62± 0.01 | 244.3± 154.4 | 40.3± 8.1 | 16.6± 1.3 |
| CodeSIM∗ | 0.73± 0.01 | 817.5± 1358.5 | 32.2± 54.8 | 10.2± 14.2 |

| Method | Pass rate | Sec | Tokens | Calls |
|---|---|---|---|---|
| Qwen3.5-27B, C++17 | ||||
| Direct | 0.192±0.018 | 27.2±74.6 | 1.7±2.2 | 1.0±0.0 |
| Single-RAG | 0.264±0.004 | 71.0±57.1 | 26.5±4.0 | 12.0±0.0 |
| MARS | 0.297±0.012 | 109.7±99.7 | 40.5±18.7 | 15.3±3.3 |
| GPT-5.4-mini, C++17 | ||||
| Direct | 0.149±0.019 | 3.4±2.3 | 1.2±0.5 | 1.0±0.0 |
| Single-RAG | 0.364±0.024 | 49.7±26.3 | 24.7±3.2 | 12.0±0.1 |
| MARS | 0.503±0.043 | 92.2±61.1 | 36.8±7.4 | 15.8±1.8 |
| Gemma 4, Python (PyPy 3) | ||||
| Direct | 0.485±0.000 | 70.0±137.8 | 1.6±1.0 | 1.0±0.0 |
| MARS | 0.622±0.015 | 307.6±215.7 | 42.9±9.1 | 17.1±1.4 |
| PairCoder | 0.705±0.009 | 426.7±451.7 | 27.6±20.9 | 7.6±5.4 |

| Configuration | Pass rate | Δ |
|---|---|---|
| MARS (full) | 0.624±0.006 | — |
| w/o RAG grounding | 0.604±0.007 | −0.020 |
| Generalists, no RAG | 0.615±0.013 | −0.009 |
| Earlier Base relay | 0.552±0.000 | −0.072 |
| Parallel manager | 0.564±0.000 | −0.060 |

Findings
- On 165 CodeContests test tasks with Gemma 4, MARS reached 0.624±0.006 pass rate at 2.3 recorded pipeline stages per task, beating Direct by 14.4 points, Single-RAG by 9.5 points, and Parallel ensemble by 6.0 points.
- CodeSIM reached the highest pass rate at 0.731±0.009, but MARS closed most of that gap at 3.3x lower wall-clock cost (about 244.3s per task versus roughly 817s for the CodeSIM rerun).
- By difficulty tier, Easy stayed near ceiling (0.80-0.93), while MARS's advantage over Direct widened on Medium (0.72 vs. 0.59) and Hard (0.40 vs. 0.18).
- The ordering Direct < Single-RAG < MARS held across other backbones (Qwen3.5-27B, GPT-5.4-mini) and on Python, where MARS reached 0.622±0.015 versus Direct's 0.485, a 13.7-point gap.
- Removing RAG cost 2.0 points in pass rate, and Base relay and Parallel manager trailed MARS by 7.2 and 6.0 points respectively.
Where it can be used
- Designing pipelines for competitive-programming-style or algorithm-heavy coding tasks that assemble a small team of retrieval-grounded topic specialists instead of relying on one generalist model.
- Building self-checking workflows where an agent runs its own draft against public tests each turn and decides whether to keep, repair, or hand off the work.
- Building practical code-generation services that need to control wall-clock cost and token-spend variance while still capturing much of the accuracy of heavier iterative-search systems.
Limits and open work
- Evaluation is limited to 165 CodeContests tasks, three backbones, two languages (C++17 and Python), one algorithm-theory corpus (cp-algorithms), and Codeforces tags, so generalization beyond this setup is untested.
- The deterministic gate only catches same-turn public-test regressions; it misses hidden tests and cannot compare across specialists, and all generated code still requires sandboxed execution.
- Only CodeSIM was compared under the same stage-aligned protocol, and PairCoder was only compared in Python; several other baselines (LDB, LPW, MapCoder, MaintainCoder, Xolver) could not be ported due to language or protocol mismatches.
- The jump from Base relay to MARS (0.552 to 0.624) combines several simultaneous changes (public-test self-check, subtask tracking, infrastructure fixer), so individual contributions are not isolated.
- The RAG-ablation comparison against a non-RAG generalist also changes retrieval itself, so it does not cleanly isolate the effect of specialization alone.
Why it matters
For tasks like competitive programming, where correctness signal is sparse and deep algorithmic knowledge matters, this shows that grounding specialized agents in real topic knowledge via retrieval can match much of a heavier system's performance at a fraction of the cost. Anyone designing multi-agent coding pipelines gets a concrete alternative to generic role-splitting: a lightweight relay of topic specialists with in-loop execution feedback.
Terms in this paper
- RAG (검색증강생성, retrieval-augmented generation) · 모델이 응답을 생성할 때 외부 문서를 검색해 그 내용을 참고하도록 하는 기법
- relay pipeline · 한 에이전트가 작성한 코드를 다음 에이전트가 이어받아 순서대로 수정해 나가는 진행 구조
- pass rate · 전체 문제 중 정답으로 통과 판정된 비율
- ExecEval · 생성된 코드를 실제로 공개 테스트 예제에 대해 실행해 통과 여부를 확인하는 샌드박스 환경
- CodeSIM · 계획 수립, 시뮬레이션, 디버깅을 반복하는 비교 대상 다중 에이전트 코드 생성 시스템
Original abstract (English)
Large Language Models excel at code generation, yet competitive programming exposes a persistent failure mode: existing multi-agent pipelines distribute work over generic planner, coder, and debugger roles and delegate the choice of algorithmic technique to the backbone alone. We present MARS (Multi-Agent Relay of Specialized LLMs), a prompt-only framework in which each agent is a topic specialist---dynamic programming, graphs, strings, geometry, and so on---grounded by retrieval-augmented generation over an algorithm-theory corpus. Given a problem, retrieval selects a small team of relevant specialists; a starter writes an initial C++17 solution, and each subsequent turn runs the candidate against public examples in a sandbox, lets the active specialist keep, repair, or hand off the draft, and forwards a structured packet to the next specialist. A single infrastructure-fixer pass normalizes boilerplate at the end. On the CodeContests test split with Gemma 4, MARS reaches $0.624 \pm 0.006$ pass rate at $2.3$ recorded pipeline stages per task ($+14.4$ percentage points over direct prompting), closing most of the gap to CodeSIM ($0.731$) at $3.3{\times}$ lower wall-clock cost and substantially smaller variance in per-task token spend. The source code is available on GitHub: https://github.com/fckand/mars.
Read on arXivLatest papers
- Sycophantic Chatbots Cause Delusional Spiraling, Even in Ideal BayesiansA math model shows that even a perfectly rational person can be talked into delusion by a chatbot that keeps agreeing with them
- Autonomous Mathematical Discovery in an Open-World Multi-Agent EnvironmentAI agents from different companies self-organized in an open-world simulation and produced new results on five math problems, with no one directing them
- Automata from Agent Traces: Failure and Next-Step PredictionResearchers compress massive LLM-agent execution logs into one small finite-state machine that predicts both the next action and eventual failure
- AgentRoom: Concurrent Multi-Agent Coding in a CRDT-Backed Shared WorkspaceLetting multiple AI coding agents share one workspace and coordinate in real time beats running them one-by-one or in uncoordinated parallel
- Recursive Agentic ReasoningSampling several answers and voting on them also fixes cases where an AI simply fails to produce any answer at all
- Black hole singularity is a surface not a pointA black hole's singularity is a surface, not a single point
- GameXpert-Bench: How Far Are Coding Agents from Expert Game Development?Coding agents are good at building a game from scratch but struggle to find their own bugs and keep fixes from breaking things
- There Is No Neutral Harness: Modern LLM Leaderboards Are Manufactured by Config-Fragile ItemsThe same model scores anywhere from 31% to 89% depending only on how you grade the multiple-choice test, and that hidden choice is quietly picking leaderboard winners
Latest from METAL LAB
- Pika, WAN 3.0에 얼굴 2개·배경 1개 따로 지정해 시대극 제작
- Prime Intellect publishes technical report on Prime Agent, ARC-AGI-3 score jumps from 30% to 95.5%
- Perplexity unveils agent memory system "Brain"
- Qwen's New Model Qwen3.8-Flash-Next Runs Locally on 75GB of Memory
- OpenAI Discloses Full Account of Hugging Face Breach
Figures: Andrei Mikhailov et al., arXiv:2608.23918, CC BY 4.0