Coding agents rarely read a repository in full. They see previews, such as a function signature, a docstring, a grep hit, a file name or a head of a CSV, and decide from these alone what to open. Information-retrieval research has a name for one way this goes wrong. The negative recall gap is the case where a document that is truly needed gets discarded because its preview looked uninformative. In web search this is well measured. In code it has barely been studied, even though every repair loop, in which the agent writes code, runs it, reads the error and tries again, depends on such preview-driven choices.
We propose to measure this gap inside code-repair loops and to shrink it with execution-conditioned previews. These are short descriptions of each candidate code unit or data file, rewritten at every repair step in light of the current failing test or traceback. A small model is trained so that the preview ranking the agent perceives agrees with the ranking by actual usefulness, where usefulness is measured by what happens to test outcomes when the unit is placed in context. All evaluation runs on benchmarks that are not yet saturated. We check separately that the new gap metric separates agents better than end-to-end pass rate does.
Core Claim
A large share of failures in retrieval-augmented coding agents are not ranking failures. They happen because a needed unit was retrieved and shown to the agent, but its preview did not signal that it was needed. The agent, reading a stack trace, cannot tell from def normalize(self, x) that this helper is where the bug lives. We claim two things. First, previews that are rewritten per step, conditioned on the failure signal, reduce this gap more than a better retriever or a larger context. Second, part of the code bloat that agents accumulate over iterations is re-implementation of helpers they were shown but did not recognize.
Where This Sits in Prior Work
Three papers motivate the gap. What Snippets Say About Pages models the probability that a page is relevant given that its snippet looks relevant. It finds this probability collapses in specialized domains, to 0.42 for news engines. Less is Less finds that human assessors judged snippets insufficient in 48% of 12,000 Bing query-document pairs. It also finds that humans and neural rankers react in opposite directions to longer snippets. That second finding warns us that "just show more text" behaves differently for machine readers. LiveNewsBench shows that search agents rely on search-result snippets instead of visiting pages.
All three study text search. None of them has an execution oracle. That oracle is exactly what code gives us, because relevance can be tested directly rather than judged by an assessor.
Our training objective comes from Bridging the Gap between Intrinsic and Perceived Relevance in Snippet Generation. That paper trains a snippet generator under the constraint that a more relevant document must get a more relevant-looking snippet. We reuse this pairwise consistency constraint. We replace its human relevance labels with counterfactual execution utility, and we condition the snippet on the agent's current error instead of a static query.
Two loop systems set the bar we must beat. COCOGEN turns compiler errors such as undefined symbols into structural code search. It fetches the exact missing definition. This works when the error names what is missing. It says nothing about runtime assertion failures, where the needed unit is not named anywhere in the trace. ARCS retrieves by chain-of-thought subgoals inside a budgeted synthesize-execute-repair loop and keeps the best-so-far candidate. It is evaluated on saturated single-function benchmarks. Neither system asks whether the retrieved item was presented in a way the model could act on.
Two lines of work constrain the design. Repoformer shows that in up to 80% of repository completion cases, retrieved context does not help or actively confuses the model. SWE-bench shows that dumping more BM25-retrieved code distracts models from the buggy lines. Together they rule out closing the gap by opening everything, so our method keeps the context budget fixed.
Research Program
The first component is a measurement protocol. For each task we log every candidate unit that was shown to the agent as a preview, and whether the agent then opened it. We label a unit as needed in one of two ways. The cheap label covers all tasks: the unit is touched or called by the gold patch, or it is the gold data file in CoDA-Bench. The expensive label is computed on a subsample of roughly 200 tasks: we force the unit's full body into context at a given step and record the change in test pass rate over several rollouts. The negative recall gap is
$$\mathrm{NRG} = \Pr(\text{not opened} \mid \text{needed},\ \text{preview shown}),$$
pooled over steps and tasks. This separates preview failure from retrieval failure, which is the case where a needed unit was never shown at all. The first empirical question is simple: how large is NRG compared with the retrieval-miss rate for current agents?
The second component is the preview model. It is a small code model, about 1–3B parameters, following Repoformer's precedent of using a small model to serve a larger one. It takes three inputs: a unit's full body, the current failing output, and the agent's last action. It emits a preview of at most about 60 tokens. It is trained in two stages. The first stage is supervised on previews written by a stronger model for units the counterfactual labels mark as useful. The second stage is pairwise fine-tuning, which pushes the agent's open-probability for a more useful unit above that for a less useful one. This is the Bridging-paper constraint, transplanted to code. The candidate set comes from the scaffold's existing retriever and is never changed. Only the text the agent reads is changed.
The third component is the erosion analysis. On SlopCodeBench, from checkpoint two onward the agent must navigate its own earlier code. We detect new functions that duplicate the behavior of existing ones, using a behavioral equivalence check on shared tests plus AST similarity. For each duplicate we ask whether the original was shown as a preview and left unopened. If a substantial fraction of duplication traces back to this event, then negative recall is a mechanism behind the paper's finding that verbosity grows in 75.5% of agent trajectories. Execution-conditioned previews should then slow that growth.
Baselines
The naive reference point is the unmodified scaffold. We use mini-SWE-agent for CoDA-Bench, as in that paper, and a matched SWE-agent-style scaffold for repository tasks. Its previews are whatever the tools print: ls, grep, head, and signature listings. This baseline tells us the raw size of the gap.
The strongest reported end-to-end number in our setting comes from CoDA-Bench. Mini-SWE-agent with GPT-5.5 reaches 61.1% execution accuracy on the full benchmark and 49.6% on CoDA-HARD. Oracle file identification adds roughly 25–28%, per CoDA-Bench. On fresh repository tasks, SWE-MERA reports DeepSeek-R1-0528 at 34.5% pass@1 on its 2024 subset. Our budget almost certainly will not allow the same backbones. We will therefore re-run the scaffold with our own open-weight backbone and report the published figures only as context, not as the comparison.
The strongest method baseline is a COCOGEN-plus-ARCS loop. It has compiler-guided structural retrieval on static-analysis errors, subgoal-based dense retrieval otherwise, and best-so-far tracking. It is run with the same backbone, iteration budget, per-task token budget and retriever candidate pool. COCOGEN reports an 80% relative pass-rate improvement over direct generation on CoderEval with GPT-3.5-Turbo, but no reported result was found on Lacuna for it on CoDA-Bench, SWE-MERA or SlopCodeBench. We reimplement it from its description.
We add a strong retrieval competitor: a cross-encoder reranker that reads each candidate's full body together with the current trace and reorders the list. It shows ordinary previews. This isolates "better ranking" from "better previews."
The key ablation is static learned previews. The same preview model and training are used, but without the failing output as input. This tests whether conditioning on the error is what matters, or whether any learned summary helps.
Every system gets an identical tuning budget: the same number of development-set configurations. Beating the COCOGEN-plus-ARCS loop means a statistically reliable gain in execution accuracy or pass rate across three seeds at equal tokens, together with a lower NRG. Beating the reranker means the same gain on tasks where the needed unit already sat in the top of the shown list.
Why not just…?
Why not just give the agent the full files, or the whole repository, in a long context? SWE-bench reports that more retrieved code distracts models from the buggy lines, and Repoformer finds retrieved context unhelpful or harmful in up to 80% of completions. We still test this directly. We run a condition that spends our preview-model token budget on appending full bodies of the top-ranked candidates. If it matches our method at equal tokens, the preview idea is unnecessary and we will say so.
Why not just use a better retriever or reranker? This is the most serious threat. A reranker that reads full bodies could put needed units first, making previews irrelevant. The reranker baseline and the NRG decomposition settle it. If most failures are retrieval misses rather than shown-but-unopened units, the proposal's premise is wrong. If NRG is large even under the reranker, the preview is the bottleneck.
Why not just prompt or force the agent to open more candidates? LiveNewsBench documents agents' reluctance to visit full pages, so a "read more" instruction is the obvious fix. We include a forced-open policy that opens the top-$k$ candidates, with $k$ chosen to match our token cost. Opening costs context. The Less is Less finding that extra body text adds noise for machine readers suggests forced opening will help less per token, but this is an empirical question our matched-cost comparison answers.
Why not just add Repoformer-style selective retrieval? Repoformer decides whether to retrieve in single-shot completion. It does not decide which shown item deserves attention during repair. It is complementary rather than competing, and we will stack it under both our method and the baselines.
Proposed Experiments
We run on CoDA-Bench and CoDA-HARD, where file discovery is the documented bottleneck and data previews are literal head outputs. We also run on the most recent monthly slice of SWE-MERA, chosen to avoid the contamination that SWE-MERA reports affected 32.67% of successful SWE-bench solutions. SlopCodeBench's 196 checkpoints are used for the erosion analysis. We avoid HumanEval and LiveCodeBench easy subsets because they are saturated. They also lack the multi-unit retrieval our question requires.
Because benchmark saturation is a live concern even here, we apply the Signal and Noise analysis. We compute dispersion across roughly eight agent configurations, divided by variance across seeds. We do this both for end-to-end accuracy and for NRG, and we report whether NRG is the higher-signal instrument for comparing retrieval designs. That paper found SNR predicts decision reliability with $R^2 = 0.626$ on static tasks. Whether this holds for agentic metrics is itself an open question we will answer.
Three results would be decisive. The idea fails if NRG under the reranker baseline is small, say below one tenth of needed units. It succeeds if execution-conditioned previews beat both the COCOGEN-plus-ARCS loop and the static-preview ablation at equal tokens on CoDA-HARD and the SWE-MERA slice, with the gain concentrated on runtime-error tasks where COCOGEN's symbol lookup cannot fire. The erosion claim holds only if duplication traced to unopened previews is a substantial share of new SlopCodeBench verbosity, and that share falls under our previews while checkpoint pass rate does not drop.
References
- What Snippets Say About Pages
- Less is Less: When are Snippets Insufficient for Human vs Machine Relevance Estimation?
- LiveNewsBench: Evaluating Web Search Agents with Freshly Curated News
- Bridging the Gap between Intrinsic and Perceived Relevance in Snippet Generation
- Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedback
- ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinement
- Repoformer: Selective Retrieval for Repository-Level Code Completion
- SWE-bench: Can Language Models Resolve Real-world Github Issues?
- CoDA-Bench: Can Code Agents Handle Data-Intensive Tasks?
- SlopCodeBench: Measuring Code Erosion Under Iterative Specification Refinement
- SWE-MERA: A Dynamic Benchmark for Agenticly Evaluating Large Language Models on Software Engineering Tasks
- Signal and Noise: A Framework for Reducing Uncertainty in Language Model Evaluation