LocAgent: Graph-Guided LLM Agents for Code Localization

Zhaoling Chen, Xiangru Tang, Gangda Deng, Fang Wu, Jialong Wu +4 more
3/12/2025
cs.SEcs.AIcs.CL

Official code: gersteinlab/LocAgent (634 stars, Apache-2.0, last commit 2025-08-17).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

[ACL 2025] Graph-guided agentic framework for code localization https://arxiv.org/abs/2503.09089

63497Jinja, ShellMar 12, 20251 years agoApache-2.0

Similar Papers

Cite this paper

@article{chen2025locagent,
  title  = {LocAgent: Graph-Guided LLM Agents for Code Localization},
  author = {Zhaoling Chen and Xiangru Tang and Gangda Deng and Fang Wu and Jialong Wu and Zhiwei Jiang and Viktor Prasanna and Arman Cohan and Xingyao Wang},
  year   = {2025},
  eprint = {2503.09089},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.09089v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.09089.svg)](https://codeofpaper.com/paper/2503.09089)

Discussion