arXiv:2604.25737cs.SEcs.AI2026-04中稿 · the EQUISA

多智能体协作提升代码编辑可靠性,有效减少错误与幻觉。

SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?

论文配图:SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?
图 1 · 摘自论文原文
  • 拆分编辑任务为规划、编辑、验证三角色,逐层推进。
  • 在多语言测试中达68.6%成功率,较单模型提升8.6个百分点。
  • 通过失败分析反馈实现迭代优化,适合高可靠性需求场景。

指令式代码编辑是大语言模型面临的重要挑战。在EditBench基准上,40个评估模型中有39个任务成功率达低于60%,暴露出通用代码生成与受指令驱动的编辑能力之间的差距。为此,我们提出SAFEdit,一种多智能体框架,将编辑过程分解为专门角色以提升可靠性并减少意外修改。规划者生成显式的、具有可见性感知的编辑计划,编辑者执行最小化、字面化的代码变更,验证者运行真实测试。当测试失败时,SAFEdit通过失败抽象层(FAL)将原始测试日志转化为结构化诊断反馈,回传给编辑者支持迭代修正。我们在包含5种语言(英语、波兰语、西班牙语、中文、俄语)的445个代码编辑实例上,采用不同空间上下文变体评估SAFEdit。结果表明,其任务成功率为68.6%,相比单模型基线提升3.8个百分点,相比ReAct单智能体基线提升8.6个百分点。迭代修正环路贡献了17.4个百分点的成功率提升。自动化错误分析还显示,相比单智能体方法,指令级幻觉显著减少,提供超越通过/失败结果的失败解释能力。

原文摘要 · Abstract (English)

Instructed code editing is a significant challenge for large language models (LLMs). On the EditBench benchmark, 39 of 40 evaluated models obtain a task success rate (TSR) below 60 percent, highlighting a gap between general code generation and the ability to perform instruction-driven editing under executable test constraints. To address this, we propose SAFEdit, a multi-agent framework for instructed code editing that decomposes the editing process into specialized roles to improve reliability and reduce unintended code changes. A Planner Agent produces an explicit, visibility-aware edit plan, an Editor Agent applies minimal, literal code modifications, and a Verifier Agent executes real test runs. When tests fail, SAFEdit uses a Failure Abstraction Layer (FAL) to transform raw test logs into structured diagnostic feedback, which is fed back to the Editor to support iterative refinement. We compare SAFEdit against both prior single-model results reported for EditBench and an implemented ReAct single-agent baseline under the same evaluation conditions. We used EditBench to evaluate SAFEdit on 445 code editing instances in five languages (English, Polish, Spanish, Chinese, and Russian) under varying spatial context variants. SAFEdit achieved 68.6 percent TSR, outperforming the single-model baseline by 3.8 percentage points and the ReAct single-agent baseline by 8.6 percentage points. The iterative refinement loop was found to contribute 17.4 percentage points to SAFEdit's overall success rate. SAFEdit's automated error analysis further indicates a reduction in instruction-level hallucinations compared to single-agent approaches, providing an additional framework component for interpreting failures beyond pass or fail outcomes.

代码生成多智能体可靠性编辑评估

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