arXiv:2412.11713cs.CLcs.SE2024-12被引 4

用多智能体框架提升代码异常处理能力,让LLM更懂如何安全写代码。

Seeker: Towards Exception Safety Code Generation with Intermediate Language Agents Framework

  • 设计五智能体协作框架,分步解析异常问题
  • 在真实项目中检测出高发异常处理缺陷
  • 适合想提升代码健壮性的开发者和团队

在真实软件开发中,不当或缺失的异常处理会严重损害代码的鲁棒性和可靠性。异常处理要求开发者按高标准检测、捕获和管理异常,但许多开发者难以胜任,导致代码脆弱。这一问题在开源项目中尤为突出,影响整个软件生态质量。为解决此问题,我们探索使用大语言模型(LLMs)改进代码中的异常处理。通过广泛分析,我们识别出三大关键问题:对脆弱代码的敏感度不足、异常块捕获不准确、处理方案失真。这些问题在真实仓库中普遍存在,表明稳健的异常处理实践常被忽视或错误执行。为此,我们提出Seeker,一个受专家开发策略启发的多智能体框架。该框架包含Scanner、Detector、Predator、Ranker和Handler五个智能体,协助LLM更有效地检测、捕获并解决异常。本工作是首次系统性研究利用LLMs提升真实开发场景中异常处理实践的研究,为未来代码可靠性改进提供了重要洞见。

原文摘要 · Abstract (English)

In real world software development, improper or missing exception handling can severely impact the robustness and reliability of code. Exception handling mechanisms require developers to detect, capture, and manage exceptions according to high standards, but many developers struggle with these tasks, leading to fragile code. This problem is particularly evident in open-source projects and impacts the overall quality of the software ecosystem. To address this challenge, we explore the use of large language models (LLMs) to improve exception handling in code. Through extensive analysis, we identify three key issues: Insensitive Detection of Fragile Code, Inaccurate Capture of Exception Block, and Distorted Handling Solution. These problems are widespread across real world repositories, suggesting that robust exception handling practices are often overlooked or mishandled. In response, we propose Seeker, a multi-agent framework inspired by expert developer strategies for exception handling. Seeker uses agents: Scanner, Detector, Predator, Ranker, and Handler to assist LLMs in detecting, capturing, and resolving exceptions more effectively. Our work is the first systematic study on leveraging LLMs to enhance exception handling practices in real development scenarios, providing valuable insights for future improvements in code reliability.

异常处理多智能体LLM编码代码质量

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