Software agents that fix bugs work in a loop: read code, propose an edit, run the tests, read the error, try again. Today they see the repository through a keyhole. They view 100-line windows, use keyword search, and replace old outputs with one-line summaries, because putting the whole codebase into the prompt on every turn is too slow and expensive. Separately, context parallelism, which splits one long sequence across many GPUs so their combined memory can hold it, can now prefill a million tokens in about a minute. That work has been evaluated only on documents, video and synthetic retrieval, never inside an edit-compile-test loop. This note proposes the following design. Prefill the entire repository once across a group of GPUs. Keep that attention cache resident and sharded for the whole repair episode. Make each turn cost only its own short new text. Handle code edits by masking out the stale file and appending the new version, so nothing downstream is recomputed.
The claim has two parts, and the second is the one that matters scientifically. First, the systems claim: under this "tombstone-and-append" scheme, the per-turn cost of a full-repository agent drops from re-reading the repository to reading only the turn's new tokens, at a measurable and small cost in exactness. Second, the empirical question: once full-repository visibility is affordable inside the loop, does it reduce the failures that windowed agents suffer, namely logic errors and long futile loops? Or does the "lost in the middle" degradation reported by SWE-bench make it useless? Either answer is informative. The design includes a direct test that could refute the premise.
Where This Sits
The motivating evidence comes from code agents. SWE-agent builds an interface around file windowing, capped search and collapsed observation history. It reports that over half of its failures are semantic logic errors and that runs past about 20 turns almost never succeed. SWE-Effi measures the "token snowball": prompts that grow every turn because history is re-sent. It also finds that failed runs cost about 4x the resources of successful ones. COCOGEN and MAGIS address missing context by retrieving it, using syntax-tree queries driven by static errors and keyword-based file filtering respectively. All of these treat context as scarce and ration it. We test what happens when it is not rationed.
The method comes from context parallelism. RingAttention passes key/value blocks around a ring of devices while each device holds a block of queries. It hides communication behind computation, and the order in which blocks are combined does not matter. Context Parallelism for Scalable Million-Token Inference adds a variant that passes queries instead of keys and values ("pass-Q"). Pass-Q wins when almost all of the cache is already computed, below roughly 5% cache misses. That is exactly the regime of an agent turn: a huge resident repository plus a few hundred new tokens. The same paper warns of a decode-latency regression under context parallelism, which matters because agent turns generate short outputs often. We reuse pass-Q for turns and pass-KV for the initial prefill. We do not claim new ring kernels.
DCP shows that irregular attention masks can be planned and their empty regions skipped. LongCA-Bench shows that non-causal masks hurt kernel efficiency. Both constrain the design: tombstone masks must stay coarse, at the granularity of whole file blocks, not individual tokens.
The closest connecting work is PI-Mem. It reads chunks in parallel over several refinement turns while sharing a global natural-language memory, and it beats recurrent memory on 3.6M-token question answering. It compresses evidence into text and has never been run against an executable codebase. We keep exact token-level attention over the raw code, which matters when the fix depends on exact signatures. The chunk-independent methods, NBCE and LARA, give up cross-window attention entirely. NBCE's own authors note failures on multi-hop tasks, and cross-file dependencies in code are multi-hop by nature. We therefore do not use them.
Core Mechanism
At the start of an episode, the repository's source files are serialized in a fixed order, file blocks are assigned to devices, and the sequence is prefilled once with causal attention. The resulting key/value cache stays resident and sharded across the ring.
Each agent turn appends a suffix. The suffix contains the tool observation (test output, traceback) and the model's next action. The suffix is processed with pass-Q against the resident cache, and its own key/value entries are appended to the tail shard.
When the agent edits file $f$, we do not recompute anything. File $f$'s cache block is tombstoned, meaning all future queries are masked from attending to it. The edited file is then appended at the tail as a new block. All new queries attend to the new block, and the new block attends to everything before it.
The scheme is inexact in one specific way. Files that came after $f$ in the original order were encoded while seeing the old $f$. Their cached representations are therefore slightly stale. We call this edit staleness, and quantifying it is a core deliverable. Old observations are handled the same way: instead of being lossily summarized, they can be tombstoned and remain recoverable, without being re-sent.
The cost model is straightforward. If $R$ is repository length and $s_t$ is the number of new tokens at turn $t$, re-prefilling every turn costs on the order of $R^2$ attention work per turn. Even ideal prefix caching must recompute everything after the earliest edited file. The resident scheme costs on the order of $s_t \cdot R$ per turn, because each new token attends once over the resident cache. Position indices grow with appended edits and turns. We cap total positions within the model's trained window and trigger a full re-prefill, which also clears accumulated staleness, when the cap or a staleness budget is reached.
Research Program
We will build the resident-context agent on an open-weight long-context model, with Qwen3-32B as the primary candidate because SWE-Effi supplies baselines with it. The context-parallel inference layer uses pass-KV prefill, pass-Q turns and block-granular tombstone masks. We will reuse SWE-agent's linter-guarded edit and test commands, so that the only change from SWE-agent is what the model can see.
Repositories larger than the model's window are reduced by a fixed, task-independent rule: non-test source files of the main package. We report the fraction of gold-patch files that survive this rule, so that coverage failures are separated from reasoning failures.
We then run three analyses. The first measures edit staleness. At every turn, we compare the next-token distributions of the tombstone scheme against an exact recompute of the same state, using KL divergence, and track how the divergence grows with the number and position of edits. The second measures cost: GPU-seconds and wall-clock time per turn and per resolved issue, including the decode regression. The third measures behavior: resolve rate, the share of failures attributable to logic errors under SWE-agent's failure taxonomy, and the rate of runs exceeding 20 turns.
Baselines
The naive reference point is a single-shot, non-interactive retrieval baseline. SWE-agent reports 3.8% on SWE-bench for prior non-interactive retrieval baselines, and SWE-bench reports 1.96% for Claude 2 with BM25 retrieval. We rerun such a baseline with our model to anchor the scale.
The strongest existing competitor at matched model size is Agentless with Qwen3-32B. SWE-Effi reports a 48% resolve rate and 46.7% Effectiveness under Token Budget on its SWE-bench-Verified subset. This is the most relevant comparison because it uses the same open model and is the most efficient method in that study.
For interactive agents, SWE-agent reports 18.0% on SWE-bench Lite with GPT-4 Turbo, and MAGIS reports 25.33% on Lite with GPT-4. Those numbers come from different backbones. We rerun SWE-agent and Agentless with our backbone on identical instances, with the same per-issue cap on GPU-seconds and the same number of sampled attempts. Beating the strongest baseline means a higher resolve rate on SWE-bench-Verified at equal or lower GPU-seconds per resolved issue. Alternatively, it means an equal resolve rate with a clearly lower logic-error failure share, which would indicate that the two approaches are complementary.
Three ablations isolate the key ingredient. Full-repository resident context with exact recompute after every edit isolates the cost of staleness. Full-repository context re-prefilled every turn isolates the systems saving. The resident agent restricted to SWE-agent's windowed view, with the same infrastructure, isolates the effect of visibility itself.
Why not just…?
Why not just retrieve the relevant files, as Agentless or COCOGEN do? This is the real threat. Agentless at 48% shows that retrieval-based localization is strong at this model size. COCOGEN reports an 80% relative pass-rate gain from syntax-tree retrieval, but its signal comes from static errors and cannot target logic bugs. Our proposal is only worth adopting if full visibility helps on exactly the instances where retrieval misses a needed file or the bug is semantic. The per-instance comparison will show this. We will also test the hybrid, retrieval-ordered serialization over a resident full repository. If retrieval alone matches the resident agent, we will report that, and the remaining contribution is the cost analysis.
Why not just use native long context with ordinary prefix caching? Prefix caching is exact only up to the first edited file. Edits to an early file force recomputation of almost the whole repository. Edits to late files are already cheap, so the gap depends on where edits land. The exact-recompute ablation measures this distribution on SWE-bench patches. If most gold edits fall near the end under a sensible ordering, the tombstone scheme buys little, and we will say so.
Why not compress history and repository into a text memory, as PI-Mem does? PI-Mem's gains are on question answering. Paraphrased memory cannot reproduce exact signatures or tracebacks, and the logic-error failures we target depend on those exact details. We include a PI-Mem-style condition: a parallel read of file chunks conditioned on the issue, merged into a text memory and fed to the same loop. This tests the claim directly.
Why not just keep windowing, given lost-in-the-middle? SWE-bench found that localization worsens as more files are added, and RingAttention's near-perfect 512K line-retrieval result is a much easier task than bug localization. The visibility ablation settles this. It runs the same model and infrastructure with and without full-repository visibility, and the outcome is broken down by repository size.
Decisive Checks
The experiments run on SWE-bench Lite for development and on the SWE-bench-Verified subset used by SWE-Effi for headline numbers, with HumanEvalFix as a sanity check that the loop machinery does not hurt small-scale repair.
Three results decide the proposal. The first is whether tombstone staleness stays small. That means low per-turn KL divergence from exact recompute and no statistically detectable resolve-rate gap over a typical episode of 10 to 15 edits. If staleness compounds, the scheme needs periodic re-prefill, and we report the break-even interval. The second is whether per-turn cost scales with new tokens rather than repository length. This is measured as wall-clock time per turn against repository size, including decode, so that the regression reported by Context Parallelism for Scalable Million-Token Inference is counted, not hidden. The third is whether full visibility shifts behavior: fewer logic-error failures and fewer runs exceeding 20 turns than windowed SWE-agent at the same model.
If the third check fails, the honest conclusion is that cheap full-repository context does not help repair at this model scale. That would be a useful negative result for anyone tempted to scale context instead of improving localization.
References
- SWE-bench: Can Language Models Resolve Real-world Github Issues?
- SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering
- SWE-Effi: Re-Evaluating Software AI Agent System Effectiveness Under Resource Constraints
- Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedback
- MAGIS: LLM-Based Multi-Agent Framework for GitHub Issue Resolution
- RingAttention with Blockwise Transformers for Near-Infinite Context
- Context Parallelism for Scalable Million-Token Inference
- DCP: Addressing Input Dynamism In Long-Context Training via Dynamic Context Parallelism
- Long-Context Attention Benchmark: From Kernel Efficiency to Distributed Context Parallelism
- PI-Mem: Pushing Long-Context Reasoning to 3.6M Tokens with Parallel-Iterative Memory
- Naive Bayes-based Context Extension for Large Language Models
- Divide, Reweight, and Conquer: A Logit Arithmetic Approach for In-Context Learning