Elamur Research⌕
☰
home / papers / 2025 / LocAgent: Graph-Guided LLM Agents for Code Localization

LocAgent: Graph-Guided LLM Agents for Code Localization

Paper · 2025 · Zhaoling Chen, Robert Tang, Gangda Deng et al.

Summary

Code localization means finding the files, classes and functions that must be edited to resolve an issue. It is difficult because issue reports often describe symptoms rather than causes, and the relevant code may sit several dependency steps away. LocAgent addresses this by converting a Python repository into a directed heterogeneous graph. The graph's nodes are directories, files, classes and functions, and its edges are containment, imports, calls and inheritance. Building it takes only seconds. Sparse BM25 indexes over entity names and contents sit on top of the graph, and an LLM agent queries them through a small set of tools so it can reason across multiple hops. The authors also fine-tune Qwen-2.5-Coder-Instruct 7B and 32B with LoRA and release Loc-Bench, a new benchmark. With the fine-tuned 32B model, LocAgent performs about as well as Claude-3.5 at a fraction of the cost. Better localization also helps automated repair: more GitHub issues get solved. This makes structure-aware localization practical with open models.

Key points

  • Graph and tools: The graph has four node types and four relation types (contain, import, invoke, inherit). The agent uses three tools: SearchEntity, TraverseGraph and RetrieveEntity. Ablations show that multi-hop traversal and the sparse index both matter.
  • Accuracy and cost: File-level accuracy reaches up to 92.7%. Cost per example falls from about $0.66 to $0.09, roughly an 86% reduction compared with Claude-3.5.
  • Loc-Bench: It is built from Python repositories collected after known LLM training cutoffs to limit contamination. It spans four issue types: bug report, feature request, performance and security.
  • Loc-Bench results: LocAgent with Claude-3.5 scores 83.39% file Acc@5 and 60.71% function Acc@15. The fine-tuned Qwen2.5-7B scores 78.57% file Acc@5, competitive with SWE-agent running Claude-3.5. Results are weaker on non-bug categories.
  • Downstream repair: Using Agentless editing with Claude-3.5, Pass@10 rises from 33.58 (Agentless localization) to 36.13 with Qwen2.5-32B(ft) and 37.59 with Claude-3.5. The study is limited to Python.

Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.

 Fields, topics and concepts

Cite

Cite as Zhaoling Chen, Robert Tang, Gangda Deng, Fang Wu, Jialong Wu, Zhiwei Jiang, Viktor Prasanna, Arman Cohan and Xingyao Wang. 2025. LocAgent: Graph-Guided LLM Agents for Code Localization. Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2025.acl-long.426

