LocAgent: Graph-Guided LLM Agents for Code Localization
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.
67d2328a34eb54912d6fbb83
Zhaoling Chen
67d2328a34eb54912d6fbb84
Xiangru Tang
extracted_pending
2025-03-13T01:19:07.804Z
63357c608adfa81faf2ac180
/avatars/ae0314c644f882251baf59b9134fd36f.svg
Xiangru Tang
user
RTT1
67d2328a34eb54912d6fbb85
Gangda Deng
claimed_verified
2025-03-13T08:24:25.045Z
62c54062f7c810d3cd4043cc
/avatars/bc0be3082fe1a6eec7687f57cfe84d55.svg
Gangda Deng
user
Hydrapse
67d2328a34eb54912d6fbb86
Fang Wu
claimed_verified
2025-07-23T08:38:18.988Z
675e0d5cdd3e9eeed6954f5a
https://cdn-avatars.huggingface.co/v1/production/uploads/no-auth/7oMEoBmaFiCR9K2q9Z_7q.png
Fang Wu
user
fangwu97
67d2328a34eb54912d6fbb87
Jialong Wu
claimed_verified
2025-04-09T16:55:16.408Z
644a4fbc2166258fccc664bc
https://cdn-avatars.huggingface.co/v1/production/uploads/noauth/8k3b44MbhQiWuo6i8BnYl.jpeg
Jialong Wu
user
callanwu
67d2328a34eb54912d6fbb88
Zhiwei Jiang
67d2328a34eb54912d6fbb89
Viktor Prasanna
67d2328a34eb54912d6fbb8a
Arman Cohan
67d2328a34eb54912d6fbb8b
Xingyao Wang
LocAgent: Graph-Guided LLM Agents for Code Localization
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.