Papers
Topics
Authors
Recent
Search
2000 character limit reached

SWE-Edit: Modular Code-Editing Framework

Updated 5 July 2026
  • SWE-Edit is a code-editing framework that decomposes tasks by using distinct subagents for code viewing and editing to address the context coupling problem.
  • It improves performance by reducing non-cached tokens by 34.5% and boosting edit success rates to 96.9% on SWE-bench Verified tasks.
  • The architecture employs adaptive mode selection via GRPO, seamlessly switching between find-and-replace and whole-file rewrites for efficient patch generation.

Searching arXiv for SWE-Edit and closely related SWE benchmark papers to ground the article. SWE-Edit is a code-editing framework for software engineering agents that addresses what it terms the context coupling problem: in standard agent scaffolds, code inspection, modification planning, and edit execution are interleaved within a single context window, so exploratory viewing and format-constrained patch generation compete for limited attention (Zhang et al., 28 Apr 2026). The framework decomposes these functions into specialized subagents—a Viewer for task-relevant code retrieval and an Editor for executing modifications from high-level instructions—while leaving a main reasoning agent responsible for orchestration (Zhang et al., 28 Apr 2026). Evaluated on SWE-bench Verified, SWE-Edit improves resolved rate by 2.1% and reduces inference cost by 17.9%, and it is accompanied by PR-Edit, a code editing benchmark intended to predict downstream agentic performance (Zhang et al., 28 Apr 2026).

1. Conceptual basis and relation to SWE-style evaluation

SWE-Edit is situated within the broader family of repository-level software engineering benchmarks derived from SWE-bench, where an agent is given an issue description and a real repository snapshot and is expected to produce code edits that make tests pass (Jimenez et al., 2023). In SWE-bench, edits are represented as patch files applied to real repositories, and success is determined executionally: a task is resolved if the resulting codebase passes the designated FAIL_TO_PASS and PASS_TO_PASS tests (Jimenez et al., 2023). SWE-agent subsequently showed that performance on such tasks is highly sensitive to the design of the agent-computer interface, with repository navigation, file editing, and execution feedback all affecting resolution rates (Yang et al., 2024).

Against this background, SWE-Edit focuses specifically on the editing layer rather than the full end-to-end agent loop (Zhang et al., 28 Apr 2026). Its central claim is that many existing systems use a monolithic interface in which a single model must inspect files, reason about changes, and emit exact edit commands inside one growing context, thereby accumulating irrelevant code snippets that degrade both efficiency and accuracy (Zhang et al., 28 Apr 2026). This framing complements work such as ORACLE-SWE, which isolates the contributions of information signals like Edit Location, Execution Context, Reproduction Test, Regression Test, and API Usage, and shows that localization signals alone are helpful but not dominant unless combined with stronger guidance such as reproduction tests (Li et al., 9 Apr 2026).

SWE-Edit also serves as a reference point for later interactive and user-driven benchmarks. SWE-Interact explicitly describes itself as taking the “SWE-bench / SWE-Edit” style of static, single-shot repository patching and embedding it in a multi-turn workflow with vague initial requests, incremental requirement disclosure, and user feedback (Raghavendra et al., 29 Jun 2026). This suggests that SWE-Edit occupies the static patch-generation end of a broader capability spectrum: it optimizes edit execution under a fully specified issue, whereas later benchmarks test interactive goal discovery and iterative refinement (Raghavendra et al., 29 Jun 2026).

2. The context coupling problem

The motivating problem in SWE-Edit is that standard code-editing interfaces conflate three distinct operations: viewing code, planning modifications, and emitting structured edits (Zhang et al., 28 Apr 2026). In conventional scaffolds such as Anthropic’s str_replace_editor, Aider, and OpenHands-based agents, the same agent incrementally opens files, scrolls through them, reasons about a solution, and finally generates find-and-replace or diff-style edits in the same context window (Zhang et al., 28 Apr 2026).

