寻求者:基于中间语言代理框架实现异常安全代码生成

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

December 16, 2024
作者: Xuanming Zhang, Yuxuan Chen, Yiming Zheng, Zhexin Zhang, Yuan Yuan, Minlie Huang
cs.AI

摘要

在现实世界的软件开发中,不当或缺失的异常处理可能严重影响代码的健壮性和可靠性。异常处理机制要求开发人员根据高标准检测、捕获和管理异常,但许多开发人员在这些任务上遇到困难,导致代码脆弱。这个问题在开源项目中尤为明显,并影响软件生态系统的整体质量。为了解决这一挑战,我们探讨了使用大型语言模型(LLMs)来改进代码中的异常处理。通过广泛分析,我们确定了三个关键问题:对脆弱代码的敏感度不足、异常块捕获不准确以及处理方案扭曲。这些问题在现实世界的代码库中普遍存在,表明健壮的异常处理实践经常被忽视或处理不当。为此,我们提出了Seeker,这是一个受到专业开发人员异常处理策略启发的多代理框架。Seeker使用代理:Scanner、Detector、Predator、Ranker和Handler来协助LLMs更有效地检测、捕获和解决异常。我们的工作是首个系统研究如何利用LLMs来增强现实开发场景中的异常处理实践,为未来改进代码可靠性提供了宝贵的见解。
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.

Summary

AI-Generated Summary

PDF52December 18, 2024