Large language model agents have made strong progress on software engineering, yet current systems suffer from a context coupling problem: the standard code editing interface conflates code inspection, modification planning, and edit execution within a single context window, forcing agents to interleave exploratory viewing with strictly formatted edit generation. Irrelevant context accumulates and edit reliability degrades. We propose SWE-Edit, which decomposes the editing interface into two specialized subagents: a Viewer that extracts task-relevant code on demand, and an Editor that executes modifications from high-level natural language plans -- letting the main agent focus on reasoning while delegating context-intensive operations to clean context windows. On SWE-Bench Verified, this decomposition raises resolve rate by 2.1 pp and cuts inference cost by 17.9%, with consistent gains across multiple reasoning-model families (Kimi-K2, MiniMax-M2.1, GLM-4.7). We further show that effective edit-format selection can be trained into a small model rather than requiring frontier-scale capacity: GRPO training on Qwen3-8B with an adaptive find-replace/whole-file-rewrite policy improves edit success by 12.5 pp and brings an 8B open-source editor to parity with GPT-5-nano on downstream SWE-Bench resolve rate. To enable rapid editor iteration, we release PR-Edit, a lightweight evaluation whose scores correlate strongly with SWE-Bench resolve rate. We release our code at https://github.com/microsoft/SWE-Edit.
翻译:大语言模型智能体在软件工程领域取得了显著进展,但现有系统存在上下文耦合问题:标准代码编辑接口将代码检查、修改规划和编辑执行混在单一上下文窗口内,迫使智能体在探索性查看与严格格式化的编辑生成之间频繁切换。无关上下文不断累积,编辑可靠性随之下降。我们提出SWE-Edit方法,将编辑接口分解为两个专门化的子智能体:一个按需提取任务相关代码的查看器(Viewer)和一个根据高层级自然语言计划执行修改的编辑器(Editor)——让主智能体专注于推理,同时将上下文密集型操作委托给独立的干净上下文窗口。在SWE-Bench验证集上,这种分解使解决率提升2.1个百分点,推理成本降低17.9%,且在多个推理模型系列(Kimi-K2、MiniMax-M2.1、GLM-4.7)上均取得一致提升。我们进一步证明,有效的编辑格式选择可以通过小型模型训练实现,而无需依赖前沿规模能力:在Qwen3-8B上采用自适应查找替换/全文件重写策略进行GRPO训练,使编辑成功率提升12.5个百分点,并使8B开源编辑器的下游SWE-Bench解决率与GPT-5-nano持平。为支持快速迭代编辑器,我们发布轻量级评估基准PR-Edit,其得分与SWE-Bench解决率高度相关。相关代码已开源至https://github.com/microsoft/SWE-Edit。