arXiv:2604.26102cs.SEcs.CL2026-04被引 3

拆分代码编辑流程,提升编程智能体的效率与可靠性。

SWE-Edit: Rethinking Code Editing for Efficient SWE-Agent

  • 将编辑分为查看与执行两个专用子代理,分离上下文负担。
  • 在SWE-Bench Verified上解决率提升2.1个百分点,推理成本降低17.9%。
  • 轻量评估工具PR-Edit可快速迭代编辑器,适合研发团队使用。

大型语言模型智能体在软件工程领域进展显著,但现有系统存在上下文耦合问题:标准代码编辑接口将代码检查、修改规划与编辑执行混在一个上下文窗口中,迫使智能体在探索性查看与严格格式化编辑之间交替,导致无关信息累积,编辑可靠性下降。我们提出SWE-Edit,将编辑接口分解为两个专用子代理:一个查看器按需提取任务相关代码,一个编辑器根据高层自然语言计划执行修改,使主智能体专注于推理,而将上下文密集型操作交由独立的清洁上下文窗口处理。在SWE-Bench Verified上,该分解使解决率提升2.1个百分点,推理成本降低17.9%,并在多个推理模型族(Kimi-K2、MiniMax-M2.1、GLM-4.7)中均取得一致改进。进一步表明,有效的编辑格式选择可通过小模型训练实现,无需前沿规模算力:在Qwen3-8B上采用GRPO训练并结合自适应查找替换/整文件重写策略,编辑成功率提升12.5个百分点,使8B开源编辑器达到GPT-5-nano在下游SWE-Bench解决率上的表现。为支持快速编辑器迭代,我们发布PR-Edit,一种轻量级评估工具,其得分与SWE-Bench解决率高度相关。代码已公开于https://github.com/microsoft/SWE-Edit。

原文摘要 · Abstract (English)

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.

代码生成智能体编辑优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。