Skip to main content
QUICK REVIEW

[Paper Review] RepairAgent: An Autonomous, LLM-Based Agent for Program Repair

Islem Bouzenia, Prémkumar Dévanbu|arXiv (Cornell University)|Mar 25, 2024
AI-based Problem Solving and PlanningComputer Science13 citations
TL;DR

RepairAgent is the first autonomous, LLM-based agent for program repair that uses a dynamic prompt, a set of repairTools, and a guiding finite state machine to fix bugs, achieving 164 correct repairs on Defects4J (including 39 not fixed by prior work) at about 14 cents per bug.

ABSTRACT

Automated program repair has emerged as a powerful technique to mitigate the impact of software bugs on system reliability and user experience. This paper introduces RepairAgent, the first work to address the program repair challenge through an autonomous agent based on a large language model (LLM). Unlike existing deep learning-based approaches, which prompt a model with a fixed prompt or in a fixed feedback loop, our work treats the LLM as an agent capable of autonomously planning and executing actions to fix bugs by invoking suitable tools. RepairAgent freely interleaves gathering information about the bug, gathering repair ingredients, and validating fixes, while deciding which tools to invoke based on the gathered information and feedback from previous fix attempts. Key contributions that enable RepairAgent include a set of tools that are useful for program repair, a dynamically updated prompt format that allows the LLM to interact with these tools, and a finite state machine that guides the agent in invoking the tools. Our evaluation on the popular Defects4J dataset demonstrates RepairAgent's effectiveness in autonomously repairing 164 bugs, including 39 bugs not fixed by prior techniques. Interacting with the LLM imposes an average cost of 270,000 tokens per bug, which, under the current pricing of OpenAI's GPT-3.5 model, translates to 14 cents of USD per bug. To the best of our knowledge, this work is the first to present an autonomous, LLM-based agent for program repair, paving the way for future agent-based techniques in software engineering.

Motivation & Objective

  • Motivate automated program repair (APR) and the need for autonomous, decision-making agents beyond fixed-prompt LLM loops.
  • Introduce RepairAgent as an autonomous, tool-enabled LLM that plans, executes, and validates bug fixes.
  • Demonstrate effectiveness on Defects4J, including fixes not achieved by prior approaches, and analyze resource costs.

Proposed method

  • Define an autonomous LLM agent capable of planning and executing bug-fixing actions via a set of repair tools.
  • Introduce a dynamically updated prompt format guiding the agent through bug understanding, information gathering, and patch validation.
  • Employ a finite state machine to constrain tool usage and guide the repair process.
  • Provide a middleware to parse and map LLM outputs to tool invocations, including error-handling heuristics.
  • Utilize 14 tools (read/extract code, search/generate code, testing/patching, and control) to emulate human repair workflows.
  • Run repairs on the Defects4J dataset, comparing against three baselines (ChatRepair, ITER, SelfAPR).
Figure 1 : Overview of RepairAgent.
Figure 1 : Overview of RepairAgent.

Experimental results

Research questions

  • RQ1RQ1 How effective is RepairAgent at fixing real-world bugs?
  • RQ2RQ2 What are the costs of the approach?
  • RQ3RQ3 How does the LLM agent use the available tools?

Key findings

  • RepairAgent fixes 164 bugs in Defects4J, including 39 bugs not fixed by prior work.
  • RepairAgent achieves fixes across both v1.2 (74 correct) and v2.0 (90 correct) with 186 plausible fixes.
  • The average token cost for interaction is about 270,000 tokens per bug (≈$0.14 at GPT-3.5 pricing).
  • RepairAgent demonstrates capability across single-line, multi-line, and multi-file bugs (115 single-line, 46 multi-line, 3 multi-file).
  • Compared to ChatRepair, ITER, and SelfAPR, RepairAgent fixes a comparable total number of bugs and excels on Defects4Jv2, fixing 90 bugs where others fixed fewer.
  • The approach yields several exclusive fixes that rely on the tool set (e.g., find_similar_api_calls, generate_method_body).
Figure 2 : State machine to guide selection of tools.
Figure 2 : State machine to guide selection of tools.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.