SWE-Edit argues that this produces context pollution. Snippets viewed during exploration often turn out to be irrelevant to the final fix, yet they remain in context and compete with the code that actually needs editing (Zhang et al., 28 Apr 2026). The result is a structural conflict: broad exploration requires more viewed text, while precise editing benefits from a minimal, tightly focused context (Zhang et al., 28 Apr 2026). The paper further notes that the dominant find-and-replace interface is fragile, because exact matching fails under whitespace or indentation mismatches, and because the model must simultaneously reason about the change and reproduce the exact pre-edit text within a strict markup format (Zhang et al., 28 Apr 2026).

The empirical evidence presented in SWE-Edit is consistent with this diagnosis. In a strong baseline scaffold on SWE-bench Verified, the main agent consumes 276.7K non-cached input tokens per run on average, while edit success is 93.4% (Zhang et al., 28 Apr 2026). When the full SWE-Edit system is used, non-cached input tokens fall to 181.3K, a 34.5% reduction, while edit success rises to 96.9% (Zhang et al., 28 Apr 2026). This suggests that much of the baseline context is unnecessary for successful editing, and that editing reliability can be improved by isolating low-level edit generation from exploratory reasoning (Zhang et al., 28 Apr 2026).

A plausible implication is that SWE-Edit’s decomposition addresses a narrower but important subproblem within autonomous software engineering: not merely how to reason over repositories, but how to preserve reasoning quality by preventing context contamination during code retrieval and patch synthesis.

3. Architecture: main agent, Viewer, and Editor

SWE-Edit is presented as a two-stage optimization framework operating at both the scaffolding and model levels (Zhang et al., 28 Apr 2026). At the scaffolding level, it introduces three roles: a Main agent, a Viewer, and an Editor (Zhang et al., 28 Apr 2026).

The Main agent is a high-capacity reasoning model responsible for understanding the issue, forming hypotheses, deciding which files or functions to inspect, choosing when to edit, and running tests (Zhang et al., 28 Apr 2026). Crucially, it does not directly inspect whole files or emit low-level edit commands; instead, it delegates these operations to the Viewer and Editor through an llm_editor tool (Zhang et al., 28 Apr 2026).

The Viewer is a smaller, cost-effective model used with llm_editor and "command": "view" (Zhang et al., 28 Apr 2026). It receives a file path and a natural-language query such as “show the implementation of X” or “where is user authentication handled?” and returns only relevant line ranges plus surrounding context (Zhang et al., 28 Apr 2026). The Viewer sees the entire file, but the Main agent only receives the selected snippets (Zhang et al., 28 Apr 2026). The paper reports that SWE-Edit uses about 7.49 Viewer calls per instance, and that each call returns on average 39.7% of the file, corresponding to 60.3% context reduction (Zhang et al., 28 Apr 2026).

The Editor is invoked through llm_editor with "command": "edit" (Zhang et al., 28 Apr 2026). It receives a file path and a high-level natural-language instruction describing the desired change, reads the entire file internally, chooses an editing mode, and emits concrete edit operations (Zhang et al., 28 Apr 2026). This separates high-level reasoning from the production of format-sensitive patches (Zhang et al., 28 Apr 2026). In the highest-performance setup, the Editor is implemented with GPT-5-mini; an open-weight alternative based on Qwen3-8B fine-tuned with GRPO is also studied (Zhang et al., 28 Apr 2026).

The typical workflow consists of six steps: initialize from the repo and issue description; inspect code through Viewer calls; plan changes; execute edits through the Editor; validate by running tests; and iterate until producing a final patch (Zhang et al., 28 Apr 2026). Conceptually, this creates separate context windows for reasoning, retrieval, and patch execution, rather than forcing all three into a single conversational state (Zhang et al., 28 Apr 2026).

This architecture bears a family resemblance to earlier agent-computer interface ideas in SWE-agent, which also argued for specialized commands for viewing, searching, and editing files, plus concise feedback and guardrails (Yang et al., 2024). The difference is that SWE-Edit internalizes those interface specializations as LLM subagents, especially for viewing and editing, rather than only as shell-level commands (Zhang et al., 28 Apr 2026).

