arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.06875cs.SEcs.AI
收藏

TraceCoder: 一个基于跟踪的多智能体框架,用于自动调试LLM生成的代码

TraceCoder: A Trace-Driven Multi-Agent Framework for Automated Debugging of LLM-Generated Code

School of Computer Science and Technology, Chongqing University of Posts and Telecommunications(重庆邮电大学计算机科学与技术学院);Nanyang Technological University(南洋理工大学);Beihang University(北京航空航天大学);Southwest University(西南大学)

Jiangping Huang, Wenguang Ye, Weisong Sun, Jian Zhang, Mingyue Zhang, Yang Liu

AI总结:

TraceCoder通过多智能体框架和历史教训学习机制,提升LLM生成代码的自动调试效率和准确性。

摘要:

大型语言模型(LLMs)常常生成包含微妙但关键错误的代码,尤其是在复杂任务中。现有的自动修复方法通常依赖于表面的通过/失败信号,提供有限的程序行为视图,阻碍了精确的错误定位。此外,如果没有从先前失败中学习的方法,修复过程往往陷入重复和低效的循环。为了解决这些挑战,我们提出了TraceCoder,一个协作的多智能体框架,模拟了专家的观察-分析-修复过程。该框架首先通过诊断探针对代码进行仪器化,以捕获细粒度的运行时跟踪,从而深入洞察其内部执行。然后,它对这些跟踪进行因果分析,以准确识别失败的根本原因。这一过程进一步通过一种新的历史教训学习机制(HLLM)得到增强,该机制从先前的失败修复尝试中提炼出见解,以指导后续的修正策略并防止类似错误的再次发生。为了确保稳定收敛,回滚机制强制每个修复迭代都朝着正确解决方案的严格改进。在多个基准上的全面实验显示,TraceCoder在现有先进基线上的Pass@1准确率方面实现了高达34.43%的相对提升。消融研究验证了每个系统组件的重要性,其中仅迭代修复过程本身就贡献了65.61%的准确率提升。此外,TraceCoder在准确性和成本效率方面均显著优于领先迭代方法。

英文摘要:

Large Language Models (LLMs) often generate code with subtle but critical bugs, especially for complex tasks. Existing automated repair methods typically rely on superficial pass/fail signals, offering limited visibility into program behavior and hindering precise error localization. In addition, without a way to learn from prior failures, repair processes often fall into repetitive and inefficient cycles. To overcome these challenges, we present TraceCoder, a collaborative multi-agent framework that emulates the observe-analyze-repair process of human experts. The framework first instruments the code with diagnostic probes to capture fine-grained runtime traces, enabling deep insight into its internal execution. It then conducts causal analysis on these traces to accurately identify the root cause of the failure. This process is further enhanced by a novel Historical Lesson Learning Mechanism (HLLM), which distills insights from prior failed repair attempts to inform subsequent correction strategies and prevent recurrence of similar mistakes. To ensure stable convergence, a Rollback Mechanism enforces that each repair iteration constitutes a strict improvement toward the correct solution. Comprehensive experiments across multiple benchmarks show that TraceCoder achieves up to a 34.43\% relative improvement in Pass@1 accuracy over existing advanced baselines. Ablation studies verify the significance of each system component, with the iterative repair process alone contributing a 65.61\% relative gain in accuracy. Furthermore, TraceCoder significantly outperforms leading iterative methods in terms of both accuracy and cost-efficiency.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