TL;DR
While large language model (LLM) coding agents excel at resolving software bugs, existing benchmarks only evaluate their final output, leaving the internal process of code context retrieval a black box. This paper introduces ContextBench, a process-oriented benchmark with 1,136 tasks across eight languages equipped with human-verified "gold contexts" to evaluate how agents find and use code. The study reveals a "Bitter Lesson" for coding agents: complex agent scaffolding yields minimal retrieval gains over simple baselines, and a major bottleneck lies in agents discarding relevant context before generating a fix.
What Problem Does This Paper Address?
When a coding agent tackles a bug in a massive repository, its success hinges on its ability to navigate the codebase and retrieve the exact lines of code, functions, or classes relevant to the issue. Currently, we evaluate these agents using end-to-end metrics like Pass@k (e.g., on SWE-bench), which only measure whether the final patch passes a test suite.
This outcome-only evaluation creates a significant blind spot. An agent might pass a test through lucky trial-and-error or by overfitting to specific test cases without actually understanding the underlying codebase. Conversely, an agent might find the exact source of a bug but fail to write the correct syntax to fix it. To build reliable software engineering AI, we need to unbox this process and evaluate the intermediate steps: specifically, how effectively agents retrieve and utilize critical code context.
Methods
The authors developed a semi-automated pipeline to construct ContextBench and an automated framework to evaluate agent trajectories.
The benchmark creation process follows three main steps:
- Task Deduplication: Pooling tasks from existing benchmarks and removing duplicates using rule-based metadata matching and embedding-based semantic similarity.
- Task Selection: Filtering for challenging tasks based on agent solvability, edit scope (number of files modified), and edit dispersion (how scattered the edits are across the repository tree).
- Expert Annotation: Human experts iteratively trace code dependencies (such as variable, function, and class invocations) from ground-truth patches to construct a compact, sufficient "gold context." This context is verified by ensuring an LLM can successfully solve the issue using only the annotated code.
To evaluate agents, the framework instruments their execution, recording every code region they inspect. Using tree-sitter, the framework maps both the agent's trajectory and the human gold contexts onto a shared coordinate system to calculate precision, recall, and F1 scores across three granularities: file, block (AST definitions), and line levels.
Datasets
The paper introduces ContextBench, which comprises:
- 1,136 issue-resolution tasks sourced from 66 repositories.
- 8 programming languages: Python, Java, JavaScript, TypeScript, Go, Rust, C, and C++.
- 522,115 lines of human-verified gold contexts covering 23,116 classes and functions across 4,548 files.
- A Lite subset of 500 tasks balanced by difficulty to enable faster, cost-effective evaluation.
Key Insights and Ideas
- The "Bitter Lesson" of Coding Agents: Highly sophisticated, engineered agent scaffolds (e.g., graph-based or embedding-based retrieval systems) do not consistently outperform a simple baseline (
mini-SWE-agent) that relies on basic iterative shell commands. Much of the current orchestration overhead may be over-engineered. - Recall Over Precision: Across all tested LLMs, models aggressively favor recall over precision. They retrieve sweeping amounts of code to ensure they don't miss the answer, introducing substantial noise that can degrade downstream reasoning.
- The "Evidence Drop" Bottleneck: A significant gap exists between explored context and utilized context. Agents frequently look at the correct gold-relevant code during their trajectory but fail to retain or declare it in their final context before patch generation. This highlights information consolidation as a major failure mode.
- The Value of Balance: Models that balance retrieval frequency with context granularity (like Claude 4.5 Sonnet) achieve the highest line-level F1 scores and downstream task success, proving that more context is not always better.
Key Results
The authors evaluated four frontier LLMs (GPT-5, Claude 4.5 Sonnet, Gemini 2.5 Pro, Devstral 2) and five coding agent frameworks.
- Agent Performance: The simple baseline,
mini-SWE-agent, achieved the highest file-level precision (0.709) and block-level F1 (0.375). More complex agents like Prometheus or OpenHands achieved higher recall in some areas but suffered heavily in precision. - LLM Performance: State-of-the-art LLMs still struggle significantly with precise context retrieval. Block-level F1 scores remained below 0.45, and line-level F1 scores fell below 0.35 across the board.
- Downstream Correlation: There is a clear positive correlation between context recall and final task success (Pass@1). Claude 4.5 Sonnet achieved the best line-level F1 (0.344) and the highest Pass@1 rate (0.530).
- Robustness: A case study on solution multiplicity showed that gold contexts are highly consistent (0.9518 average Jaccard similarity) even when derived from different valid patches for the same issue.
Limitations and Future Work
- Data Contamination and Protocol Misalignment: The authors observed that certain models (specifically Devstral 2) exhibited anomalous behavior, such as generating a massive multi-step debugging plan in a single turn and hallucinating environment responses. This strongly hints at benchmark data contamination in public models. The authors emphasize the need for strict data hygiene and explicit contamination checks in future evaluations.
- Bridging Retrieval and Repair: While ContextBench successfully isolates the retrieval process, future work must focus on helping agents better consolidate and retain the information they find to prevent the "evidence drop" phenomenon during the final code repair phase.
Summary updated