TL;DR
While large language models (LLMs) excel at localized, function-level coding tasks, real-world software engineering demands reasoning across entire codebases. This paper introduces RepoReasoner, a new benchmark designed to evaluate LLMs on repository-level code reasoning through cross-file execution simulation and architectural dependency tracking. The findings reveal a stark performance ceiling: even top-tier models struggle with multi-hop dependency tracing and frequently rely on memorization shortcuts rather than genuine logical deduction.
What Problem Does This Paper Address?
Most existing code intelligence benchmarks evaluate LLMs at the function level, where all relevant context is neatly contained within a single file or snippet. However, real-world software development requires developers to constantly navigate complex dependency structures and reason about logic scattered across multiple files.
With the advent of long-context LLMs, there is a temptation to assume that larger context windows automatically translate to better codebase comprehension. This paper challenges that assumption by isolating and testing two core repository-level capabilities: fine-grained, stateful cross-file execution reasoning, and macro-level architectural understanding.
Methods
The authors design two complementary evaluation tasks to test repository-level reasoning:
- Output Prediction: A cloze-style task where an assertion value in a test function is masked out. The model must trace variable states, class inheritances, and function calls across multiple files to predict the exact runtime output.
- Call Chain Prediction: A macro-level task where the model is given a target test function and a noisy "file pool" containing both relevant source files and irrelevant "distractor" files. The model must identify the exact sequence of files invoked during execution.
To construct the benchmark without human labeling bias or data contamination, the authors developed a multi-stage automated pipeline:
- Dynamic Tracing: Instead of relying on imprecise static analysis, they run repository test suites inside isolated Docker containers and use the
huntertracing library to capture the ground-truth runtime call chains. - I/O Rewriting: To prevent models from simply regurgitating code they memorized during pre-training, an LLM-powered iterative refinement loop modifies the input variables and expected assertion outputs of the tests while keeping the underlying execution logic completely identical.
Datasets
The authors introduce the RepoReasoner benchmark. It consists of 525 test functions across 169 test files sourced from 14 high-quality Python repositories spanning diverse scientific domains (e.g., machine learning, astrophysics, parallel computing). This pipeline curates a total of 858 evaluation samples for output prediction and 169 samples for call chain prediction.
Key Insights and Ideas
- The "Long-Context" Illusion: Simply expanding the context window does not guarantee better reasoning. For code-specialized models like Qwen-2.5-Coder-14B, expanding the context from 10k to 30k tokens actually degraded performance because the model became overwhelmed by the additional noise.
- High Precision, Low Recall: In Call Chain Prediction, larger models achieve high precision (often >80%) but very low recall (<40%). This indicates that while LLMs easily spot direct dependencies (like explicit
importstatements), they fail miserably at deep, multi-hop dependency tracing. - Brittleness and Memorization: When evaluated on the "I/O-Rewritten" datasets, every single tested model suffered a performance drop. This reveals that current LLMs heavily rely on familiar code patterns and "cognitive shortcuts" from their training data rather than robust semantic deduction.
- Reasoning Distillation Pitfalls: DeepSeek-R1-Distill-Qwen-14B performed worse than its non-distilled base counterpart on Output Prediction. The authors note that verbose chain-of-thought reasoning can sometimes exacerbate "identifier confusion," causing the model to lose track of the final return structure amidst complex execution traces.
Key Results
The authors evaluated seven state-of-the-art models, including DeepSeek-R1, GPT-4.1-Mini, and Gemini-2.5-Flash:
- Output Prediction Ceiling: Even when provided with the perfect "Oracle" context (only the exact files needed for execution), the best-performing model, DeepSeek-R1, achieved only 69.1% Pass@1.
- Call Chain Failure: Reconstructing multi-file dependency graphs proved incredibly difficult. Exact Match (EM) scores for all models under noisy conditions were under 20%. Even under Oracle conditions, the highest exact match achieved was just 21.3% (by Gemini-2.5-Flash).
- The Memorization Drop: On the rewritten dataset, GPT-4.1-Mini’s Pass@1 score dropped from 66.6% to 58.8%, while DeepSeek-R1 dropped from 69.1% to 65.0%.
Limitations and Future Work
- Language Scope: RepoReasoner is currently limited to Python repositories. Future work aims to extend the framework to other languages with different architectural paradigms.
- Retrieval Methods: The realistic evaluation setting relies solely on BM25 retrieval. Integrating advanced vector-based or graph-based retrieval mechanisms remains an open area for exploration.
- Rewriting Depth: The current pipeline only rewrites inputs and outputs. More sophisticated code refactoring—such as restructuring functions or reorganizing call chains—is required to completely eliminate the effects of model memorization.
Summary updated