When a language model repairs code over several rounds, it writes a patch, runs the tests, reads the failures, and tries again. Each round adds more text to its prompt: old patches, stack traces, compiler logs, and its own earlier reasoning. Models are known to get worse when their prompt contains irrelevant material. They are also known to stop improving after two or three repair rounds. We propose that these two facts are linked, and that an old idea from program analysis offers a fix. After each patch, compute which parts of the program the change could affect (its "impact set"), and rebuild the next prompt from only the code, test failures, and prior edits that touch that set. We would then train the repair model with reinforcement learning on this marked context, so that it learns to rely on the marking rather than on a growing transcript.
The borrowed idea is directed incremental symbolic execution. Directed Incremental Symbolic Execution diffs two program versions and slices the control-flow and data-flow graphs to find the nodes a change can reach. It then explores only paths through those nodes, cutting explored path conditions by over 576× on avionics mutants. We apply the same marking to a different consumer. Here the thing being pruned is the language model's context between repair turns, not a symbolic executor's search.
Core Claim
Our central hypothesis concerns accumulated history. Multi-turn repair plateaus partly because stale, change-irrelevant context builds up across turns, and not only because the model runs out of ideas. If this is right, it has three consequences. At inference time, an agent whose context is rebuilt from the impact set of its latest patch should keep improving for more turns than one that appends or summarizes history. It should also regress less often. Finally, training the policy with verifiable-reward reinforcement learning on impact-marked context should widen this gap, since the model learns to treat the marked slice as the complete working state. Reinforcement learning from verifiable rewards means optimizing the model against automatic pass/fail checks such as unit tests, rather than against a learned preference model.
What is new is the pairing of three things: context keyed to the agent's own delta, a slice-based definition of relevance, and a multi-turn training regime in which that context is what the policy sees. Existing systems have at most two of these.
What Prior Work Leaves Open
Three repository-repair systems show that structural context helps. RepoGraph builds a line-level dependency graph and retrieves k-hop neighborhoods. SynFix uses 1-hop dependency neighbors to coordinate multi-file edits, and drops from 52.33% to 31.00% on SWE-bench Lite without them. COCOGEN uses compiler errors as structured queries into the codebase. All three build their graph or index before repair starts and key retrieval to the issue or the error message. None keys it to the agent's own evolving edits, and none trains a policy. RepoGraph's authors name a dynamic, edit-tracking graph as open work.
On the training side, two results constrain our design. Kevin trains multi-turn refinement with discounted per-turn verifiable rewards on CUDA kernels. It found that carrying raw reasoning across turns blew up the context and degraded training, and handled this with natural-language summaries that keep only code and compiler logs. That is exactly the ad hoc pruning we want to replace with a principled rule. LongRLVR shows that sparse terminal rewards give weak signal about which parts of a long context matter. It fixes this for document question answering with a dense reward on evidence selection, which motivates our optional localization reward.
SWE-Gym and Kimi-Dev supply the training substrate and the strongest trained competitors. Both score whole trajectories or final outcomes, with no notion of per-turn relevance.
Two sources on noise frame the tension we must resolve. Less is More removes narrative fluff from problem statements and gains 8.13% strict accuracy on APPS. It also gains only about 2% on competition problems, a warning that pruning cannot replace reasoning. SWE-bench shows Claude 2 rising from 1.96% to 4.8% when given oracle files instead of retrieved ones.
The plateau we target comes from CodeTransOcean, where compiler-feedback self-debugging moves DSR@0 from 48.57% to DSR@3 of 52.57%, and gains flatten after about three rounds. DSR@K is the fraction of programs that execute successfully after K rounds of automated debugging.
Research Program
Graph maintenance. We start from the tree-sitter line-level dependency graph released with RepoGraph (RepoGraph code) and make it incremental. When the agent's patch touches a set of lines, we re-parse only the edited files, update their nodes and edges, and diff the old and new graphs.
Impact set. Following DiSE, the impact set at turn t is built from two slices. The forward slice collects the definitions and uses reachable from the changed nodes. The backward slice collects the nodes reachable from the currently failing test assertions. Their union is capped by hop distance.
Context rebuild. The next prompt is rebuilt from scratch every turn. It contains the issue text, the current source of every function intersecting the impact set, and the failing test outputs whose stack frames fall in the impact set. It also includes a compact ledger of earlier patches, restricted to those whose own impact sets intersect the current one. Everything else from earlier turns is dropped. That includes old reasoning, passing-test logs, and patches to unrelated regions.
The ledger is what separates this from simple truncation. The agent can still see that it already tried and reverted an edit to the same function. Losing that record is the failure mode that motivates the rollback mechanisms of Fang et al..
Policy training. We then train a policy on this context with multi-turn Group Relative Policy Optimization (GRPO), a policy-gradient method that normalizes each rollout's reward against other rollouts for the same task. Turn rewards are discounted as in Kevin. The reward is test-suite outcome on SWE-Gym environments, with regression tests counted. As an ablation only, we add a LongRLVR-style dense term: the F-score between the lines the agent edits and the backward slice of the failing tests. This slice is computable without the gold patch. We treat this term as a hypothesis, not a component, because it could push the agent away from correct fixes that lie outside the slice.
Flaky tests. Tests in these environments can be flaky, a noise source that Reinforcement Learning with Verifiable yet Noisy Rewards under Imperfect Verifiers shows can badly distort learning. We therefore rerun failing tests to estimate a flake rate per environment. We exclude environments above a threshold rather than adding a noise-correction method, so that noise correction does not confound the context comparison.
Where slicing breaks. DiSE's authors found that the size of a change does not predict how much the impact set shrinks. A small edit to a core loop or data structure can mark half the program. Python adds dynamic dispatch and reflection, which make static slices over-approximate. We will report the distribution of impact-set sizes. We will also report how often the cap truncates, and whether resolve-rate gains concentrate in tasks with compact impact sets. If gains exist only there, the method is a niche tool, and we will say so.
Baselines
Naive reference. The same backbone runs the same multi-turn loop with full history appended each turn, up to the context limit. This is the configuration that CodeTransOcean-style plateaus describe. It anchors every per-turn curve.
Kevin-style summarization. The model summarizes past reasoning, and only the latest code and test/compiler logs are kept verbatim. This is the pruning rule that has already been shown to work under multi-turn reinforcement learning, which makes it the most direct competitor for the context-management question. We run it with the identical backbone, training environments, GRPO settings, rollout count, and turn budget. Beating it means a higher resolve rate at the same turn budget on SWE-bench Verified, with non-overlapping confidence intervals over seeds, and a turn-gain curve that is still rising where the summary curve has flattened.
Static structural retrieval. RepoGraph or SynFix-style retrieval is computed once from the issue and held fixed across turns. It tests whether the benefit comes from structure alone or from re-keying to the delta. SynFix reports 55.8% on SWE-bench Verified and 52.33% on SWE-bench Lite, but with GPT-4o and a pipeline we will not replicate exactly. We therefore reimplement its 1-hop scoping on our backbone and cite its numbers only as context.
Strongest trained systems. Kimi-Dev reports 60.4% on SWE-bench Verified in workflow mode and 48.6% pass@1 in agentic mode. SWE-Gym reports 20.6% pass@1 and 32.0% Best@16 with a 32B agent and a 32B verifier. We do not expect to match Kimi-Dev's absolute number. The claim is about the context rule, so the decisive comparisons all share a backbone. The SWE-Gym 32B pass@1 of 20.6% is the most comparable published trained number, and clearing it with the naive-history configuration is a sanity requirement before any comparison counts.
Key-ingredient ablations. These isolate what drives any gain. One replaces the impact set with an equally sized random set of functions from the edited files, to control for context length alone. One removes the ledger. One uses an oracle impact set derived from the gold patch, as an upper bound on what better marking could give.
Why not just…?
Why not just keep only the last turn? This is the most serious threat. It is trivially cheap and removes all stale noise. Its cost is losing memory of what was already tried, which should appear as higher regression and loop rates. SWE-Gym reports a stuck-in-loop rate of 29.4% dropping to 23.8% for a 32B model after fine-tuning, so looping is a measurable, live failure. We include last-turn-only as a baseline under both inference and reinforcement-learning training. If it matches impact marking on resolve rate and regression rate, the slice-based ledger adds nothing, and the proposal reduces to "forget aggressively," a finding worth reporting in its own right.
Why not just let a model summarize the history, as Kevin did? Summaries worked for single-file kernels, where there is no cross-file dependency to lose. In repositories, the relevant history is exactly the set of edits that interact through dependencies, and a free-text summary has no guarantee of preserving it. Less is More also shows summarization gains collapse on harder problems. The head-to-head under identical GRPO training settles this. As a control, we run on KernelBench, where impact marking degenerates to near-summary behavior, and we predict no advantage there. Seeing an advantage on KernelBench would suggest our gains come from something other than dependency structure.
Why not just rebuild the dependency graph from scratch each turn? For the model's accuracy, a from-scratch rebuild keyed to the same delta would produce the same context. We are honest that incrementality matters here for throughput, not accuracy. The accuracy claim rests on delta-keyed selection, while incremental maintenance determines how many rollouts fit in a fixed training budget. We found no reported rebuild latency for RepoGraph. COCOGEN reports 1.27 s per structural query, which suggests queries are cheap but says nothing about full rebuilds. We will measure both costs per turn and report rollouts per GPU-hour, and will not claim an accuracy benefit from incrementality itself.
Why not just give the policy a larger context window? SWE-bench's oracle-versus-retrieval gap, and the attention-diffusion failures catalogued in the noise literature, suggest that more context hurts. Our noise-injection experiment below measures this directly as a function of turn.
Proposed Experiments
Diagnostic noise-injection study. This is inference-only, and it tests the causal story before any training. We take an off-the-shelf backbone on SWE-bench Verified. At turn t we hold the current code and failing test fixed, and vary only the history: none, full, summarized, impact-marked, or impact-marked plus an equal number of tokens of stale, non-intersecting prior logs. If stale history does not measurably lower the next-turn fix rate, or if the effect does not grow with t, the plateau is not a noise problem and the rest of the program should be scaled back.
Main training comparison. We train on SWE-Gym, which has 2,438 environments across 11 Python repositories, and evaluate on SWE-bench Verified and Lite. Each context rule is trained under matched compute with at least three seeds, with evaluation turn budgets from 1 to 8. Metrics are resolve rate at each budget, marginal gain per added turn, and regression rate (tests passing at an earlier turn that later fail). We also report stuck-in-loop rate and prompt tokens per turn.
Decisive result. Impact-marked training should beat both summarization and last-turn-only on resolve rate at turn budgets of 6 and above, and its per-turn gain curve should remain positive past turn 3 while the others flatten. The random-set ablation should not recover this gain.
Secondary checks. The KernelBench control is the single-file setting described above, where no advantage should appear; the reported Kevin numbers give an external check on our training setup (82% best@16 correctness, 1.10× mean speedup). The oracle-impact-set run gives a ceiling. The dense slice-reward ablation tells us whether LongRLVR's localization lesson transfers to code, or whether constraining edits to a static slice hurts on tasks whose fix lies outside it.
References
- Directed Incremental Symbolic Execution
- RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graph
- SynFix: Dependency-Aware Program Repair via RelationGraph Analysis
- Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedback
- Kevin: Multi-Turn RL for Generating CUDA Kernels
- LongRLVR: Long-Context Reinforcement Learning Requires Verifiable Context Rewards
- Training Software Engineering Agents and Verifiers with SWE-Gym
- Kimi-Dev: Agentless Training as Skill Prior for SWE-agents
- Less is More: Summary of Long Instructions is Better for Program Synthesis
- SWE-bench: Can Language Models Resolve Real-world Github Issues?
- CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translation
- MEIC: Re-thinking RTL Debug Automation using LLMs
- Reinforcement Learning with Verifiable yet Noisy Rewards under Imperfect Verifiers