IN THIS BREAKDOWN · 10 SECTIONS
You can read 19% of this breakdown.
The paper in one minute
Coding agents are judged by whether their patch passes the tests. That hides how they got there. An agent may stumble on a fix after reading the wrong files, or read exactly the right function and still write a broken patch. Han Li, He Ye, Zhaoyang Chu and colleagues at Nanjing University and University College London built ContextBench to score the middle of the process: what code the agent retrieved.
They pooled 4,497 tasks from SWE-bench Verified, Multi-SWE-bench, SWE-PolyBench and SWE-bench Pro. After deduplication and a difficulty filter (tasks few agents solve, with patches touching many, scattered files), 1,136 tasks from 66 repositories in eight languages remained. For each one, expert annotators traced the code the reference fix depends on (calls, inheritance, data flow) into a compact gold context. A gold context counts as sufficient if GPT-5, given only that code, produces a test-passing patch in at least one of five tries; failures get up to two more annotation rounds.
At evaluation time, every file and line range the agent reads is logged, and before submitting, the agent must declare the code it used. Both are mapped with tree-sitter to files, definition-level blocks (functions, classes) and lines, and compared with gold: recall, precision and F1, plus how early gold is found, how often the agent re-reads, and how much gold it saw but left out of its declaration.
The authors report three headline findings. Elaborate scaffolds did not retrieve better than a bash-only baseline, which they call coding agents' Bitter Lesson. Models favored recall over precision. And agents often saw the right code and then dropped it.
Research notes: the problem, approach and results
issue-resolution tasks from 66 repositories in 8 languages, with 522,115 lines of gold context
line-level context F1 for every model tested on the 500-task Lite subset
share of already-seen gold code missing from the declared context, Gemini 2.5 Pro and Devstral 2 against GPT-5
SWE-bench-style benchmarks score only the final patch. A passing patch can come from trial and error or test overfitting, and a failing one gives no hint whether the agent never found the right code or found it and then ignored it.
Take hard tasks from four issue-resolution benchmarks, have experts trace the code each fix depends on into a compact gold context, check it is sufficient by asking GPT-5 to patch from it alone, then record every region an agent reads and compare with gold at file, block and line level.
Across five agents on GPT-5, the simple mini-SWE-agent had the best retrieval scores but was fourth of five on Pass@1. Across four models, line-level F1 stayed at or below 0.344, Claude Sonnet 4.5 led on Pass@1 (0.530), and Gemini 2.5 Pro and Devstral 2 dropped about 43% of gold code they had already seen.
Why it matters to an FDE
When a customer's coding agent fails on their monorepo, the first question is whether it found the right code. ContextBench gives that question a method.
Separate finding from fixing. Log every read, compare with the code a human says matters, and you know whether to work on search (indexes, tools, repository maps) or on reasoning and patch generation.
Watch the gap between seen and used. Two models in this paper lost over 40% of relevant code they had already read. That points to context management, not search.
Retrieval scores are not outcomes. The best-retrieving scaffold was fourth of five on solve rate. Use retrieval metrics to diagnose a given agent, and keep the end-to-end test suite as the measure of success.
Building gold contexts is expensive. About 40 minutes of expert time per issue. For a customer, 30 to 50 annotated issues from their own repository is a realistic diagnostic set.
Understand the mechanism. Try it on a real problem.
Unlock this breakdown and 99 more papers.
Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.
6 months · One payment · No auto-renewal
- ◇1 architecture diagram
- </>1 runnable code experiment
- ▦2 results tables
- ?5 interview questions with answers
- 03Key takeaways
Construction, metrics, the main tables and misreadings to avoid
Free account - 04How it works
Task selection, annotation and verification, context tracing, and the metric definitions
Premium - 05The numbers that matter
The agent comparison, the model comparison, retrieval patterns, dynamics and robustness
Premium - 06Try it yourself
Compute every ContextBench metric on a toy trajectory, then check the paper's tables
Premium - 07Where it breaks
Self-reported context, the gold-context assumptions, internal inconsistencies and coverage
Premium - 08Using it on a deployment
Building a retrieval diagnostic for a customer's coding agent
Premium - 09Interview angles
Five questions this paper prepares you for, with answer hints
Premium - 10Read next
Where to go from here on this site
Premium
