Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

LocAgent: Graph-Guided LLM Agents for Code Localization

About

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.

Zhaoling Chen, Xiangru Tang, Gangda Deng, Fang Wu, Jialong Wu, Zhiwei Jiang, Viktor Prasanna, Arman Cohan, Xingyao Wang• 2025

Related benchmarks

TaskDatasetResultRank
File-level Code LocalizationSWE-bench Live Lite
Acc@179.7
25
File-level Code LocalizationSWE-bench Verified Lite
Accuracy@188.2
25
Function-level Code LocalizationSWE-bench Live Lite
Acc@148
25
Function-level Code LocalizationSWE-bench Verified Lite
Acc@150.9
25
Code LocalizationSWE-bench Verified (test)
File Precision61.57
24
Repository ReconstructionRepoCraft (test)
Steps2.14
20
File-level Code LocalizationSWE-Bench Lite
Acc@177.74
16
File-level LocalizationSWE-Bench-Lite latest (test)
NDCG@177.74
16
Function-level Code LocalizationSWE-Bench Lite
Acc@573.36
16
Function-level LocalizationSWE-Bench-Lite latest (test)
NDCG@564.34
16
Showing 10 of 15 rows

Other info

Code

Follow for update