25 Mar 2024 | Islem Bouzenia, Premkumar Devanbu, Michael Pradel
**RepairAgent: An Autonomous, LLM-Based Agent for Program Repair**
This paper introduces RepairAgent, a novel approach to automated program repair (APR) that leverages a large language model (LLM) as an autonomous agent. Unlike existing deep learning-based approaches that use fixed prompts or feedback loops, RepairAgent treats the LLM as an agent capable of planning and executing actions to fix bugs by invoking suitable tools. The key contributions of RepairAgent include a set of tools for program repair, a dynamically updated prompt format, and a finite state machine to guide the agent in invoking tools.
**Key Components:**
1. **LLM Agent:** The core component, trained on natural language and source code, queries the LLM repeatedly with a dynamically updated prompt.
2. **Tools:** A set of 14 tools designed to cover different steps in bug fixing, such as reading code, searching the code base, and applying patches.
3. **Middleweight:** Orchestrates communication between the LLM and tools, parsing LLM outputs, calling tools, and updating the prompt.
**Evaluation:**
The effectiveness of RepairAgent is evaluated on the Defects4J dataset, fixing 164 bugs, including 39 that were not fixed by prior techniques. The approach imposes an average cost of 270,000 tokens per bug, equivalent to 14 cents under OpenAI's GPT-3.5 pricing.
**Contributions:**
- The first autonomous, LLM-based agent for program repair.
- A novel prompt format and a finite state machine to guide the LLM.
- A set of tools for bug repair, enhancing the agent's capabilities.
**Conclusion:**
RepairAgent demonstrates the potential of LLM-based agents in automated program repair, paving the way for future agent-based techniques in software engineering.**RepairAgent: An Autonomous, LLM-Based Agent for Program Repair**
This paper introduces RepairAgent, a novel approach to automated program repair (APR) that leverages a large language model (LLM) as an autonomous agent. Unlike existing deep learning-based approaches that use fixed prompts or feedback loops, RepairAgent treats the LLM as an agent capable of planning and executing actions to fix bugs by invoking suitable tools. The key contributions of RepairAgent include a set of tools for program repair, a dynamically updated prompt format, and a finite state machine to guide the agent in invoking tools.
**Key Components:**
1. **LLM Agent:** The core component, trained on natural language and source code, queries the LLM repeatedly with a dynamically updated prompt.
2. **Tools:** A set of 14 tools designed to cover different steps in bug fixing, such as reading code, searching the code base, and applying patches.
3. **Middleweight:** Orchestrates communication between the LLM and tools, parsing LLM outputs, calling tools, and updating the prompt.
**Evaluation:**
The effectiveness of RepairAgent is evaluated on the Defects4J dataset, fixing 164 bugs, including 39 that were not fixed by prior techniques. The approach imposes an average cost of 270,000 tokens per bug, equivalent to 14 cents under OpenAI's GPT-3.5 pricing.
**Contributions:**
- The first autonomous, LLM-based agent for program repair.
- A novel prompt format and a finite state machine to guide the LLM.
- A set of tools for bug repair, enhancing the agent's capabilities.
**Conclusion:**
RepairAgent demonstrates the potential of LLM-based agents in automated program repair, paving the way for future agent-based techniques in software engineering.