PATCHAGENT: A Practical Program Repair Agent Mimicking Human Expertise

Zheng Yu, Ziyi Guo, Yuhang Wu, and Jiahao Yu, Northwestern University; Meng Xu, University of Waterloo; Dongliang Mu, Independent Researcher; Yan Chen and Xinyu Xing, Northwestern University

Automated program repair (APR) techniques, which aim to triage and fix software bugs autonomously, have emerged as powerful tools against vulnerable code. Recent advancements in large language models (LLMs) have further shown promising results when applied to APR, especially on patch generation. However, without effective fault localization and patch validation, APR tools specialized in patching alone cannot handle a more practical and end-to-end setting—given a concrete input that triggers a vulnerability, how to patch the program without breaking existing tests?

In this paper, we introduce PatchAgent, a novel LLM-based APR tool that seamlessly integrates fault localization, patch generation, and validation within a single autonomous agent. PatchAgent employs a language server, a patch verifier, and interaction optimization techniques to mimic human-like reasoning during vulnerability repair. Evaluated on a dataset of 178 real-world vulnerabilities, PatchAgent successfully repairs over 90% of the cases, outperforming state-of-the-art APR tools where applicable. Our ablation study further offers insights into how various interaction optimizations contribute to PatchAgent's effectiveness.

Category: 
Long Presentation

Open Access Media

USENIX is committed to Open Access to the research presented at our events. Papers and proceedings are freely available to everyone once the event begins. Any video, audio, and/or slides that are posted after the event are also free and open to everyone. Support USENIX and our commitment to Open Access.

BibTeX
@inproceedings {307834,
author = {Zheng Yu and Ziyi Guo and Yuhang Wu and Jiahao Yu and Meng Xu and Dongliang Mu and Yan Chen and Xinyu Xing},
title = {{PATCHAGENT}: A Practical Program Repair Agent Mimicking Human Expertise},
booktitle = {34th USENIX Security Symposium (USENIX Security 25)},
year = {2025},
isbn = {978-1-939133-52-6},
address = {Seattle, WA},
pages = {4381--4400},
url = {https://www.usenix.org/conference/usenixsecurity25/presentation/yu-zheng},
publisher = {USENIX Association},
month = aug
}