arXiv(opens in a new tab)cs.SESep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.08355

RepoNav: From Snippet Retrieval to File-Centered Repository Navigation for Code Agents

Hongzheng Chai, Jiakun Li, Hongyue Yu, Yuan Yuan

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

Abstract

Solving repository-level code tasks requires LLM-based agents to use code search tools to navigate large codebases and identify a small set of relevant files and functions. However, current retrieval tools typically return flat lists of isolated code snippets: such lists can surface relevant files, but provide insufficient structure for agents to distinguish the target function from semantically similar alternatives in the same file. We introduce RepoNav, a lightweight post-retrieval interface that reorganizes retrieved snippets into a file-centered navigation scaffold. By presenting compact structural cues and candidate targets, this scaffold guides on-demand file-structure browsing, helping agents compare sibling symbols before selecting a target function. Across diverse models on LocBench, RepoNav improves function-level localization and narrows the file-to-function gap. Controlled ablations demonstrate that these gains come from structured evidence organization rather than simply exposing additional file structure, and the approach also improves performance on a repository-level question-answering benchmark.¹

1 Introduction

Large language models (LLMs) have driven rapid progress in autonomous software engineering. In repository-scale tasks such as issue resolution and bug localization, agents must operate across two levels of granularity: identifying the relevant files and pinpointing the specific functions within them. Modern code agents equipped with retrieval or agentic search tools (Zhang et al., 2023; Wang et al., 2025b; Yang et al., 2024) can often surface relevant files, yet function-level localization still lags significantly behind. We analyze this behavior using a common mini-SWE-agent scaffold (Yang

*Corresponding author.

¹We release code at https://github.com/CCChz233/reponav to facilitate future research.

Figure

Figure 1: Failure taxonomy for function-level misses from interactive agent executions. Percentages are computed over misses within each LLM backbone and setting. A substantial fraction of misses occurs after the agent has reached the correct file, indicating within-file navigation failures. Percentages may not sum to 100 due to rounding.

et al., 2024), keeping the underlying agent loop fixed across exploration interfaces.

Why do agents that reach the correct file still miss the target function? Our analysis reveals pre-mature anchoring: agents often commit to a salient nearby symbol before inspecting sibling definitions or file-structure views. Flat snippet retrieval reinforces this behavior by presenting relevant chunks and distractors as isolated evidence, with limited cues about what else the file contains. As Figure 1 shows, Correct File, Wrong Function accounts for 44–58% of function-level misses across agents instantiated with different LLM backbones, confirming within-file navigation as a central bottleneck in function-level localization.

To mitigate this bottleneck under a fixed retrieval substrate, we introduce RepoNav, a lightweight post-retrieval interface for repository navigation.

Here, lightweight refers to low incremental infrastructure and deployment overhead: RepoNav reuses the existing dense retrieval substrate and requires no additional persistent structural index or repository-wide graph. RepoNav reorganizes the retrieved evidence into a file-centered navigation scaffold. The scaffold exposes compact structural cues, candidate targets, and continuation hints, and supports on-demand file-structure browsing through list_symbols. This design separates file discovery from within-file verification: retrieval proposes candidate files, while RepoNav helps the agent decide which internal symbols to inspect next. Throughout this paper, we use symbol to denote a named structural code unit, such as a function, method, or class. Rather than asking agents to read more code upfront, RepoNav makes candidate files structurally expandable and encourages verification of sibling symbols before commitment. Unlike heavyweight graph-based systems (Ouyang et al., 2025; Liu et al., 2025; Chen et al., 2025) that rely on repository-wide graph construction or static-analysis infrastructure, RepoNav is an agent-facing interface layer built on top of existing snippet retrieval outputs.

