LocAgent: Graph-Guided LLM Agents for Code Localization

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Chen, Zhaoling, Tang, Xiangru, Deng, Gangda, Wu, Fang, Wu, Jialong, Jiang, Zhiwei, Prasanna, Viktor, Cohan, Arman, Wang, Xingyao
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866910921417293824
author Chen, Zhaoling
Tang, Xiangru
Deng, Gangda
Wu, Fang
Wu, Jialong
Jiang, Zhiwei
Prasanna, Viktor
Cohan, Arman
Wang, Xingyao
author_facet Chen, Zhaoling
Tang, Xiangru
Deng, Gangda
Wu, Fang
Wu, Jialong
Jiang, Zhiwei
Prasanna, Viktor
Cohan, Arman
Wang, Xingyao
contents Code localization--identifying precisely where in a codebase changes need to be made--is a fundamental yet challenging task in software maintenance. Existing approaches struggle to efficiently navigate complex codebases when identifying relevant code sections. The challenge lies in bridging natural language problem descriptions with the appropriate code elements, often requiring reasoning across hierarchical structures and multiple dependencies. We introduce LocAgent, a framework that addresses code localization through graph-based representation. By parsing codebases into directed heterogeneous graphs, LocAgent creates a lightweight representation that captures code structures (files, classes, functions) and their dependencies (imports, invocations, inheritance), enabling LLM agents to effectively search and locate relevant entities through powerful multi-hop reasoning. Experimental results on real-world benchmarks demonstrate that our approach significantly enhances accuracy in code localization. Notably, our method with the fine-tuned Qwen-2.5-Coder-Instruct-32B model achieves comparable results to SOTA proprietary models at greatly reduced cost (approximately 86% reduction), reaching up to 92.7% accuracy on file-level localization while improving downstream GitHub issue resolution success rates by 12% for multiple attempts (Pass@10). Our code is available at https://github.com/gersteinlab/LocAgent.
format Preprint
id arxiv_https___arxiv_org_abs_2503_09089
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle LocAgent: Graph-Guided LLM Agents for Code Localization
Chen, Zhaoling
Tang, Xiangru
Deng, Gangda
Wu, Fang
Wu, Jialong
Jiang, Zhiwei
Prasanna, Viktor
Cohan, Arman
Wang, Xingyao
Software Engineering
Artificial Intelligence
Computation and Language
Code localization--identifying precisely where in a codebase changes need to be made--is a fundamental yet challenging task in software maintenance. Existing approaches struggle to efficiently navigate complex codebases when identifying relevant code sections. The challenge lies in bridging natural language problem descriptions with the appropriate code elements, often requiring reasoning across hierarchical structures and multiple dependencies. We introduce LocAgent, a framework that addresses code localization through graph-based representation. By parsing codebases into directed heterogeneous graphs, LocAgent creates a lightweight representation that captures code structures (files, classes, functions) and their dependencies (imports, invocations, inheritance), enabling LLM agents to effectively search and locate relevant entities through powerful multi-hop reasoning. Experimental results on real-world benchmarks demonstrate that our approach significantly enhances accuracy in code localization. Notably, our method with the fine-tuned Qwen-2.5-Coder-Instruct-32B model achieves comparable results to SOTA proprietary models at greatly reduced cost (approximately 86% reduction), reaching up to 92.7% accuracy on file-level localization while improving downstream GitHub issue resolution success rates by 12% for multiple attempts (Pass@10). Our code is available at https://github.com/gersteinlab/LocAgent.
title LocAgent: Graph-Guided LLM Agents for Code Localization
topic Software Engineering
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2503.09089