Manuscript Offprint

arXiv:2610.33958

How Do Small Coding Agents Use Code Graphs and Embeddings?

Saurav Bellam

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Coding agents are given embedding search and code-graph tools on the premise that a repository’s structure is something the model lacks and the tool supplies. We test that premise on SWE-bench Verified with small open-weight models. First, we label all 500 tasks with a deterministic hop depth: the shortest code-graph path from code the issue mentions to code the gold patch changes (186/128/78/76 tasks at hop 0/1/2/3+). With repository, tool-set and patch-size controls, each extra hop multiplies the odds of correct function-level localization by 0.47–0.55 for Qwen3–4B, Qwen3–8B, Gemma 4 E4B and Qwen3–32B, and by 0.50–0.67 at each of six Qwen3 sizes from 0.6B to 32B. Second, we ablate a localization agent’s tool set (grep only; +embedding search; +graph tools; all) on a depth-balanced 160-task split and on all 500 tasks for ten models (79k episodes). Structured tools double grep-only accuracy for Qwen3–8B and Gemma 4 E4B; their gain peaks at 17–21 points at 1.7–4B and falls to 4–5 points at 32B (odds ratio 0.77–0.82 per doubling of parameters). From 8B up, about half of that gain is the form of the submission rather than finding the target; the fall from 14B to 32B is a fall in tool uptake at equal grep-only accuracy; and the same 4B size gains or does not gain from a tool depending on the checkpoint. Traces show the graph tools’ gain is name lookup at hop 0 and one expansion at hop 1: agents chain expansions in 12–14% of episodes and never flatten the depth gradient. A fixed repair model resolves 6–13 of 160 tasks from these localizations (oracle 26). Third, linear probes find direct call edges decodable under a within-anchor, degree-stratified protocol (AUC 0.74), but below a lexical baseline (0.99), with two-hop edges at 0.57. Small agents carry a one-hop, largely lexical picture of their repository, in weights and in use. We release the labels, scripts, logs and traces.

1 INTRODUCTION

Resolving a GitHub issue in a large repository starts with finding the code that has to change. Agentic systems for this localization step increasingly ship with structured tools: dense retrievers over function bodies, and query interfaces over a static code graph whose nodes are files, classes and functions and whose edges record containment, imports, calls and inheritance (Chen et al., 2025a; Yu et al., 2025; Jiang et al., 2025; Yang et al., 2025). The working assumption behind these tools is simple. An issue names some code; the fix lives some distance away along the dependency structure; a plain text search cannot bridge that distance, so the agent needs either a semantic index (to jump directly to code that means the right thing) or a graph (to walk to it). LocAgent (Chen et al., 2025a) made the assumption measurable by scoring SWE-bench tasks by the hop distance between the functions an issue mentions and the functions the patch edits, and reported that graph-guided agents degrade least as that distance grows. CodeAnchor (Lin et al., 2026) observed that SWE-bench Lite and Verified contain mostly one- and two-hop faults, and argued that evaluating structure-aware agents properly “requires a benchmark that sorts tasks by structural depth”.

This paper takes that argument seriously and asks three questions that the existing literature leaves open, using small open-weight models where the behaviour is cheap to measure many times over and where tool support plausibly matters most.

Part 1. Is structural depth a usable difficulty axis? We compute, for every SWE-bench Verified task, a deterministic hop depth on a LocAgent-style graph built at the task's base commit (Section 3). Unlike LocAgent's measurement, which extracted mentions with GPT-4o, ours uses only regular expressions and the Python ast module, so it can be re-run, audited and varied. We ask how the 500 tasks are distributed over depth, whether depth predicts whether an agent localizes the fix after controlling for repository, tool set, number of gold functions and patch size (DEPTHGEE), how sensitive the label is to the two measurement choices that matter—how calls are resolved and how mentions are extracted (LABELVAR)—and we release the labelled split.

Part 2. What do grep, embedding search and graph tools each contribute? On a 160-task subset balanced over depth we run a localization-only agent whose arms differ only in their tool set: G (grep, read_file, list_dir), E (G + embedding search over function and class texts), T (G + a name lookup and a one- or two-hop neighbourhood query over the graph) and ET (all tools) (Section 4). We measure accuracy by depth, run-to-run variance under sampling, which tool first exposes the gold code and whether exposure converts into a correct submission, sensitivity to retrieval quality, the effect of forcing the structured tool to be used, the effect of a larger step and context budget, and—because localization is only useful if it leads to a fix—how many issues one fixed repair model resolves when given each arm's localizations (Section 5). We then rerun the four arms on all 500 tasks across a model-size curve: six Qwen3 sizes from 0.6B to 32B with five decodings each, an FP8 precision control, and three Gemma 4 sizes (Section 5.4).

