TL;DR
While LLM-based code agents achieve impressive scores on repository-level benchmarks, this paper reveals they often rely on localized shortcuts rather than true codebase reasoning. By introducing RepoMirage, an evaluation suite that applies semantics-preserving structural perturbations to codebases, the authors expose a severe performance drop across leading models. To fix this, they propose RepoAnchor, a structure-first workflow that separates codebase exploration from problem-solving, yielding substantial performance gains.
What Problem Does This Paper Address?
AI code agents are increasingly deployed to handle complex, repository-level software engineering tasks like issue resolution. Current benchmarks (e.g., SWE-Bench) measure success end-to-end, assuming that a passing patch implies the agent successfully reasoned across the entire codebase.
However, the authors discover a highly localized pattern: for successfully resolved cases in SWE-Bench Verified, advanced models like GPT-5 and DeepSeek-V3.2 frequently inspect only 1 to 3 files.
This raises a critical question: Are these agents genuinely performing repository context reasoning (understanding multi-file dependencies and cross-file relationships), or are they just exploiting superficial cues like matching an issue description directly to a file name? This paper aims to isolate and rigorously evaluate true cross-file reasoning capabilities.
Methods
The authors introduce RepoMirage, a two-stage evaluation framework that uses codebase perturbations as a diagnostic tool. Crucially, these perturbations alter how the repository structure is exposed while preserving the original program semantics and test validation behavior.
1. RepoMirage-Perturb
This stage applies three distinct types of repository-level perturbations to break localized shortcuts:
- Dependency-Path Indirection: Direct imports are rerouted through a constructed four-layer proxy chain, forcing the agent to trace multi-hop dependencies across files to understand a component's role.
- Runtime-Target Masking: Target files are renamed and hidden behind an
__init__.pywrapper module, accompanied by superficially similar "decoy" files to test if the agent can distinguish actual runtime targets from text-matching illusions. - Local-Value Externalization: Local constant definitions are extracted out of the target file into external JSON resources, requiring the agent to map local logic to cross-file references.
2. RepoMirage-Extend
To make context reasoning explicitly measurable, this stage transforms the structural bottlenecks into standalone tasks: Proxy Chain Completion, Runtime Target Identification, and Missing-Constant Recovery, alongside Multi-File Issue Resolution.
3. RepoAnchor Workflow
To mitigate agent failures, the authors design RepoAnchor, a prototype workflow that splits the agent's execution into two distinct stages:
- Exploration & Scaffolding: The agent explores the codebase without editing code, outputting its structural findings into an intermediate
INSTRUCTIONS.mdfile. - Downstream Problem Solving: A second agent uses this structured summary as an explicit architectural anchor to guide its code modifications and testing.
Datasets
The evaluation suite is built on top of SWE-Bench Verified, a human-validated subset of real-world GitHub issues. From this, the authors generate:
- RepoMirage-Perturb: The original SWE-Bench Verified instances subjected to the three semantic-preserving transformations.
- RepoMirage-Extend: A balanced dataset where instances are converted into explicit structural reasoning tasks based on their most salient codebase signals.
Key Insights and Ideas
- Exploration Drift: When local shortcuts are removed, agents don't stop exploring—they actually look at more files. However, they suffer from "exploration drift," meaning they get trapped in an infinite loop of searching and reading without ever translating that information into concrete editing decisions.
- The Illusion of Competence: High scores on standard benchmarks are brittle. When direct local cues are obscured, model performance plummets, proving that current code agents struggle significantly with deep structural reasoning.
- Structure-First Scaffolding is Essential: Code agents fail not because they can't access the right files, but because they fail to organize fragmented observations into a coherent mental model. Providing explicit structural hints or forcing a two-stage exploration workflow dramatically restores their problem-solving capabilities.
Key Results
- Performance Drop under Perturbation: Across eight frontier LLMs, the average issue-resolution success rate dropped from 66.80% to 49.78% under RepoMirage-Perturb, while the average number of accessed files nearly tripled (from 4.77 to 13.24).
- Failure on Explicit Structural Tasks: On RepoMirage-Extend, where structural reasoning is the explicit objective, average performance plummeted to just 25.3%. Proxy Chain Recovery proved to be the most difficult task family, averaging a mere 17.19% success rate.
- RepoAnchor Gains: Implementing the RepoAnchor workflow or providing basic structural hints led to massive performance recoveries. For instance, providing structural hints boosted GPT-5's average score on RepoMirage-Extend from 27.60% to 62.60%, and DeepSeek-V3.2's score from 39.80% to 76.80%.
Limitations and Future Work
- Language Constraint: Due to the engineering complexity of syntax-tree transformations and runtime validations, RepoMirage is currently limited to Python repositories. Extending this framework to compiled languages with strict build systems (like Java or C++) remains future work.
- Task Diversity: The benchmark still focuses on a classical patch-generation format. The authors note that future evaluations should explore how repository context reasoning impacts other software engineering dimensions, such as code review, refactoring, and automated test generation.
Summary updated