SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2503.09089 · ACL · 2025

LocAgent: Graph-Guided LLM Agents for Code Localization

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

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 2 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2503.09089.json · badge: /api/ran/2503.09089.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
gersteinlab/LocAgent community
Papers with Code archive
4 ran · 0 no recorded run
FunctionStatusWhere it lives
RepoDependencySearcher Ran
ran on a synthesized input · constructed an object; no result was computed
gersteinlab/LocAgent/dependency_graph/traverse_graph.py
code served (permissive licence) · get_code("3ffc6363f552738d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, RepoDependencySearcher: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import networkx as nx

# Create a small directed multigraph to serve as the repository dependency graph
G = nx.MultiDiGraph()

# Add nodes with 'type' attribute
G.add_node('src/module_a.py:ClassA', type='class')
G.add_node('src/module_b.py:ClassB', type='class')
G.add_node('src/utils.py:helper_func', type='function')
G.add_node('tests/test_module_a.py:TestClassA', type='test')
G.add_node('src/main.py:main', type='function')

# Add edges with 'type' attribute
# Forward edges from module_a to module_b
G.add_edge('src/module_a.py:ClassA', 'src/module_b.py:ClassB', 
           key=0, type='contains')
# Forward edges from module_a to utils
G.add_edge('src/module_a.py:ClassA', 'src/utils.py:helper_func', 
           key=0, type='invokes')
# Forward edges from main to module_a
G.add_edge('src/main.py:main', 'src/module_a.py:ClassA', 
           key=0, type='imports')
# Backward edge from module_b to module_a (for testing backward direction)
G.add_edge('src/module_b.py:ClassB', 'src/module_a.py:ClassA', 
           key=0, type='inherits')

ARGS = {
    'graph': G
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RepoDependencySearcher — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a RepoDependencySearcher output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
RepoEntitySearcher Ran
ran on a synthesized input · constructed an object; no result was computed
gersteinlab/LocAgent/dependency_graph/traverse_graph.py
code served (permissive licence) · get_code("c6a7782e9a902680")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, RepoEntitySearcher: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import networkx as nx
from collections import defaultdict

# Create a simple directed multigraph to represent the repository structure
G = nx.MultiDiGraph()

# Add nodes with type attributes
G.add_node('src/module.py', type='file')
G.add_node('src/utils.py', type='file')
G.add_node('src/module.py:MyClass', type='class')
G.add_node('src/module.py:MyClass.method', type='function')
G.add_node('src/utils.py:helper_func', type='function')
G.add_node('src/', type='directory')
G.add_node('tests/test_module.py', type='file')
G.add_node('tests/test_module.py:TestClass', type='class')

# Add edges with type attributes
G.add_edge('src/', 'src/module.py', key=0, type='contains')
G.add_edge('src/', 'src/utils.py', key=0, type='contains')
G.add_edge('src/module.py', 'src/module.py:MyClass', key=0, type='contains')
G.add_edge('src/module.py:MyClass', 'src/module.py:MyClass.method', key=0, type='contains')
G.add_edge('src/module.py:MyClass.method', 'src/utils.py:helper_func', key=0, type='invokes')
G.add_edge('src/module.py', 'src/utils.py', key=0, type='imports')
G.add_edge('tests/test_module.py', 'tests/test_module.py:TestClass', key=0, type='contains')

# Store node code content as attributes
G.nodes['src/module.py']['code_content'] = 'class MyClass:\n    def method(self):\n        pass'
G.nodes['src/module.py']['start_line'] = 1
G.nodes['src/module.py']['end_line'] = 3
G.nodes['src/utils.py']['code_content'] = 'def helper_func():\n    return 42'
G.nodes['src/utils.py']['start_line'] = 1
G.nodes['src/utils.py']['end_line'] = 2
G.nodes['src/module.py:MyClass']['code_content'] = 'class MyClass:\n    pass'
G.nodes['src/module.py:MyClass']['start_line'] = 1
G.nodes['src/module.py:MyClass']['end_line'] = 2
G.nodes['src/module.py:MyClass.method']['code_content'] = 'def method(self):\n    pass'
G.nodes['src/module.py:MyClass.method']['start_line'] = 2
G.nodes['src/module.py:MyClass.method']['end_line'] = 3
G.nodes['src/utils.py:helper_func']['code_content'] = 'def helper_func():\n    return 42'
G.nodes['src/utils.py:helper_func']['start_line'] = 1
G.nodes['src/utils.py:helper_func']['end_line'] = 2

ARGS = {
    'graph': G
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RepoEntitySearcher — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a RepoEntitySearcher output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
is_test_file Ran
ran, violated the contract we drafted
gersteinlab/LocAgent/dependency_graph/traverse_graph.py
code served (permissive licence) · get_code("6ff966d192844369")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def is_test_file(nid):
    file_path = nid.split(':')[0]
    word_list = re.split(' |_|\\/', file_path.lower())
    return any([word.startswith('test') for word in word_list])

ARGS = {
    'nid': 'test_module.py:42'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
wrap_code_snippet Ran
ran; our contract draft was wrong, not the code
gersteinlab/LocAgent/dependency_graph/traverse_graph.py
code served (permissive licence) · get_code("4eaf41e329447227")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

# Analyze the function:
# - code_snippet: a string that will be split by '\n'
# - start_line: an integer representing the starting line number
# - end_line: an integer representing the ending line number
# The function splits code_snippet into lines, validates line numbers,
# and formats them with line numbers.

# Create test arguments
code_snippet = """def hello():
    print('world')
    return 42"""

start_line = 1
end_line = 3

ARGS = {
    "code_snippet": code_snippet,
    "start_line": start_line,
    "end_line": end_line,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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 snippets. The challenge lies in bridging natural language problem descriptions with the target code elements, often requiring reasoning across hierarchical structures and multiple dependencies. We introduce LOCAGENT, a framework that addresses code localization through a graphguided agent. By parsing codebases into directed heterogeneous graphs, LOCAGENT creates a lightweight representation that captures code structures and their dependencies, enabling LLM agents to effectively search and locate relevant entities through powerful multihop reasoning. Experimental results on realworld 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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2503.09089")
get_code_for_paper("2503.09089")
have("2503.09089")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2503.09089.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2503.09089.svg)](https://syntology.ai/paper/2503.09089)

Connect an agent — have() is free.