AEGIS: An Agent-based Framework for General Bug Reproduction from Issue Descriptions

Xinchen Wang, Pengfei Gao, Xiangxin Meng, Chao Peng, Ruida Hu, Yun Lin, Cuiyun GaoarXiv 2024

Abstract

In software maintenance, bug reproduction is essential for effective fault localization and repair. Manually writing reproduction scripts is a time-consuming task with high requirements for developers. Hence, automation of bug reproduction has increasingly attracted attention from researchers and practitioners. However, the existing studies on bug reproduction are generally limited to specific bug types such as program crashes, and hard to be applied to general bug reproduction. In this paper, considering the superior performance of agent-based methods in code intelligence tasks, we focus on designing an agent-based framework for the task. Directly employing agents would lead to limited bug reproduction performance, due to entangled subtasks, lengthy retrieved context, and unregulated actions. To mitigate the challenges, we propose an Automated gEneral buG reproductIon Scripts generation framework, named AEGIS, which is the first agent-based framework for the task. AEGIS mainly contains two modules: (1) A concise context construction module, which aims to guide the code agent in extracting structured information from issue descriptions, identifying issue-related code with detailed explanations, and integrating these elements to construct the concise context; (2) A FSM-based multi-feedback optimization module to further regulate the behavior of the code agent within the finite state machine (FSM), ensuring a controlled and efficient script generation process based on multi-dimensional feedback. Extensive experiments on the public benchmark dataset show that AEGIS outperforms the state-of-the-art baseline by 23.0% in F->P metric. In addition, the bug reproduction scripts generated by AEGIS can improve the relative resolved rate of Agentless by 12.5%.

Introduction

Bug reproduction—the process of creating a script that triggers a reported software failure—is a critical prerequisite for effective debugging and automated program repair. A successful reproduction script fails on the buggy version of the code and passes once the fix is applied. Despite its importance, manual reproduction is labor-intensive and requires significant domain expertise.

While Large Language Models (LLMs) have shown promise in code intelligence, applying them to general bug reproduction remains difficult. Existing automated tools often struggle with the complexity of real-world issue descriptions, which are frequently cluttered with irrelevant logs and conversational noise. AEGIS (Automated gEneral buG reproductIon Scripts) is designed to bridge this gap, providing a structured, agent-based approach to transform messy GitHub issues into executable reproduction scripts.

Challenges in Automated Bug Reproduction

Directly deploying LLM agents for reproduction tasks typically results in poor performance due to three primary obstacles:

  1. Entangled Subtasks: Without a clear workflow, agents often oscillate between searching for files and writing code before they have fully understood the bug's logic.
  2. Context Drowning: Issue descriptions are often "noisy," containing environment details and logs that distract the model. Feeding this raw context into an LLM leads to degraded reasoning.
  3. Unregulated Actions: Agents may hallucinate success, claiming a bug is reproduced when a script fails for the wrong reason (e.g., a syntax error rather than the logic error described in the issue).

The AEGIS Framework

AEGIS addresses these challenges through two core modules designed to regulate agent behavior and refine the information they process.

Concise Context Construction (CCC)

Rather than providing the agent with a raw data dump, the CCC module distills the issue description into a structured format. It identifies the "Current Result" versus the "Expected Result" and extracts specific, relevant code snippets. Most importantly, it generates relevance explanations—textual justifications that explain why a specific piece of code is related to the reported bug. This ensures the agent focuses on the most critical parts of the codebase.

FSM-based Multi-feedback Optimization (FMO)

To prevent unregulated actions, AEGIS employs a Finite State Machine (FSM) that forces the agent to follow a strict operational sequence: Create → Execute → Self-Verify → External-Verify → Modify → Restart.

  • Multi-dimensional Feedback: The agent receives feedback from syntax checkers and runtime error messages.
  • The Referee: A separate LLM instance acts as an "External-Verify" gate. This referee evaluates whether the reproduction script truly captures the essence of the bug or if it is failing due to unrelated environment issues.
  • Ranking and Selection: AEGIS generates multiple candidate scripts and prioritizes "Double-verified" scripts—those that have passed both the agent’s internal checks and the referee’s external validation.

Experimental Evaluation

AEGIS was evaluated using SWE-bench Lite, a benchmark consisting of 300 real-world GitHub issues from 12 major Python open-source repositories, including Django, scikit-learn, and Flask.

Key Results

  • Superior Performance: AEGIS achieved a 36.0% Fail-to-Pass (F→P) rate, a significant improvement over the state-of-the-art baseline (AgentBaseline), which achieved only 13.0%. This represents a 23.0% absolute gain in reproduction success.
  • Downstream Impact: The utility of AEGIS extends beyond reproduction. When the generated scripts were used to assist Agentless (a bug-fixing tool), the bug-resolution rate improved from 27.3% to 30.7%, a 12.5% relative boost.
  • Robustness: The multi-feedback loop allows AEGIS to self-correct. Even when the initial code search was imperfect, the FSM-guided optimization enabled the agent to refine its approach and successfully reproduce the bug.

Insights and Discussion

The success of AEGIS highlights several key principles in agent-based software engineering:

  • Constraints Improve Creativity: By restricting the agent’s freedom through an FSM, AEGIS prevents common LLM failure modes like task-switching and hallucination.
  • Context Quality Over Quantity: Stripping away irrelevant logs and focusing on structured summaries significantly improves the reasoning capabilities of the underlying model.
  • Fresh Starts: The research found that generating a clean, standalone reproduction script (reproduce.py) is generally more effective than attempting to modify existing, complex test suites.

Conclusion and Future Work

AEGIS represents the first agent-based framework specifically designed for general bug reproduction. By combining concise context construction with a regulated state machine, it sets a new state-of-the-art on the SWE-bench Lite benchmark. While currently focused on Python, the underlying logic of AEGIS is language-agnostic. Future work will explore extending the framework to more verbose languages like Java and C++, as well as handling complex bugs that require specific environment configurations.

Summary updated

BibTeX
@misc{wang2024aegis,
  author = {Xinchen Wang and Pengfei Gao and Xiangxin Meng and Chao Peng and Ruida Hu and Yun Lin and Cuiyun Gao},
  title = {{AEGIS: An Agent-based Framework for General Bug Reproduction from Issue Descriptions}},
  year = {2024},
  eprint = {2411.18015},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.18015},
}
Figure