< Explain other AI papers

LocAgent: Graph-Guided LLM Agents for Code Localization

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

2025-03-12

LocAgent: Graph-Guided LLM Agents for Code Localization

Summary

This paper talks about LocAgent, a tool that helps AI find where to make code changes by turning codebases into maps of connected parts, making it easier to spot the right spots to edit.

What's the problem?

Finding where to fix code in big projects is hard because code has lots of connected pieces, and current tools can’t follow these connections well when given regular English descriptions of problems.

What's the solution?

LocAgent turns code into a graph (like a family tree of code parts) showing how files, classes, and functions link together, then uses AI to follow these links step-by-step to find the exact code needing changes.

Why it matters?

This helps developers fix bugs faster and cheaper, saving time and money, especially for big projects where code connections are complex and hard to track manually.

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.