Table of Contents
Fetching ...

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

Xuanming Zhang, Yuxuan Chen, Yiming Zheng, Zhexin Zhang, Yuan Yuan, Minlie Huang

TL;DR

Open-source code often suffers from fragile exception handling, undermining robustness. The authors propose Seeker, a five-agent intermediate language framework combined with Common Exception Enumeration and a Deep-RAG retrieval strategy to guide robust exception handling in code generation. By decomposing handling into Planner, Detector, Predator, Ranker, and Handler and anchoring decisions to CEE, Seeker standardizes and generalizes exception strategies across inheritance hierarchies and long-tail types. Empirical results on 750 Java snippets and additional benchmarks show substantial gains in detection accuracy, coverage, and code quality, establishing a new state-of-the-art in exception handling for real development scenarios.

Abstract

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.

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

TL;DR

Open-source code often suffers from fragile exception handling, undermining robustness. The authors propose Seeker, a five-agent intermediate language framework combined with Common Exception Enumeration and a Deep-RAG retrieval strategy to guide robust exception handling in code generation. By decomposing handling into Planner, Detector, Predator, Ranker, and Handler and anchoring decisions to CEE, Seeker standardizes and generalizes exception strategies across inheritance hierarchies and long-tail types. Empirical results on 750 Java snippets and additional benchmarks show substantial gains in detection accuracy, coverage, and code quality, establishing a new state-of-the-art in exception handling for real development scenarios.

Abstract

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.

Paper Structure

This paper contains 51 sections, 9 figures, 8 tables.

Figures (9)

  • Figure 1: Overview of the Intermediate Language (IL) agents (Right) Compared with Traditional Code Generation Approaches (Left) in Exception-Safe Code Generation Tasks The Seeker framework leverages IL agents to perform dynamic analysis, transformation, and optimization of code to ensure robust exception handling. In contrast, traditional approaches often rely on static error-handling routines and lack comprehensive analysis for exception safety.
  • Figure 2: (a) Comparison of LLM and human exception handling performance as prompts evolve from General prompting (Prompt1), to Coarse-grained Knowledge-driven (Prompt2), Fine-grained Knowledge-driven (Prompt3), and Fine-grained Knowledge-driven with explicit handling logic (Prompt4). Results show a clear mitigation effect, where increasingly detailed and context-rich prompts significantly improve handling quality. (b) How expert human developers integrate programming expertise, domain knowledge, fine-grained exception hierarchies, and adaptive strategies to achieve robust exception management.
  • Figure 3: Comprehensive Workflow of Seeker. Seeker orchestrates the automated exception handling process through the seamless collaboration of five specialized agents: Planner, Detector, Predator, Ranker, and Handler. The colored circles within the workflow illustrate the flow of information and interactions among the agents, highlighting how each component activates and contributes to the overall exception handling process. This integrated approach ensures that Seeker delivers highly reliable and maintainable exception handling solutions, significantly improving code robustness and developer productivity.
  • Figure 4: An overview of the CEE construction process. The diagram illustrates how authoritative documentation (JDK), enterprise-level best practices, and real-world code repositories are integrated and refined. Each exception node is enriched with Scenario, Property, and Handling Logic. This framework is further optimized through LLM-based in-context learning and iterative fine-tuning, ultimately providing a reliable, structured reference (CEE) to enhance exception handling in generated code.
  • Figure 5: Comparison of Performance Stability Across Baselines and Our Method over Varying Conditions. The top set of curves illustrates the performance metrics over time (2019 to 2024) across different baselines and our method. The bottom set displays performance across increasing function counts.
  • ...and 4 more figures