RepoMaster: Autonomous Exploration and Understanding of GitHub Repositories for Complex Task Solving
作者: Huacan Wang, Ziyi Ni, Shuo Zhang, Shuo Lu, Sen Hu, Ziyang He, Chen Hu, Jiaye Lin, Yifu Guo, Ronghao Chen, Xin Li, Daxin Jiang, Yuntao Du, Pin Lyu
分类: cs.SE, cs.AI
发布日期: 2025-05-27 (更新: 2025-08-25)
备注: A novel approach; Very practical
🔗 代码/项目: GITHUB
💡 一句话要点
RepoMaster:自主探索和理解GitHub仓库,解决复杂任务
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 代码智能体 GitHub仓库 自主探索 知识图谱 大型语言模型
📋 核心要点
- 现有代码智能体难以有效利用GitHub上的开源仓库,因为信息量巨大且依赖关系复杂,超出LLM的上下文窗口限制。
- RepoMaster通过构建函数调用图、模块依赖图和分层代码树来提取仓库的核心组件,并逐步探索相关信息,优化上下文利用。
- 实验表明,RepoMaster在MLE-bench和GitTaskBench上显著提升了任务完成率,并大幅降低了token使用量。
📝 摘要(中文)
代码智能体的最终目标是自主解决复杂任务。尽管大型语言模型(LLM)在代码生成方面取得了显著进展,但实际任务通常需要完整的代码仓库,而不仅仅是简单的脚本。从头开始构建这样的仓库仍然是一个主要的挑战。幸运的是,GitHub托管着大量不断发展的开源仓库,开发者经常将其重用为复杂任务的模块化组件。然而,现有的框架(如OpenHands和SWE-Agent)仍然难以有效地利用这些宝贵的资源。仅仅依赖README文件提供的指导不足,更深入的探索揭示了两个核心障碍:海量的信息和仓库之间错综复杂的依赖关系,这两者都受到当前LLM有限上下文窗口的限制。为了解决这些问题,我们提出了RepoMaster,一个旨在探索和重用GitHub仓库以解决复杂任务的自主智能体框架。为了高效理解,RepoMaster构建函数调用图、模块依赖图和分层代码树来识别必要的组件,仅向LLM提供识别出的核心元素,而不是整个仓库。在自主执行过程中,它使用我们的探索工具逐步探索相关组件,并修剪信息以优化上下文使用。在调整后的MLE-bench上评估,RepoMaster在有效提交方面比最强的基线OpenHands提高了110%。在我们新发布的GitTaskBench上,RepoMaster将任务通过率从40.7%提高到62.9%,同时减少了95%的token使用量。我们的代码和演示材料可在https://github.com/QuantaAlpha/RepoMaster公开获取。
🔬 方法详解
问题定义:现有代码智能体在利用GitHub开源仓库解决复杂任务时,面临信息过载和依赖关系复杂的问题。仅仅依赖README文件不足以理解仓库,而直接将整个仓库输入LLM又会超出其上下文窗口限制,导致性能下降。现有方法难以有效提取和利用仓库中的关键信息。
核心思路:RepoMaster的核心思路是通过对GitHub仓库进行结构化分析,提取关键信息并构建知识图谱,从而帮助LLM更好地理解和利用仓库。它采用了一种逐步探索和信息过滤的方法,只将必要的组件提供给LLM,避免信息过载。
技术框架:RepoMaster框架包含以下主要模块:1) 仓库理解模块:构建函数调用图、模块依赖图和分层代码树,提取核心组件。2) 自主探索模块:使用探索工具逐步探索相关组件。3) 信息修剪模块:优化上下文使用,避免信息过载。4) LLM交互模块:与LLM交互,完成任务。
关键创新:RepoMaster的关键创新在于其结构化的仓库理解方法和逐步探索的信息过滤机制。它不是简单地将整个仓库提供给LLM,而是通过构建知识图谱来提取关键信息,并根据任务需求逐步探索相关组件。这种方法有效地解决了信息过载和依赖关系复杂的问题。
关键设计:RepoMaster在仓库理解模块中,使用静态分析和动态分析相结合的方法来构建函数调用图和模块依赖图。在信息修剪模块中,使用基于重要性的排序算法来选择保留哪些信息。在与LLM交互时,采用了一种迭代式的提示策略,逐步引导LLM完成任务。
🖼️ 关键图片
📊 实验亮点
RepoMaster在调整后的MLE-bench上,有效提交率比最强的基线OpenHands提高了110%。在GitTaskBench上,RepoMaster将任务通过率从40.7%提高到62.9%,同时减少了95%的token使用量。这些结果表明,RepoMaster能够显著提升代码智能体在复杂任务上的性能。
🎯 应用场景
RepoMaster具有广泛的应用前景,可以应用于自动化软件开发、代码维护、漏洞修复等领域。它可以帮助开发者更高效地利用开源代码,加速软件开发过程。此外,RepoMaster还可以用于教育领域,帮助学生更好地理解和学习开源项目。
📄 摘要(原文)
The ultimate goal of code agents is to solve complex tasks autonomously. Although large language models (LLMs) have made substantial progress in code generation, real-world tasks typically demand full-fledged code repositories rather than simple scripts. Building such repositories from scratch remains a major challenge. Fortunately, GitHub hosts a vast, evolving collection of open-source repositories, which developers frequently reuse as modular components for complex tasks. Yet, existing frameworks like OpenHands and SWE-Agent still struggle to effectively leverage these valuable resources. Relying solely on README files provides insufficient guidance, and deeper exploration reveals two core obstacles: overwhelming information and tangled dependencies of repositories, both constrained by the limited context windows of current LLMs. To tackle these issues, we propose RepoMaster, an autonomous agent framework designed to explore and reuse GitHub repositories for solving complex tasks. For efficient understanding, RepoMaster constructs function-call graphs, module-dependency graphs, and hierarchical code trees to identify essential components, providing only identified core elements to the LLMs rather than the entire repository. During autonomous execution, it progressively explores related components using our exploration tools and prunes information to optimize context usage. Evaluated on the adjusted MLE-bench, RepoMaster achieves a 110% relative boost in valid submissions over the strongest baseline OpenHands. On our newly released GitTaskBench, RepoMaster lifts the task-pass rate from 40.7% to 62.9% while reducing token usage by 95%. Our code and demonstration materials are publicly available at https://github.com/QuantaAlpha/RepoMaster.