Part 3. Does the model represent the repository’s graph internally? The “Thousand-Graph Hypothesis” (Ding, 2026) proposes that an entity-only index suffices because self-attention materialises whatever relation a task needs; a recent probe shows that the runtime tool-call dependency structure of an agent is linearly decodable from Qwen3-32B residual streams (Sun & Kazakov, 2026). Neither probes the repository’s own call and inheritance graph. We do, with linear probes on definition-level activations, first in static file contexts (GLOBALPROBE, ANCHORPROBE) and then inside real agent conversations (CONVPROBE). The design is driven by a negative result we obtained early on: a global pair probe reaches AUC 0.75–0.80 for call edges, but so does a probe that sees only one of the two definitions, and so does the in-file in-degree of the callee. Linked and unlinked pairs differ in properties of a single node. We therefore introduce a within-anchor ranking protocol with an in-degree-binned stratification that a node-level shortcut cannot pass, with bootstrap intervals over anchors and a lexical name-match baseline (Section 6).

Findings. The answers are consistent across two model families and six sizes, and point in one direction.

• Hop depth is a strong, controlled predictor of failure. Each extra hop multiplies the odds of correct function-level localization by 0.47 (Qwen3-4B, three runs), 0.47 (Qwen3-8B), 0.54 (Gemma 4 E4B, three runs) and 0.55 (Qwen3-32B, all 500 tasks), with all p≤10−3p \leq 10^{-3}; across the scale curve the per-hop odds ratio is 0.50–0.67 at every size and barely changes with size. The label barely moves under alternative call resolution ( κ=0.96–0.98\kappa = 0.96–0.98). It is, however, sensitive to mention extraction: a strict extractor that counts only back-ticked code and traceback frames leaves 311 of 500 tasks without a mention.

• For Qwen3-8B and Gemma 4 E4B, grep alone is a weak baseline (12.8% and 9.6% function Acc@10) that any structured tool roughly doubles. For Qwen3-4B the embedding tool adds nothing (-1.1 points) and the graph tools add +8.1 points ([3.0, 13.5]). In every model, the graph-tool advantage is largest at hop 0, where the issue names the target and find_entity resolves the name directly, and at hop 1, where one graph_neighbors expansion reaches it; at hop 2+ the gain shrinks or vanishes, and in a GEE interaction model the depth slope of T is never significantly flatter than that of G (it is steeper in the Qwen models) while E has the flattest slope. Small graph-tool agents do not walk the graph; they look names up and expand once. Over the scale curve, the structured tools' gain over grep rises from 7–9 points at 0.6B to 17–21 at 1.7–4B and falls to 4–5 at 32B (odds ratio 0.77–0.82 per doubling of parameters); from 8B up about half of that gain is the form of the submission (exact ids) rather than discovery; the fall from 14B to 32B happens at equal grep-only accuracy and is a fall in tool uptake (find_entity called in 96% of episodes at 14B, 45% at 32B), not an FP8 artifact; and the same 4B size gains +17.6 points from embedding search under one checkpoint and nothing under another.

• Grep-only Qwen3-8B collapses into search loops (10 grep calls per episode, 40% of episodes hit the step cap, 41% never submit); a 50-step, 40k-token budget does not rescue it. Graph tools also change the form of what the agent submits: 85% of its top-5 function strings are exact entity ids, against 47% with grep only, which matters downstream.

• Downstream, the localizations of G/E/T/ET lead a fixed Qwen3-8B repair prompt to 6/13/12/13 resolved tasks of 160 (oracle locations: 26). Resolution is almost entirely conditional on correct localization (24–27% versus 1–2%).

• Inside the model, direct call edges are linearly decodable within anchor and in-degree bin (AUC 0.74 and 0.68 on the two held-out folds for Qwen3-4B; 0.73 and 0.66 for Qwen3-8B) and remain so inside agent conversations (0.61–0.66) including for edges no tool printed (0.59–0.60); but a one-line lexical baseline reaches 0.99, two-hop edges with the lexical cue removed reach only 0.57, and inheritance is not decodable beyond one-sided information. What is in the weights is a shallow, mostly lexical picture of direct dependencies.

Contributions. (i) A deterministic, released hop-depth labelling of SWE-bench Verified with a validated difficulty analysis and a robustness study of the label itself (Section 3). (ii) A controlled, depth-stratified tool ablation with trace-level mechanism analysis, variance, forced-use, budget, retrieval-quality and downstream-repair experiments, and a full-benchmark scale curve over ten models (six Qwen3 sizes from 0.6B to 32B with five decodings each, an FP8 control and three Gemma 4 sizes; 79k episodes) with a canonical rescoring that separates discovery from the form of the submission (Section 5). (iii) A within-anchor, degree-stratified probing protocol for relational structure, with the negative control that motivates it, applied both to static code and to activations taken inside agent conversations (Section 6). (iv) A synthesis: with small models, the benefit of “structure” tools is exact-name resolution plus one hop, which is also the extent of the structure the models appear to carry internally, and which shrinks with scale as the models stop calling the tools; deeper tasks are failed by every arm at every size (Section 7).

All numbers in this paper are computed from the episode logs, traces, probe scores and harness reports described in the reproducibility statement; the depth labels, source code, raw result files and analysis scripts are public (see the reproducibility statement).

References (60)