在现实世界的软件开发中,不当或缺失的异常处理会严重影响代码的健壮性和可靠性。异常处理机制要求开发者按照高标准检测、捕获和管理异常,但许多开发者难以胜任这些任务,导致代码脆弱。这一问题在开源项目中尤为明显,并影响了整个软件生态系统的质量。为应对这一挑战,我们探索使用大型语言模型(LLMs)来改进代码中的异常处理。通过广泛分析,我们识别出三个关键问题:对脆弱代码的检测不敏感(Insensitive Detection of Fragile Code)、异常块捕获不准确(Inaccurate Capture of Exception Block)以及处理方案失真(Distorted Handling Solution)。这些问题在真实世界的代码库中普遍存在,表明健壮的异常处理实践常常被忽视或处理不当。为此,我们提出Seeker,一个受专家开发者异常处理策略启发的多智能体框架。Seeker使用多个智能体:Scanner(扫描器)、Detector(检测器)、Predator(捕食者)、Ranker(排序器)和Handler(处理器),以协助LLMs更有效地检测、捕获和解决异常。我们的工作是首个关于利用LLMs在真实开发场景中增强异常处理实践的系统性研究,为未来代码可靠性的改进提供了宝贵见解。
英文摘要:
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.
MPI(马克斯·普朗克研究所);ETH Zürich(苏黎世联邦理工学院);MIT(麻省理工学院);Harvard(哈佛大学);IIT Kharagpur(印度理工学院卡拉格普尔分校);Carnegie Mellon University(卡内基梅隆大学);University of Michigan(密歇根大学);MPI for Intelligent Systems(马克斯·普朗克智能系统研究所)
AI systems are becoming increasingly intertwined with human life. In order to effectively collaborate with humans and ensure safety, AI systems need to be able to understand, interpret and predict human moral judgments and decisions. Human moral judgments are often guided by rules, but not always. A central challenge for AI safety is capturing the flexibility of the human moral mind -- the ability to determine when a rule should be broken, especially in novel or unusual situations. In this paper, we present a novel challenge set consisting of rule-breaking question answering (RBQA) of cases th…
DiffuGuard: How Intrinsic Safety is Lost and Found in Diffusion Large Language Models
Beijing University of Posts and Telecommunications(北京邮电大学);National University of Singapore(新加坡国立大学);Nanyang Technological University(南洋理工大学);Tsinghua University(清华大学);The Chinese University of Hong Kong(香港中文大学);Squirrel Ai Learning(松鼠AI);Peking University(北京大学)
Cross-Modal Obfuscation for Jailbreak Attacks on Large Vision-Language Models
University of Science and Technology of China(中国科学技术大学);The Chinese University of Hong Kong, Shenzhen(香港中文大学(深圳));Institute of High Performance Computing, A*STAR, Singapore(新加坡A*STAR高性能计算研究所)
Safety at Scale: A Comprehensive Survey of Large Model and Agent Safety
Fudan University(复旦大学);The University of Melbourne(墨尔本大学);Singapore Management University(新加坡国立大学);Deakin University(德肯大学);Hong Kong University of Science and Technology(香港科学与技术大学);City University of Hong Kong(香港城市大学);University of Oxford(牛津大学);Chinese University of Hong Kong, Shenzhen(香港中文大学(深圳));Shanghai Jiao Tong University(上海交通大学);Nanyang Technological University(南洋理工大学);The University of Sydney(悉尼大学);Griffith University(格里菲斯大学);University of California, Santa Cruz(加州大学圣克鲁兹分校);Sea AI Lab(Sea AI实验室);Tsinghua University(清华大学);Virginia Tech(弗吉尼亚理工大学);CISPA Helmholtz Center for Information Security(CISPA海德堡信息安全部);University of Massachusetts Amherst(马萨诸塞大学阿姆赫斯特分校);Purdue University(普渡大学);Duke University(杜克大学);University of Wisconsin - Madison(威斯康星大学麦迪逊分校);RIKEN(理化学研究所);The University of Tokyo(东京大学)
Test-Time Immunization: A Universal Defense Framework Against Jailbreaks for (Multimodal) Large Language Models
NLPR & MAIS, Institute of Automation, Chinese Academy of Sciences(国家工程实验室与人工智能研究所,中国科学院);School of Artificial Intelligence, University of Chinese Academy of Sciences(中国科学院大学人工智能学院)
CODESYNC: Synchronizing Large Language Models with Dynamic Code Evolution at Scale
National Engineering Research Center for Big Data Technology and Systems(大数据技术与系统国家工程研究中心);Services Computing Technology and System Lab(服务计算技术与系统实验室);Cluster and Grid Computing Lab(集群与网格计算实验室);School of Computer Science and Technology(计算机科学与技术学院);Huazhong University of Science and Technology(华中科技大学);Wuhuan University(吴奂大学);Zhejiang University(浙江大学)