GraphCodeAgent: Dual Graph-Guided LLM Agent for Retrieval-Augmented Repo-Level Code Generation

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Li, Jia, Shi, Xianjie, Zhang, Kechi, Li, Ge, Jin, Zhi, Li, Lei, Zhang, Huangzhao, Liu, Fang, Zhang, Yuwei, Tao, Zhengwei, Dong, Yihong, Zhu, Yuqi, Tao, Chongyang
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866915625027239936
author Li, Jia
Shi, Xianjie
Zhang, Kechi
Li, Ge
Jin, Zhi
Li, Lei
Zhang, Huangzhao
Li, Jia
Liu, Fang
Zhang, Yuwei
Tao, Zhengwei
Dong, Yihong
Zhu, Yuqi
Tao, Chongyang
author_facet Li, Jia
Shi, Xianjie
Zhang, Kechi
Li, Ge
Jin, Zhi
Li, Lei
Zhang, Huangzhao
Li, Jia
Liu, Fang
Zhang, Yuwei
Tao, Zhengwei
Dong, Yihong
Zhu, Yuqi
Tao, Chongyang
contents Writing code requires significant time and effort in software development. To automate this process, researchers have made substantial progress for code generation. Recently, large language models (LLMs) have demonstrated remarkable proficiency in function-level code generation, yet their performance significantly degrades in the real-world software development process, where coding tasks are deeply embedded within specific repository contexts. Existing studies attempt to use retrieval-augmented code generation (RACG) approaches to mitigate this demand. However, there is a gap between natural language (NL) requirements and programming implementations. This results in the failure to retrieve the relevant code of these fine-grained subtasks. To address this challenge, we propose GraphCodeAgent, a dual graph-guided LLM agent for retrieval-augmented repo-level code generation, bridging the gap between NL requirements and programming implementations. Our approach constructs two interconnected graphs: a Requirement Graph (RG) to model requirement relations of code snippets within the repository, as well as the relations between the target requirement and the requirements of these code snippets, and a Structural-Semantic Code Graph (SSCG) to capture the repository's intricate code dependencies. Guided by this, an LLM-powered agent performs multi-hop reasoning to systematically retrieve all context code snippets, including implicit and explicit code snippets, even if they are not explicitly expressed in requirements. We evaluated GraphCodeAgent on three advanced LLMs with the two widely-used repo-level code generation benchmarks DevEval and CoderEval. Extensive experiment results show that GraphCodeAgent significantly outperforms state-of-the-art baselines.
format Preprint
id arxiv_https___arxiv_org_abs_2504_10046
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle GraphCodeAgent: Dual Graph-Guided LLM Agent for Retrieval-Augmented Repo-Level Code Generation
Li, Jia
Shi, Xianjie
Zhang, Kechi
Li, Ge
Jin, Zhi
Li, Lei
Zhang, Huangzhao
Li, Jia
Liu, Fang
Zhang, Yuwei
Tao, Zhengwei
Dong, Yihong
Zhu, Yuqi
Tao, Chongyang
Software Engineering
Writing code requires significant time and effort in software development. To automate this process, researchers have made substantial progress for code generation. Recently, large language models (LLMs) have demonstrated remarkable proficiency in function-level code generation, yet their performance significantly degrades in the real-world software development process, where coding tasks are deeply embedded within specific repository contexts. Existing studies attempt to use retrieval-augmented code generation (RACG) approaches to mitigate this demand. However, there is a gap between natural language (NL) requirements and programming implementations. This results in the failure to retrieve the relevant code of these fine-grained subtasks. To address this challenge, we propose GraphCodeAgent, a dual graph-guided LLM agent for retrieval-augmented repo-level code generation, bridging the gap between NL requirements and programming implementations. Our approach constructs two interconnected graphs: a Requirement Graph (RG) to model requirement relations of code snippets within the repository, as well as the relations between the target requirement and the requirements of these code snippets, and a Structural-Semantic Code Graph (SSCG) to capture the repository's intricate code dependencies. Guided by this, an LLM-powered agent performs multi-hop reasoning to systematically retrieve all context code snippets, including implicit and explicit code snippets, even if they are not explicitly expressed in requirements. We evaluated GraphCodeAgent on three advanced LLMs with the two widely-used repo-level code generation benchmarks DevEval and CoderEval. Extensive experiment results show that GraphCodeAgent significantly outperforms state-of-the-art baselines.
title GraphCodeAgent: Dual Graph-Guided LLM Agent for Retrieval-Augmented Repo-Level Code Generation
topic Software Engineering
url https://arxiv.org/abs/2504.10046