ExplainBench:评估智能体生成的代码解释
ExplainBench: Evaluating Code Explanations from Agents
July 29, 2026
作者: Zhiyuan Pan, Sungmin Kang, Imam Nur Bani Yusuf, Abhik Roychoudhury
cs.AI
摘要
大语言模型(LLM)智能体在软件工程领域已得到迅速采用。随着智能体在实际代码生成中承担更大角色,它们所做的修改规模也日益增大,往往跨越数十至数百行代码。这使得人工审查智能体结果变得越来越不可行,开发者因而转向借助解释来理解已实施的变更。尽管如此,目前尚无基准测试能够评估智能体生成解释的可信度。为弥补这一空白,我们提出了ExplainBench,一个用于自动评估编码智能体解释质量的基准测试。ExplainBench基于如下直觉:信息充分的解释应能使LLM正确回答问题,从而实现对不同智能体解释质量的定量比较。基于这一观察,我们构建了一组问题,用于评估解释能否准确描述:(1)有缺陷代码的预期行为,以及(2)应用智能体补丁本身所产生的效果。实验首先表明,解释质量是智能体评估中一个独立的维度:ExplainBench对智能体的排序与广泛使用的SWE-bench Verified基准测试不同。对智能体解释质量的更深入剖析显示,解释中频繁出现问题,例如解释常常声称某个补丁是正确的,而实际上并非如此。基于这一发现,我们实现并评估了一个解释审计智能体,该智能体通过运行额外测试来验证和修正解释。该智能体改进了所有被评估智能体的解释,表明智能体生成的解释可以自动地变得更加可信。
English
Large Language Model (LLM) agents have seen rapid adoption in software engineering. As agents take a greater role in the actual generation of code, they are making larger changes, spanning tens to hundreds of lines. This makes manual review of agent results increasingly infeasible, leading developers to turn to explanations to understand enacted changes. Despite this, there are no benchmarks that evaluate the trustworthiness of agent-generated explanations. To bridge this gap, we propose ExplainBench, a benchmark to automatically evaluate explanations from coding agents. ExplainBench is based on the intuition that informative explanations should enable an LLM to correctly answer questions, allowing quantitative comparison of explanation quality between agents. With this observation, we construct a suite of questions that evaluates whether explanations accurately describe (1) the intended behavior of buggy code and (2) the effect of applying the agent patch itself. Experiments first reveal that explanation quality is a distinct axis of agent evaluation: ExplainBench ranks agents differently from the widely-used SWE-bench Verified benchmark. A deeper breakdown of explanation quality in agents shows frequent problems in explanations, such that explanations often claim that a patch is correct when it is not. Based on this insight, we implement and evaluate an explanation audit agent which runs additional tests to validate and refine explanations. This agent improved the explanations of all evaluated agents, demonstrating agent explanations can be automatically made more trustworthy.