Programmers have a new tool to cheer about! LocAgent, a graph-indexed large language model (LLM) agent framework specifically designed for code localization, has been introduced by research teams from OpenHands, Yale University, the University of Southern California, and Stanford University. Excitingly, LocAgent’s code localization accuracy reached an impressive 92.7%, and this groundbreaking achievement will be unveiled at the 2025 ACL conference.
During their work, programmers often face challenges in pinpointing problematic code. For instance, when dealing with a bug report, they may find themselves lost in the question: "Where exactly should I make the change?" Traditional methods for code localization are either crude keyword matching or inefficiently handing over the entire codebase to an LLM, sometimes even blindly traversing directories. In reality, there are often multiple layers of complex call relationships between problem descriptions in natural language and the actual code locations. Therefore, accurately identifying the problematic code is crucial.
The innovative aspect of LocAgent lies in its ability to parse the entire codebase into a graph that includes relationships between files, classes, and functions. This graph structure not only significantly improves the efficiency of code retrieval but also allows the LLM to reason and search more effectively within complex codebases. The system employs a layered sparse indexing approach, enabling the LLM to locate code as easily as using a map, quickly narrowing down to the target.
LocAgent also provides a simple and user-friendly set of tools for LLM agents to query the code graph structure, including keyword search, information extraction, and graph traversal functionalities. These tools enable agents to reason step-by-step, deeply understand the issue, and pinpoint the exact code location that needs modification. According to recent experiments, LocAgent performs exceptionally well on datasets like SWE-Bench Lite, outperforming traditional methods with much higher accuracy.
With its outstanding performance and ease of use, LocAgent has solved a long-standing problem for programmers, greatly enhancing development efficiency.