Abstract
MarsCode Agent is a multi-agent framework designed to automate the end-to-end bug-fixing process—from fault localization to patch validation. By combining the reasoning power of Large Language Models (LLMs) with specialized tools like Code Knowledge Graphs (CKG) and Language Server Protocols (LSP), it achieves a 34% success rate on the SWE-bench Lite benchmark. This paper details the architecture, specialized agent roles, and dual-path solving strategies that enable MarsCode Agent to outperform current state-of-the-art autonomous agents in real-world software repair.
Introduction
Automated Program Repair (APR) has evolved from fixing isolated code snippets to addressing "real-world" software issues within massive codebases. Modern challenges include navigating thousands of files, generating stable patches without breaking line offsets, and verifying fixes in complex environments. While LLMs excel at code generation, they often struggle with contextual navigation and precise editing. MarsCode Agent addresses these by moving beyond a single "do-it-all" agent toward a collaborative multi-agent system that leverages specialized tools for retrieval and verification.
Methodology
The core of MarsCode Agent is a specialized multi-agent architecture where each agent is assigned a specific role and a restricted toolset to ensure stability and reduce execution errors.
Specialized Roles and Tool Constraints
The framework employs six distinct roles: Searcher (retrieval), Planner (strategy), Reproducer (bug reproduction), Programmer (writing the fix), Tester (verification), and Editor (finalizing the patch). By restricting the tools available to each agent, the system avoids "agent confusion" and ensures that each component focuses on its primary task.
Dual-Path Solving Strategy
The Planner analyzes the issue and selects one of two primary workflows:
- Dynamic Debugging: Used for complex logic errors. It involves creating a reproduction script, running it in a Docker sandbox, and iteratively fixing the code based on test failures.
- Static Repair: Used for simpler fixes. It generates multiple candidate patches and uses a voting mechanism to select the best one.
Advanced Retrieval and Editing
MarsCode Agent utilizes Hybrid Indexing, combining a Code Knowledge Graph (CKG) for repository-level relationships with LSP for precise "jump-to-definition" capabilities. To solve the "line number" problem common in LLM-generated edits, the authors developed AutoDiff. This tool uses snippet-based matching with git-style conflict markers, allowing the agent to provide code blocks for surgical insertion without needing to calculate exact line offsets.
Evaluation and Results
The framework was evaluated on SWE-bench Lite, which consists of 300 real-world Python issues from popular GitHub repositories.
- Success Rate: MarsCode Agent successfully resolved 102 out of 300 issues (34%), significantly outperforming early LLM-based baselines.
- Localization Accuracy: The system achieved an 88.3% precision in identifying the correct file to fix.
- Workflow Efficacy: Dynamic debugging yielded a higher success rate (38.1%) than static repair (32.4%), highlighting the value of a sandbox environment for verification.
Discussion
Several key insights emerged from the development of MarsCode Agent. First, restricting agent toolsets is crucial for performance; not every agent needs every capability. Second, LSP serves as a "secret sauce" for navigating third-party libraries and resolving naming ambiguities that trip up standard RAG systems. Finally, the "AutoDiff" approach proves that LLMs are better at matching code patterns than performing the "math" required for line-based editing.
Conclusion and Future Work
MarsCode Agent demonstrates that a multi-agent approach combined with specialized engineering tools can effectively tackle real-world software maintenance tasks. Future work will focus on reducing the computational cost of multiple LLM calls, enhancing environment safety for debugging within user workspaces, and exploring human-in-the-loop collaboration for more complex debugging scenarios.
Summary updated