@inproceedings{chen2025locagent,
  title = {{LocAgent: Graph-Guided LLM Agents for Code Localization}},
  author = {Zhaoling Chen, Robert Tang, Gangda Deng, Fang Wu, Jialong Wu, Zhiwei Jiang, Viktor Prasanna, Arman Cohan and Xingyao Wang},
  booktitle = {Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
  year = {2025},
  doi = {10.18653/v1/2025.acl-long.426},
  url = {https://doi.org/10.18653/v1/2025.acl-long.426}
}

References

44 references, 10 of them with a card of ours. ↗ leads to the work, «find» searches for one we have no id for yet.

  1. Aider. 2023. Building a better repository map with tree sitter. Accessed: April 15, 2025. find
  2. Anthropic. 2023. Claude: Conversational ai by anthropic. Accessed: January 21, 2025. artificialanalysis.ai. 2025. Artificial analysis. https://artificialanalysis.ai/models/. Accessed: 2025-04-28. ↗
  3. Marcel Böhme, Ezekiel O Soremekun, Sudipta Chattopadhyay, Emamurho Ugherughe, and Andreas Zeller. 2017. Where is the bug and how is it fixed? an experiment with practitioners. In Proceedings of the 2017 11th joint meeting on foundations of software engineering, pages 117–128. on High Performance Com… find
  4. John Ellson, Emden Gansner, Lefteris Koutsofios, Stephen C North, and Gordon Woodhull. 2002. Graphviz—open source graph drawing tools. In Graph Drawing: 9th International Symposium, GD 2001 Vienna, Austria, September 23–26, 2001 Revised Papers 9, pages 483–484. Springer. find
  5. Bahare Fatemi, Jonathan Halcrow, and Bryan Perozzi. 2023. Talk like a graph: Encoding graphs for large language models. arXiv preprint arXiv:2310.04560. find
  6. Jiafeng Guo, Yixing Fan, Qingyao Ai, and W Bruce Croft. 2016. A deep relevance matching model for ad-hoc retrieval. In Proceedings of the 25th ACM international on conference on information and knowledge management, pages 55–64. find
  7. Jiafeng Guo, Yixing Fan, Liang Pang, Liu Yang, Qingyao Ai, Hamed Zamani, Chen Wu, W Bruce Croft, and Xueqi Cheng. 2020. A deep look into neural ranking models for information retrieval. Information Processing & Management, 57(6):102067. find
  8. Michael Günther, Louis Milliken, Jonathan Geuter, Georgios Mastrapas, Bo Wang, and Han Xiao. 2023. Jina embeddings: A novel set of high-performance sentence embedding models. Preprint, arXiv:2307.11224. find
  9. Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2021. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685.
  10. Binyuan Hui, Jian Yang, Zeyu Cui, Jiaxi Yang, Dayiheng Liu, Lei Zhang, Tianyu Liu, Jiajun Zhang, Bowen Yu, Keming Lu, Kai Dang, Yang Fan, Yichang Zhang, An Yang, Rui Men, Fei Huang, Bo Zheng, Yibo Miao, Shanghaoran Quan, Yunlong Feng, Xingzhang Ren, Xuancheng Ren, Jingren Zhou, and Junyang Lin. 2024… — Qwen2.5-Coder Technical Report
  11. Zehui Chen, Weihua Du, Wenwei Zhang, Kuikun Liu, Jiangning Liu, Miao Zheng, Jingming Zhuo, Songyang Zhang, Dahua Lin, Kai Chen, et al. 2024. T-eval: Evaluating the tool utilization capability of large language models step by step. In Proceedings of the 62nd Annual Meeting of the Association for Comp… find
  12. Hyperbolic. 2025. Hyperbolic website. https://hyperbolic.xyz/. Accessed: 2025-04-15. ↗
  13. Cognition.ai. 2024. Introducing devin, the first ai software engineer. find
  14. Sungmin Kang, Gabin An, and Shin Yoo. 2023. A preliminary evaluation of llm-based fault localization. arXiv preprint arXiv:2308.05487. — [arXiv:2308.05487](https://arxiv.org/abs/2308.05487) find
  15. Gangda Deng, Ömer Faruk Akgül, Hongkuan Zhou, Hanqing Zeng, Yinglong Xia, Jianbo Li, and Viktor Prasanna. 2023. An efficient distributed graph engine for deep learning on graphs. In Proceedings of the SC ’23 Workshops of the International Conference Carlos E Jimenez, John Yang, Alexander Wettig, Shu…
  16. Sungmin Kang, Gabin An, and Shin Yoo. 2024. A quantitative and qualitative evaluation of llm-based explainable fault localization. Proceedings of the ACM on Software Engineering, 1(FSE):1424–1446. find
  17. Xiangyan Liu, Bo Lan, Zhiyuan Hu, Yang Liu, Zhicheng Zhang, Fei Wang, Michael Shieh, and Wenmeng Zhou. 2024. Codexgraph: Bridging large language models and code repositories via code graph databases. Preprint, arXiv:2408.03910. find
  18. Qingsong Lv, Ming Ding, Qiang Liu, Yuxiang Chen, Wenzheng Feng, Siming He, Chang Zhou, Jianguo Jiang, Yuxiao Dong, and Jie Tang. 2021. Are we really making much progress? revisiting, benchmarking and refining heterogeneous graph neural networks. In Proceedings of the 27th ACM SIGKDD conference on kn… find
  19. Yingwei Ma, Qingping Yang, Rongyu Cao, Binhua Li, Fei Huang, and Yongbin Li. 2024. How to understand whole software repository? arXiv e-prints, pages arXiv–2406. find
  20. Niels Mündler, Mark Müller, Jingxuan He, and Martin Vechev. 2024. Swt-bench: Testing and validating real-world bug-fixes with code agents. Advances in Neural Information Processing Systems, 37:81857– 81887. find
  21. OpenAI. 2023. Chatgpt: Language model by openai. Accessed: January 21, 2025. find
  22. Siru Ouyang, Wenhao Yu, Kaixin Ma, Zilin Xiao, Zhihan Zhang, Mengzhao Jia, Jiawei Han, Hongming Zhang, and Dong Yu. 2025. Repograph: Enhancing AI software engineering with repository-level code graph. In The Thirteenth International Conference on Learning Representations. find
  23. PerplexityAI. 2023. Perplexity ai: An ai-powered search engine. Accessed: January 21, 2025. find
  24. Yihao Qin, Shangwen Wang, Yiling Lou, Jinhao Dong, Kaixin Wang, Xiaoling Li, and Xiaoguang Mao. 2024. Agentfl: Scaling llm-based fault localization to project-level context. arXiv preprint arXiv:2403.16362. — [arXiv:2403.16362](https://arxiv.org/abs/2403.16362) find
  25. Stephen Robertson, Hugo Zaragoza, et al. 2009. The probabilistic relevance framework: Bm25 and beyond. Foundations and Trends® in Information Retrieval, 3(4):333–389. find
  26. Stephen E. Robertson, Steve Walker, Susan Jones, Micheline Hancock-Beaulieu, and Mike Gatford. 1994. Okapi at trec-3. In Text Retrieval Conference.
  27. Tarun Suresh, Revanth Gangi Reddy, Yifei Xu, Zach Nussbaum, Andriy Mulyar, Brandon Duderstadt, and Heng Ji. 2024. Cornstack: High-quality contrastive data for better code ranking. arXiv preprint arXiv:2412.01007. — [arXiv:2412.01007](https://arxiv.org/abs/2412.01007) find
  28. David A. Tomassi, Naji Dmeiri, Yichen Wang, Antara Bhowmick, Yen-Chuan Liu, Premkumar Devanbu, Bogdan Vasilescu, and Cindy Rubio-González. 2019. Bugswarm: Mining and continuously growing a dataset of reproducible failures and fixes. Preprint, arXiv:1903.06725. — [arXiv:1903.06725](https://arxiv.org/abs/1903.06725) find
  29. VoyageAI. 2024. Voyage-code-2: Elevate your code retrieval. Accessed: 2024-02-02. find
  30. Liang Wang, Nan Yang, Xiaolong Huang, Binxing Jiao, Linjun Yang, Daxin Jiang, Rangan Majumder, and Furu Wei. 2022. Text embeddings by weakly-supervised contrastive pre-training. arXiv preprint arXiv:2212.03533.
  31. Xingyao Wang, Yangyi Chen, Lifan Yuan, Yizhe Zhang, Yunzhu Li, Hao Peng, and Heng Ji. 2024a. Executable code actions elicit better llm agents. In Forty-first International Conference on Machine Learning.
  32. Xingyao Wang, Boxuan Li, Yufan Song, Frank F. Xu, Xiangru Tang, Mingchen Zhuge, Jiayi Pan, Yueqi Song, Bowen Li, Jaskirat Singh, Hoang H. Tran, Fuqiang Li, Ren Ma, Mingzhang Zheng, Bill Qian, Yanjun Shao, Niklas Muennighoff, Yizhe Zhang, Binyuan Hui, Junyang Lin, Robert Brennan, Hao Peng, Heng Ji, a… — OpenHands: An Open Platform for AI Software Developers as Generalist Agents
  33. Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, Sharan Narang, Aakanksha Chowdhery, and Denny Zhou. 2023a. Self-consistency improves chain of thought reasoning in language models. Preprint, arXiv:2203.11171.
  34. Yue Wang, Hung Le, Akhilesh Deepak Gotmare, Nghi D. Q. Bui, Junnan Li, and Steven C. H. Hoi. 2023b. Codet5+: Open code large language models for code understanding and generation. Preprint, arXiv:2305.07922. find
  35. Zora Zhiruo Wang, Akari Asai, Xinyan Velocity Yu, Frank F. Xu, Yiqing Xie, Graham Neubig, and Daniel Fried. 2024b. Coderag-bench: Can retrieval augment code generation? Preprint, arXiv:2406.14497. find
  36. Yonghao Wu, Zheng Li, Jie M Zhang, Mike Papadakis, Mark Harman, and Yong Liu. 2023. Large language models in fault localisation. arXiv preprint arXiv:2308.15276. — [arXiv:2308.15276](https://arxiv.org/abs/2308.15276) find
  37. Zhiyong Wu, Chengcheng Han, Zichen Ding, Zhenmin Weng, Zhoumianze Liu, Shunyu Yao, Tao Yu, and Lingpeng Kong. 2024. Os-copilot: Towards generalist computer agents with self-improvement. arXiv preprint arXiv:2402.07456. find
  38. Chunqiu Steven Xia, Yinlin Deng, Soren Dunn, and Lingming Zhang. 2024. Agentless: Demystifying llm-based software engineering agents. arXiv preprint arXiv:2407.01489. find
  39. Tianbao Xie, Danyang Zhang, Jixuan Chen, Xiaochuan Li, Siheng Zhao, Ruisheng Cao, Toh J Hua, Zhoujun Cheng, Dongchan Shin, Fangyu Lei, et al. 2024. Osworld: Benchmarking multimodal agents for open-ended tasks in real computer environments. Advances in Neural Information Processing Systems, 37:52040–…
  40. John Yang, Carlos E Jimenez, Alexander Wettig, Kilian Lieret, Shunyu Yao, Karthik Narasimhan, and Ofir Press. 2024. Swe-agent: Agent-computer interfaces enable automated software engineering. arXiv preprint arXiv:2405.15793.
  41. Zhongming Yu, Hejia Zhang, Yujie Zhao, Hanxian Huang, Matrix Yao, Ke Ding, and Jishen Zhao. 2025. Orcaloca: An llm agent framework for software issue localization. arXiv preprint arXiv:2502.00350. — [arXiv:2502.00350](https://arxiv.org/abs/2502.00350) find
  42. Dejiao Zhang, Wasi Uddin Ahmad, Ming Tan, Hantian Ding, Ramesh Nallapati, Dan Roth, Xiaofei Ma, and Bing Xiang. 2024a. CODE REPRESENTATION LEARNING AT SCALE. In The Twelfth International Conference on Learning Representations. find
  43. Yuntong Zhang, Haifeng Ruan, Zhiyu Fan, and Abhik Roychoudhury. 2024b. Autocoderover: Autonomous program improvement. In Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis, pages 1592–1604. find
  44. Albert Örwall. 2024. Moatless tools. find

Updated

↑ back to top

This page in Markdown → https://md.research.elamur.ai/free/en/papers/chen-2025-locagent-graph-guided-llm-agents/