AI Agents Enhance Code Localization with Graph-Based Approach

Top post
Graph-Based AI Agents Revolutionize Code Localization
Locating code, meaning the precise identification of places within a codebase where changes need to be made, presents a fundamental challenge in software maintenance. Traditional approaches often reach their limits, especially when navigating complex codebases. The difficulty lies in linking natural language problem descriptions with the corresponding code elements, which often requires a complex understanding of hierarchical structures and dependencies.
A promising approach to overcome this challenge is the use of graph-based representations in combination with AI agents. One example is the LocAgent framework. By analyzing codebases and transforming them into directed heterogeneous graphs, LocAgent creates an efficient representation. These graphs not only map code structures such as files, classes, and functions, but also their dependencies, such as imports, function calls, and inheritance. This allows AI agents, particularly Large Language Models (LLMs), to effectively search and locate relevant code elements using multi-hop reasoning, i.e., the ability to draw conclusions over multiple steps.
Increased Efficiency and Cost Reduction through LLMs
Experimental results with LocAgent on real-world datasets show a significant improvement in the accuracy of code localization. Particularly noteworthy is the performance of LocAgent in combination with fine-tuned LLMs like Qwen-2.5-Coder-Instruct-32B. This model achieves comparable results to state-of-the-art models, but at significantly lower costs – in some cases with a cost reduction of up to 86%. The accuracy of file localization reaches up to 92.7%. Moreover, the success rate in resolving GitHub issues could be increased by up to 12%.
How LocAgent Works
LocAgent leverages the power of graphs to model the complex relationships within a codebase. Nodes in the graph represent code elements, while edges represent the relationships between these elements. This structure allows LLMs to efficiently traverse the code and identify relevant sections. By combining graph-based representation and the inference capabilities of LLMs, LocAgent can significantly improve code localization and thus make software development more efficient.
Future Prospects
The application of graph-based AI agents like LocAgent for code localization opens promising possibilities for the future of software development. By combining efficient code representation and powerful AI, developers can save time and resources and improve the quality of their work. Further research in this area could lead to even more powerful tools that further optimize the development process and address the challenges of modern software development.
Bibliographie: Chen, Z., Tang, X., Deng, G., Wu, F., Wu, J., Jiang, Z., Prasanna, V., Cohan, A., & Wang, X. (2025). LocAgent: Graph-Guided LLM Agents for Code Localization. arXiv preprint arXiv:2503.09089. Gao, D. (2025). KAG: Graph Multimodal RAG LLM Agents. Substack. Nayak, P. (2025). Build an Arxiv Paper Content Retriever and Summarizer Agent using Completely Local OpenAI Swarm. Medium. Batool, F., Saleem, M., Khan, M. U. G., Din, I. U., & Chun, S. Y. (2025). AGENTiGraph: An Interactive Knowledge Graph Platform for LLM-based Chatbots Utilizing Private Data. ResearchGate. Jin, P. (n.d.). Awesome Language Model on Graphs. GitHub.