ChatPaper.aiChatPaper

HAFixAgent: Agente de Reparação Automática de Programas com Consciência Histórica

HAFixAgent: History-Aware Automated Program Repair Agent

November 2, 2025
Autores: Yu Shi, Hao Li, Bram Adams, Ahmed E. Hassan
cs.AI

Resumo

A reparação automática de programas (APR) tem recentemente migrado para modelos de linguagem de grande escala e sistemas baseados em agentes, contudo, a maioria dos sistemas depende de contexto de instantâneo local, negligenciando o histórico do repositório. Trabalhos anteriores demonstram que o histórico do repositório auxilia na reparação de *bugs* de linha única, uma vez que o último *commit* que tocou na linha problemática é frequentemente aquele que introduziu o erro. Neste artigo, investigamos se o histórico do repositório também pode melhorar sistemas de APR agentivos em escala, especialmente para *bugs* complexos de múltiplos *hunks*. Apresentamos o HAFixAgent, um Agente de Correção de *Bugs* Consciente do Histórico que injeta heurísticas de repositório derivadas de *blame* no seu ciclo de reparação. Um estudo preliminar de todos os 854 *bugs* do mundo real do Defects4J motiva o nosso desenho, mostrando que o histórico relevante para o *bug* está amplamente disponível e altamente concentrado. A comparação empírica do HAFixAgent com duas *baselines* state-of-the-art mostra: (1) **Eficácia**: O HAFixAgent melhora significativamente em relação à *baseline* baseada em agente (em 212,3%) e à *baseline* para múltiplos *hunks* (em 29,9%). (2) **Eficiência**: o histórico não aumenta significativamente os passos do agente e mantém os custos de *tokens* comparáveis, com custos medianos notavelmente mais baixos para *bugs* complexos de múltiplos ficheiros e múltiplos *hunks*. (3) **Praticidade**: combinar diferentes heurísticas históricas repara mais *bugs*, oferecendo uma clara relação custo-benefício. O HAFixAgent oferece uma receita prática para APR agentivo consciente do histórico: fundamentar o agente no histórico de controlo de versões, priorizar o contexto histórico baseado em *diff* e integrar heurísticas complementares quando necessário.
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.
PDF42February 8, 2026