4. Editing interface and adaptive edit modes

A central component of SWE-Edit is the Editor’s unified editing syntax, which supports both localized replacement and whole-file rewrite (Zhang et al., 28 Apr 2026). The syntax is:

1
2
3
4
5
<<<<<<< SEARCH
<exact lines from the original file to find>
=======
<new lines to replace them with>
>>>>>>> REPLACE

If the SEARCH block is empty, the edit is treated as a whole-file rewrite, and the REPLACE block becomes the entire new file (Zhang et al., 28 Apr 2026). Multiple edits can be expressed by emitting multiple blocks in sequence, and if a SEARCH pattern is not unique, the Editor is instructed to add more context (Zhang et al., 28 Apr 2026).

SWE-Edit treats mode choice—find-and-replace versus whole-file rewrite—as a learned decision rather than a fixed rule (Zhang et al., 28 Apr 2026). The paper formulates this as a single-step decision problem in which the Editor observes a file cc, a natural-language instruction qq, and chooses an editing mode m{find-replace,whole-file-rewrite}m \in \{\text{find-replace}, \text{whole-file-rewrite}\} (Zhang et al., 28 Apr 2026). Training uses GRPO on PR-derived edit data, with reward based on normalized match between generated and gold edits after a lightweight code canonicalization procedure that removes comments and normalizes whitespace (Zhang et al., 28 Apr 2026).

The training corpus comprises 3.5K examples mined from open-source GitHub pull requests, split into 2.8K train, 200 validation, and 500 held-out test examples (Zhang et al., 28 Apr 2026). For each example, the paper extracts file contents before and after the PR, the diff, and the PR message, then uses GPT-4.1 to generate a natural-language edit instruction (Zhang et al., 28 Apr 2026). The held-out 500-example test set becomes PR-Edit, a benchmark for evaluating editors in isolation (Zhang et al., 28 Apr 2026).

The GRPO setup uses 32 instances per batch and 8 candidate outputs per instance, with 520 rollout steps (Zhang et al., 28 Apr 2026). Mode selection is implicit: the Editor receives no explicit labels for which editing mode to use, but learns that localized changes are often better expressed as find-and-replace, while more structural transformations are better handled as whole-file rewrites (Zhang et al., 28 Apr 2026).

The paper’s ablation between fixed Search-Replace only and Adaptive mode selection shows modest but consistent gains: on PR-Edit, GPT Grader improves from 67.0% to 68.4%, and on SWE-bench, resolved rate improves from 69.4% to 69.9%, cost decreases from \$244.7** to **\$215.9, and edit success rises from 80.2% to 81.1% (Zhang et al., 28 Apr 2026). This suggests that edit mode selection is a real bottleneck, but one that benefits more from targeted training than from brute-force model scaling (Zhang et al., 28 Apr 2026).

5. Evaluation on SWE-bench Verified and PR-Edit

SWE-Edit is evaluated primarily on SWE-bench Verified, a 500-instance benchmark of real GitHub issues with repository snapshots and tests, where success is defined by passing all tests after the patch is applied (Zhang et al., 28 Apr 2026). For each configuration, the authors report averages over three independent runs across all 500 instances (Zhang et al., 28 Apr 2026).

The main comparison includes four configurations: baseline monolithic editing, + Viewer, + Editor, and the full SWE-Edit system (Zhang et al., 28 Apr 2026).

Configuration Resolved Total cost Edit success
Baseline 69.9% \$243.7 93.4%
+ Viewer 70.3% \$225.0 94.3%
+ Editor 71.3% \$268.4 96.1%
SWE-Edit 72.0% \$200.1 96.9%

These results show a clear division of labor between the two subagents (Zhang et al., 28 Apr 2026). The Viewer primarily reduces cost and input-token burden by filtering code before it reaches the Main agent, while the Editor primarily improves edit reliability (Zhang et al., 28 Apr 2026). When combined, they yield both the highest resolved rate and the lowest total cost, producing what the paper describes as a cost–performance synergy (Zhang et al., 28 Apr 2026).

