NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Towards Effectively Leveraging Execution Traces for Program Repair with Code LLMs

Mirazul Haque, Petr Babkin, Farima Farmahinifarahani, Manuela Veloso · DOI

Introduction

Automatic Program Repair (APR) is a critical field in software engineering aimed at fixing bugs without human intervention. While Large Language Models (LLMs) like GPT-4 have demonstrated remarkable proficiency in code generation and debugging, their primary strength lies in static analysis—interpreting code as text. However, many software bugs are rooted in dynamic behavior, such as unexpected variable modifications or control flow deviations that only manifest during execution.

To bridge this gap, researchers have explored providing LLMs with "execution traces" (step-by-step logs of program runtime). This paper investigates whether these traces actually improve repair outcomes or if they simply overwhelm the model's context window with irrelevant data.

The Complexity Penalty

A primary finding of the study is the "Complexity Penalty." By analyzing the relationship between trace characteristics and repair success, the researchers identified a clear inverse correlation: as the length of the execution trace and the number of variable changes increase, the likelihood of an LLM producing a correct fix decreases.

Figure 4: Distribution of trace length and variable changes for correct vs. incorrect programs across three datasets.

As shown in the figure above, incorrect programs consistently exhibit higher median trace lengths and more frequent variable changes compared to correctly repaired programs. This suggests that raw execution data often acts as "noise," cluttering the prompt and hindering the model's reasoning capabilities.

Methodology: The "Summarize-then-Repair" Approach

To mitigate the complexity penalty, the researchers proposed a summarize-then-repair workflow. Instead of feeding raw, verbose logs (generated by tools like PySnooper) directly into the repair prompt, they utilize a high-reasoning model (GPT-4-32k) to condense the runtime data into an LLM-Optimized Trace (OPT).

Figure 5: The proposed pipeline for generating optimized traces and confidence scores to guide the repair process.

This pipeline involves two parallel prompts: one to summarize the trace and another to generate a confidence score. If the model's confidence in its understanding of the trace is low, the system can route the request differently. This structured summary acts as a diagnostic bridge, providing the repair model with high-level insights rather than raw line-by-line logs.

Key Results and Insights

The study evaluated several strategies across benchmarks like Refactory, RunBugRun, and HumanEval-Java. Key findings include:

  • OPT Traces Outperform Baselines: On the HumanEval-Java dataset, GPT-4 using optimized traces achieved a Correct Fix Accuracy (CFA) of 0.572, significantly higher than the standard error-only baseline (0.511).
  • The "Mental Execution" Gap: Probing studies revealed that even advanced models like GPT-4 struggle to perfectly predict a program's execution trace from scratch, matching ground truth only 15-50% of the time. This confirms that providing real runtime data offers unique information that the model cannot reliably infer on its own.
  • Prompting vs. Fine-Tuning: While the researchers fine-tuned smaller models (e.g., DeepSeek-Coder-1.3B) on trace data, prompting a high-reasoning model like GPT-4 remained superior, suggesting that general reasoning ability is currently more vital for APR than specialized trace-based training on small datasets.

Conclusion

Execution traces are not a silver bullet for program repair; when used naively, they can degrade performance due to information overload. However, by employing LLM-driven summarization to create optimized traces, researchers can consistently improve repair accuracy across diverse datasets. Future work will focus on scaling these techniques to larger, multi-file codebases and reducing the computational cost of the summarization step.

Summary updated

BibTeX
@misc{haque2025towards,
  author = {Mirazul Haque and Petr Babkin and Farima Farmahinifarahani and Manuela Veloso},
  title = {{Towards Effectively Leveraging Execution Traces for Program Repair with Code LLMs}},
  year = {2025},
  eprint = {2505.04441},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.04441},
}
Figure