MarsCode Agent: AI-native Automated Bug Fixing

Yizhou Liu,Pengfei Gao,Xinchen Wang,Jie Liu,Yexuan Shi,Zhao Zhang,Chao Peng
2024-09-04
Abstract:Recent advances in large language models (LLMs) have shown significant potential to automate various software development tasks, including code completion, test generation, and bug fixing. However, the application of LLMs for automated bug fixing remains challenging due to the complexity and diversity of real-world software systems. In this paper, we introduce MarsCode Agent, a novel framework that leverages LLMs to automatically identify and repair bugs in software code. MarsCode Agent combines the power of LLMs with advanced code analysis techniques to accurately localize faults and generate patches. Our approach follows a systematic process of planning, bug reproduction, fault localization, candidate patch generation, and validation to ensure high-quality bug fixes. We evaluated MarsCode Agent on SWE-bench, a comprehensive benchmark of real-world software projects, and our results show that MarsCode Agent achieves a high success rate in bug fixing compared to most of the existing automated approaches.
Software Engineering,Artificial Intelligence
What problem does this paper attempt to address?
The problem this paper attempts to address is the task of code repair in automated software development. Specifically, the paper introduces a new framework called MarsCode Agent, which leverages large language models (LLMs) to automatically identify and fix errors in software code. Existing automated code repair methods often rely on manually written rules and heuristic algorithms, which have limitations when dealing with complex and diverse real-world software systems. MarsCode Agent aims to more accurately locate faults and generate high-quality patches by combining the powerful capabilities of LLMs with advanced code analysis techniques. The main contributions of the paper include: 1. **Multi-agent collaboration framework**: Dynamically allocates static or dynamic resolution pipelines based on the nature of the problem, flexibly adapting to various code repair challenges. 2. **Code knowledge graph and language server protocol**: Provides agents with comprehensive code entity retrieval, relationship retrieval, and definition and reference navigation capabilities, enabling agents to browse and analyze code like human developers. 3. **Conflict-based code edit description and static syntax checking**: Accurately generates well-formatted code patches. 4. **Containerized sandbox environment**: A Docker-based sandbox environment that equips agents with debugging capabilities similar to human developers, such as defect reproduction, log addition, and test framework execution. The paper demonstrates the effectiveness of MarsCode Agent in repairing various types of errors without human intervention through evaluation on the SWE-bench benchmark, and its performance surpasses most existing automated code repair tools.