The token statistics are particularly central to the paper’s argument. Compared with the baseline, SWE-Edit reduces Main agent non-cached input tokens from 276.7K to 181.3K, a 34.5% drop (Zhang et al., 28 Apr 2026). Viewer calls increase relative to baseline, from 5.78 to 7.49, but this is inexpensive because the Viewer is small and only returns snippets (Zhang et al., 28 Apr 2026). Editor calls average 2.37 per instance in the final system (Zhang et al., 28 Apr 2026).

The paper also evaluates the architecture with different reasoning backbones on the first 100 SWE-bench Verified instances, using 2 runs per model (Zhang et al., 28 Apr 2026). Edit success rises consistently across model families. For Kimi K2, edit success improves from 75.6% to 93.9%; for MiniMax-M2.1, from 79.6% to 94.8%; and for GLM-4.7, from 82.0% to 95.9% (Zhang et al., 28 Apr 2026). The resolved-rate improvements are smaller but generally positive (Zhang et al., 28 Apr 2026). This suggests that the scaffolding change is not tied to a single reasoning model.

The isolated editor benchmark PR-Edit functions as both a training target and a predictor of downstream performance (Zhang et al., 28 Apr 2026). On PR-Edit, Qwen3-8B achieves 76.8% format success, 56.0% GPT Grader score, and 32.0% normalized match; after GRPO, these rise to 90.4%, 68.4%, and 38.8%, respectively (Zhang et al., 28 Apr 2026). GPT-5-mini reaches 77.5% GPT Grader and 41.7% normalized match, while GPT-5 reaches 77.2% GPT Grader and 44.1% normalized match (Zhang et al., 28 Apr 2026). Across editor models, the correlation between PR-Edit GPT Grader and downstream SWE-bench resolve rate is reported as Pearson r0.98r \approx 0.98 (Zhang et al., 28 Apr 2026). This makes PR-Edit notable as a proxy benchmark for editor quality.

6. Relations to adjacent work and broader significance

SWE-Edit intersects with several adjacent lines of research. Relative to original SWE-bench, it addresses a later stage of the pipeline: SWE-bench established repository-scale issue resolution as a testbed for LLMs, with tasks formulated as patch generation against real codebases and evaluation grounded in execution (Jimenez et al., 2023). SWE-Edit inherits that evaluation setting but concentrates on making the edit interface itself more reliable and efficient (Zhang et al., 28 Apr 2026).

Relative to SWE-agent, SWE-Edit shares the premise that interface design matters. SWE-agent introduced an agent-computer interface with explicit commands for opening files, searching, editing, and submitting patches, and showed that these abstractions substantially improved performance over raw shell use (Yang et al., 2024). SWE-Edit pushes the same idea further by replacing generic commands for viewing and editing with specialized LLM subagents that each operate in their own isolated context (Zhang et al., 28 Apr 2026).

Relative to Live-SWE-agent, which emphasizes on-the-fly synthesis of tools such as custom edit and search scripts, SWE-Edit is more static and interface-centric (Xia et al., 17 Nov 2025). Live-SWE-agent shows that strong models can benefit from runtime tool creation and reach 75.4% on SWE-bench Verified with Claude 4.5 Sonnet (Xia et al., 17 Nov 2025), whereas SWE-Edit studies whether the editing subsystem itself can be decomposed and optimized (Zhang et al., 28 Apr 2026). These approaches are not mutually exclusive: a plausible implication is that a SWE-Edit-style Viewer/Editor decomposition could coexist with live tool creation.

