HAFixAgent: Agente de Reparación Automatizada de Programas con Conciencia Histórica
HAFixAgent: History-Aware Automated Program Repair Agent
November 2, 2025
Autores: Yu Shi, Hao Li, Bram Adams, Ahmed E. Hassan
cs.AI
Resumen
La reparación automática de programas (APR) ha girado recientemente hacia modelos de lenguaje grande y sistemas basados en agentes, aunque la mayoría de estos sistemas dependen del contexto local de instantáneas, pasando por alto el historial del repositorio. Trabajos previos demuestran que el historial del repositorio ayuda a reparar errores de una sola línea, ya que el último commit que modificó la línea con el error suele ser el que lo introdujo. En este artículo, investigamos si el historial del repositorio también puede mejorar los sistemas de APR basados en agentes a gran escala, especialmente para errores complejos de múltiples fragmentos (multi-hunk). Presentamos HAFixAgent, un Agente de Reparación de Errores Consciente del Historial que inyecta heurísticas del repositorio derivadas de 'blame' en su bucle de reparación. Un estudio preliminar de los 854 errores del mundo real de Defects4J motiva nuestro diseño, mostrando que el historial relevante para los errores está ampliamente disponible y altamente concentrado. La comparación empírica de HAFixAgent con dos líneas de base state-of-the-art muestra: (1) Efectividad: HAFixAgent mejora significativamente respecto a la línea base basada en agentes (en un 212.3%) y respecto a la línea base para múltiples fragmentos (en un 29.9%). (2) Eficiencia: el historial no aumenta significativamente los pasos del agente y mantiene costos de tokens comparables, con costos medianos notablemente más bajos para errores complejos de múltiples archivos y múltiples fragmentos. (3) Practicidad: la combinación de diferentes heurísticas históricas repara más errores, ofreciendo una compensación clara entre coste y beneficio. HAFixAgent ofrece una receta práctica para un APR agentivo consciente del historial: fundamentar el agente en el historial de control de versiones, priorizar el contexto histórico basado en diferencias (diff) e integrar heurísticas complementarias cuando sea necesario.
English
Automated program repair (APR) has recently shifted toward large language
models and agent-based systems, yet most systems rely on local snapshot
context, overlooking repository history. Prior work shows that repository
history helps repair single-line bugs, since the last commit touching the buggy
line is often the bug-introducing one. In this paper, we investigate whether
repository history can also improve agentic APR systems at scale, especially
for complex multi-hunk bugs. We present HAFixAgent, a History-Aware Bug-Fixing
Agent that injects blame-derived repository heuristics into its repair loop. A
preliminary study of all 854 real-world bugs from Defects4J motivates our
design, showing that bug-relevant history is both widely available and highly
concentrated. Empirical comparison of HAFixAgent with two state-of-the-art
baselines shows: (1) Effectiveness: HAFixAgent significantly improves over the
agent-based baseline (by 212.3%) and the multi-hunk baseline (by 29.9%). (2)
Efficiency: history does not significantly increase agent steps and keeps token
costs comparable, with notably lower median costs for complex
multi-file-multi-hunk bugs. (3) Practicality: combining different historical
heuristics repairs more bugs, offering a clear cost-benefit trade-off.
HAFixAgent offers a practical recipe for history-aware agentic APR: ground the
agent in version control history, prioritize diff-based historical context, and
integrate complementary heuristics when needed.