arXiv:2506.16650cs.SEcs.AI2025-06被引 9

让代码修复更懂语义,避免局部修补,提升修复准确率。

SemAgent: A Semantics Aware Program Repair Agent

  • 通过分析问题、代码和执行语义,全局识别相关代码行。
  • 在SWE-Bench-Lite上解决率达44.66%,比基线提升7.66%。
  • 适合需要多行推理和边缘情况处理的复杂修复任务。

大型语言模型在自动化程序修复(APR)任务中展现出强大能力,尤其在仓库级问题修复基准(如SWE-Bench)上已有显著进展。然而,现有智能体系统往往只关注可疑代码行,孤立修复,缺乏对问题语义、代码语义及执行语义的深层理解,导致生成的补丁过度拟合用户问题,难以给出更通用的解决方案。为此,我们提出SemAgent,一种基于工作流的新方法,通过融合问题、代码与执行语义,生成完整且一致的修复补丁。其核心流程包括:(a) 利用执行语义检索相关上下文;(b) 通过泛化抽象理解问题语义;(c) 在抽象背景下隔离代码语义;(d) 采用两阶段架构——修复阶段提出细粒度修改,评审阶段依据推断出的问题语义筛选有效修复。实验表明,该方法在SWE-Bench-Lite基准上达到44.66%的解决率,超越所有其他工作流方法,并相较基线提升7.66%。尤其在需多行推理与边缘情况处理的任务中表现优异,证明将语义理解融入修复流程可实现更鲁棒、一致的修复结果。

原文摘要 · Abstract (English)

Large Language Models (LLMs) have shown impressive capabilities in downstream software engineering tasks such as Automated Program Repair (APR). In particular, there has been a lot of research on repository-level issue-resolution benchmarks such as SWE-Bench. Although there has been significant progress on this topic, we notice that in the process of solving such issues, existing agentic systems tend to hyper-localize on immediately suspicious lines of code and fix them in isolation, without a deeper understanding of the issue semantics, code semantics, or execution semantics. Consequently, many existing systems generate patches that overfit to the user issue, even when a more general fix is preferable. To address this limitation, we introduce SemAgent, a novel workflow-based procedure that leverages issue, code, and execution semantics to generate patches that are complete - identifying and fixing all lines relevant to the issue. We achieve this through a novel pipeline that (a) leverages execution semantics to retrieve relevant context, (b) comprehends issue-semantics via generalized abstraction, (c) isolates code-semantics within the context of this abstraction, and (d) leverages this understanding in a two-stage architecture: a repair stage that proposes fine-grained fixes, followed by a reviewer stage that filters relevant fixes based on the inferred issue-semantics. Our evaluations show that our methodology achieves a solve rate of 44.66% on the SWEBench-Lite benchmark beating all other workflow-based approaches, and an absolute improvement of 7.66% compared to our baseline, which lacks such deep semantic understanding. We note that our approach performs particularly well on issues requiring multi-line reasoning (and editing) and edge-case handling, suggesting that incorporating issue and code semantics into APR pipelines can lead to robust and semantically consistent repairs.

程序修复语义理解LLM应用智能体

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