RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graph

Siru Ouyang, Wenhao Yu, Kaixin Ma, Zilin Xiao, Zhihan Zhang, Mengzhao Jia, Jiawei Han, Hongming Zhang, Dong Yu · DOI

Abstract

Large Language Models (LLMs) have demonstrated remarkable proficiency in isolated coding tasks but struggle with repository-level software engineering, where understanding complex cross-file dependencies is critical. We present RepoGraph, a novel plug-in module that constructs a line-level dependency graph of a codebase. By providing LLMs with structured "ego-graphs" as context, RepoGraph enables precise navigation of intricate repositories. Our evaluation shows that RepoGraph improves the performance of existing AI software engineering frameworks by an average of 32.8%, achieving a new state-of-the-art resolve rate of 29.67% on SWE-bench-Lite when integrated with the Agentless framework.

Introduction

While LLMs excel at generating code snippets or single functions, real-world software development occurs at the repository level. Resolving a single bug often necessitates tracing logic across dozens of files and modules. Current approaches, such as Retrieval-Augmented Generation (RAG) and autonomous agentic frameworks, often fail to capture the structural "logic" of code. RAG typically treats repositories as flat collections of text, while agents often lose focus without a global structural map. RepoGraph addresses this "scaling gap" by providing a holistic, graph-based view of code dependencies.

Methodology

RepoGraph transforms a code repository into a line-level dependency graph $G = \{V, E\}$ through a three-step process:

  1. Line-Level Parsing: Utilizing tree-sitter, the system identifies key elements like functions, classes, and variables at the line level.
  2. Dependency Filtering: To maintain graph clarity, RepoGraph filters out external noise, such as standard library calls, focusing on internal project logic.
  3. Graph Construction: Nodes represent lines of code, while edges denote invoke (calls) or contain (structural) relationships.
RepoGraph construction and its integration into procedural and agentic frameworks.

When an LLM queries a specific term, RepoGraph retrieves a k-hop ego-graph—a localized map of direct and indirect dependencies. This high-density context is flattened into text, providing the model with a "navigation map" to trace data flow across file boundaries.

Experimental Evaluation

We evaluated RepoGraph on two major benchmarks:

  • SWE-bench-Lite: 300 real-world GitHub issues from popular Python projects.
  • CrossCodeEval: A benchmark for cross-file dependency handling in code completion.

RepoGraph was integrated as a plug-in for four baseline frameworks: RAG, Agentless, AutoCodeRover, and SWE-agent.

Results and Discussion

The integration of RepoGraph led to significant performance gains across all tested frameworks.

Quantitative results showing the performance boost of RepoGraph across different LLM frameworks on SWE-bench-Lite.

Key Findings:

  • Performance Gains: RepoGraph achieved a 32.8% average relative improvement in issue resolution. Notably, the Agentless + RepoGraph combination reached a 29.67% resolve rate, a new benchmark for open-source tools.
  • Granularity Matters: Moving from file-level to line-level context proved highly effective. Line-level nodes allow LLMs to pinpoint specific dependencies without being overwhelmed by irrelevant boilerplate code.
  • Framework Synergy: RepoGraph provided a more substantial boost to procedural frameworks compared to agentic ones. This suggests that structured graph data is particularly well-suited for deterministic, plan-based execution flows.
  • Cross-File Logic: On CrossCodeEval, RepoGraph nearly tripled the Exact Match (EM) score for GPT-4o (from 10.5 to 28.7), highlighting its superior ability to handle complex inter-file relationships.

Conclusion

RepoGraph demonstrates that structural, line-level context is essential for repository-level AI software engineering. By bridging the gap between flat text retrieval and complex code logic, it significantly enhances the problem-solving capabilities of LLMs. Future work will focus on expanding language support beyond Python and exploring dynamic graph updates that evolve as the LLM modifies the codebase.

Summary updated

BibTeX
@inproceedings{ouyang2025repograph,
  author = {Siru Ouyang and Wenhao Yu and Kaixin Ma and Zilin Xiao and Zhihan Zhang and Mengzhao Jia and Jiawei Han and Hongming Zhang and Dong Yu},
  title = {{RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graph}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=dw9VUsSHGB},
}
Figure