Relative to ORACLE-SWE, SWE-Edit primarily targets the Edit Location and edit-execution portions of the agent pipeline (Li et al., 9 Apr 2026). ORACLE-SWE finds that localization alone is less important than Reproduction Test guidance, and that the strongest gains come from combining reproduction with localization, execution context, or API usage (Li et al., 9 Apr 2026). This places SWE-Edit in a broader decomposition of SWE capability: its contribution is substantial at the editing layer, but it does not by itself solve the higher-value bottlenecks associated with testing and semantic bug reproduction (Li et al., 9 Apr 2026).

Relative to SWE-Interact, SWE-Edit represents the static, fully specified prompt regime (Raghavendra et al., 29 Jun 2026). SWE-Interact reports that top models scoring roughly 50% on the single-turn baseline solve only 25–27% of the corresponding multi-turn tasks, despite identical underlying repositories and verifiers (Raghavendra et al., 29 Jun 2026). This suggests that efficient static editing, of the sort SWE-Edit improves, is a necessary but insufficient capability for interactive software engineering.

Other contemporaneous benchmarks further delimit the scope of SWE-Edit. EDIT-Bench focuses on single-file, highlight-conditioned instructed edits derived from real IDE usage, with performance sensitive to whether highlight or cursor information is exposed (Chi et al., 6 Nov 2025). ToM-SWE emphasizes persistent modeling of user preferences and multi-session interaction via a dedicated theory-of-mind agent (Zhou et al., 24 Oct 2025). Together, these works indicate that software-engineering capability is being factored into repository navigation, edit execution, user modeling, and multi-turn interaction; SWE-Edit is the principal contribution in this set aimed squarely at the edit execution bottleneck.

7. Limitations, interpretation, and future directions

SWE-Edit’s gains are meaningful but bounded. The improvement from 69.9% to 72.0% on SWE-bench Verified is substantial in a competitive regime, but it does not change the overall task definition, and it leaves most of the remaining error mass outside the editing interface itself (Zhang et al., 28 Apr 2026). The paper explicitly notes that the Editor is trained offline on PR-like data using a static match-based reward and does not receive full end-to-end trajectory rewards from test outcomes (Zhang et al., 28 Apr 2026). This limits its exposure to downstream execution semantics.

The Viewer also introduces its own inference overhead, even if modest, and the paper acknowledges that in very cost-sensitive settings a classical retriever might still be preferable, albeit with weaker semantic recall (Zhang et al., 28 Apr 2026). Whole-file rewrites remain potentially risky if misused, and while RL encourages appropriate mode selection, it does not guarantee minimality or safety of rewrites (Zhang et al., 28 Apr 2026).

Another limitation is scope. SWE-Edit is evaluated in the fully specified, single-turn benchmark setting of SWE-bench Verified (Zhang et al., 28 Apr 2026). It does not address persistent user preferences, underspecified requests, or multi-turn requirement discovery, all of which later work identifies as important real-world axes (Zhou et al., 24 Oct 2025, Raghavendra et al., 29 Jun 2026). Nor does it natively reason about the differential value of information signals such as reproduction tests or execution traces, which ORACLE-SWE shows to be the highest-impact sources of improvement beyond localization and editing (Li et al., 9 Apr 2026).

Future directions are therefore visible along at least three dimensions. One is end-to-end training, in which the Editor receives rewards tied to actual task resolution rather than approximate diff similarity (Zhang et al., 28 Apr 2026). Another is integration with richer agent workflows, combining a SWE-Edit-style editing core with stronger localization, reproduction-test generation, or execution-context modules (Li et al., 9 Apr 2026). A third is extension into interactive settings, where the same decomposition might be embedded in user-driven or stateful workflows rather than static issue resolution (Raghavendra et al., 29 Jun 2026, Zhou et al., 24 Oct 2025).

In this sense, SWE-Edit is best understood not as a complete theory of software-engineering agents, but as a precise intervention on one of their most failure-prone interfaces. Its lasting significance lies in making the edit layer measurable, trainable, and modular, and in showing that even within high-performing SWE agents, code retrieval and patch execution benefit from being treated as distinct computational problems rather than as incidental subroutines of a monolithic prompt (Zhang et al., 28 Apr 2026).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to SWE-Edit.