Across seven models on LocBench (Chen et al., 2025), RepoNav improves function-level localization and reduces the gap between file discovery and function discovery. A tool-matched Snippet+ListSym baseline shows that file-structure browsing is useful, while RepoNav further improves over this baseline by making such browsing more actionable through file-centered organization. Results on SWE-QA-Bench (Peng et al., 2026) show that RepoNav also improves repository-level question answering beyond explicit localization. Our contributions are:

  1. An empirical diagnosis of the file-to-function gap. We show that a large fraction of function-level failures occur after the agent has already reached the correct file, identifying within-file navigation as a major bottleneck in repository-scale code localization.

  2. A structurally expandable, file-centered navigation interface. RepoNav reorganizes flat snippet-style outputs into file-centered scaffolds while keeping the underlying dense index and raw retrieval scores fixed. It integrates list_symbols as an on-demand file-structure browsing tool, enabling agents to inspect lightweight file skeletons and compare sibling symbols without reading full file bodies.

  3. Behavioral and tool-matched evidence for scaffolded navigation. A Snippet+ListSym baseline controls for access to file-structure browsing, and controlled ablations show that RepoNav provides additional gains by making structural evidence more actionable and efficient for agent exploration.

References (26)

  • Yingwei Ma, Qingping Yang, Rongyu Cao, Binhua Li, Fei Huang, and Yongbin Li. 2024. Alibaba LingmaAgent: Improving automated issue resolution via comprehensive repository exploration. Preprint, arXiv:2406.01422. (opens arXiv in a new tab)
  • gpt-oss-120b & gpt-oss-20b Model Card
  • Qwen2.5 Technical Report
  • Performance is stable across the full range: Acc@1 and MRR peak near $\alpha=0.5$, while Hit@10 and Recall@10 plateau for $\alpha \geq 0.7$
  • Ranking-oriented metrics (Acc@1, MRR) peak near $\alpha=0.5$, while recall metrics reach a broad plateau for $\alpha \geq 0.7$
  • During the agent loop, the agent issues free-form natural language search queries; the retrieval backend returns the top-ranked chunks by cosine similarity
  • ><tr><td rowspan=
  • These numbers provide a retrieval-only reference point for the fixed dense index before downstream agent interaction
  • This pilot provides preliminary evidence that RepoNav is compatible with a second embedding model, while CodeRankEmbed remains the primary retriever evaluated in the full experiments
  • The main text (Table 1) reports File Acc@5, Module Acc@5, Function Acc@5, and Function Rec@10; this table additionally includes lower- and higher-rank Accuracy@k and Recall@k variants where applicable, enabling fine-grained comparison across the reported k values
  • We conduct a paired instance-level analysis over all 560 LocBench instances using GPT-OSS-120B to quantify uncertainty in the primary function-level results
  • whether the gold file becomes available to the agent either through the retrieved candidate set or through subsequent shell exploration (Coverage), whether the agent inspects it given coverage (Inspection), and whether inspection leads to correct localization (Resolution)
  • All variants use identical prompts, tools, interaction budgets, metrics, and evaluation data, with one scaffold block removed at a time
  • We stratify instances according to three properties of the gold file: number of functions, file length, and number of sibling symbols
  • This pattern supports the interpretation that RepoNav primarily helps agents discriminate among plausible targets after reaching a relevant file, rather than merely improving initial file discovery
  • Each answer is independently scored on a 20-point scale across five dimensions: Correctness, Completeness, Relevance, Clarity, and Reasoning
  • Relevance, Clarity, and Reasoning show smaller but consistently positive improvements, indicating that better evidence navigation has a downstream effect on overall answer coherence
  • The analysis complements the aggregate results in Table 3 by showing that RepoNav’s gains are not confined to a single question category
  • This is consistent with the localization findings: Why questions typically require synthesizing evidence across multiple files and tracing causal chains through the codebase—precisely the scenario where structured navigation helps agents avoid premature anchoring on a single entry point
  • Figure 2 illustrates the core same-file disambiguation mechanism; below we describe a cross-file pivoting case, summarize residual file-to-function failures, and present a representative remaining failure boundary
  • Snippet-style search keeps the agent near the output-side sink, since the highest-scoring chunks come from Markdown-related code that shares surface keywords with the issue
  • The [GLIMPSE] block lists these helpers, but the agent does not inspect them further, treating the wrapper as a sufficient answer
  • For each candidate file, [ANCHORS] includes at most two symbols
  • If the top-ranked file has no anchor match, this budget is increased to five to expose a broader file sketch
  • By default, RepoNav parses the top five candidate files and auto-expands full three-block scaffolds for the top three
  • The anchor block provides grounded entry points with call-context annotations (invokes -> and invoked-by