- The paper presents a novel LLM-powered APR system that integrates fine-grained static and dynamic program contexts to improve repair accuracy.
- It employs a sequential, question-driven diagnostic process mimicking human debugging for targeted fault localization and iterative patch synthesis.
- Empirical evaluations on Defects4J and RWB benchmarks demonstrate significant gains in unique and correct repairs over previous LLM-based methods.
PracRepair: LLM-Empowered Automated Program Repair Inspired by Human-Like Debugging Practices
Motivation and Problem Identification
Current LLM-based Automated Program Repair (APR) techniques predominantly leverage static program contexts, coarse validation feedback, or error messages for patch synthesis. This paradigm underutilizes dynamic execution signals, which are essential for understanding program failure and behavioral discrepancies pre- and post-repair. Developers, by contrast, utilize both static and dynamic information in iterative, question-driven diagnosis and interactive refinement loops, focusing on execution traces, code dependencies, and precise state changes to converge to correct repairs. The paper identifies three fundamental limitations of earlier LLM-based APR approaches: (1) overwhelming and noisy failure-execution traces, (2) static and dynamic context that is not inherently self-explanatory, and (3) the reduction of patch validation to simple pass/fail outcomes with minimal behavioral diagnostic value.
This motivates the architectural choices and workflow in PracRepair, which reframes the repair process to more closely follow human debugging strategies. A concrete motivating example based on a real-world bug is provided, demonstrating how the interplay of code context, targeted questions on execution behavior, and feedback from failed patches leads to an accurate repair—contrasting sharply with purely static input-based approaches.

Figure 1: A motivating bug-fix instance underlining the deficiency of static-context-only repair and motivating dynamic context integration and question-driven refinement.
Framework Design and Algorithmic Structure
PracRepair is a comprehensive, fully automated LLM-based APR system comprising three main stages:
- Static-Dynamic Context Construction: The system builds a context composite by statically analyzing the source code and dynamically collecting fine-grained execution traces from failing test runs, enabling targeted diagnosis without overloading the prompt context window. Static context is derived via Code Property Graph (CPG) construction, capturing AST, CFG, and data-dependence links. Dynamic execution evidence is gathered through bytecode instrumentation, focusing on in-scope variable values, branch outcomes, and statement-level traces.
- Question-Driven Failure Diagnosis: Rather than direct patch synthesis, PracRepair initiates a sequential, model-in-the-loop diagnostic process. At each step, the LLM is prompted to formulate a single targeted question (e.g., factual, causal, or repair-related) about failure or state evolution, retrieve relevant evidence via a unified interface, and append the Q/A pair to a structured diagnostic history. This loop continues until a termination condition is met (diagnosis budget or no further uncertainty), at which point an explicit, structured repair hypothesis—comprising faulty behavior, evidence, root cause, and modification suggestion—is generated.
- Feedback-Guided Patch Refinement: Patch generation is hypothesis-driven: based on diagnostic synthesis rather than purely on observed symptoms. Patch validation is not a binary check but involves extracting diagnostic, code diff, and trace diff feedback, which is then reintegrated into the next diagnosis-refinement cycle. This enables precise localization of patch-induced behavioral divergences and systematic convergence toward correct fixes.

Figure 2: High-level PracRepair framework, interleaving on-demand static-dynamic evidence retrieval, sequential question-answer diagnosis, and iterative feedback-driven patch refinement.
Empirical Evaluation and Quantitative Analysis
The evaluation is conducted primarily on Defects4J v1.2 and v2.0 (Java) and RWB benchmarks, encompassing thousands of real-world bugs, with both perfect and relaxed fault localization settings. Comparison is performed against a broad spectrum of established APR baselines—template-based, learning-based, and LLM-driven variants (e.g., TBar, SelfAPR, RepairAgent, ReInFix). Performance is assessed using semantically correct patches and plausible patch counts.
Key empirical claims include:
- With GPT-3.5, PracRepair achieves 139/136 correct repairs on Defects4J v1.2/v2.0; with GPT-4o, these rise to 162/171. PracRepair consistently outperforms all SOTA LLM-based approaches (e.g., ReInFix, ChatRepair, ThinkRepair) in both plausibility and correctness. Notably, under GPT-4o, the improvement over ReInFix is 16–26 additional correct fixes.
- The framework achieves 75 (GPT-3.5) and 93 (GPT-4o) correct fixes uniquely, not repaired by any recent LLM-based baseline. This indicates substantial complementarity to existing techniques.
- Effectiveness is robust across diverse scenarios—including single-function, single-hunk, single-line, and, notably, multi-function bugs—where the latter tend to be ignored or poorly handled by prior APR paradigms.
- Ablation studies reveal that all three mechanisms (context integration, question-driven diagnosis, feedback-guided refinement) contribute accumulatively to performance. Removal of any core module results in a marked drop in correct repair count.
- On unseen RWB benchmarks and under varying foundation models (GPT-4, DeepSeek, Llama-3), PracRepair maintains best-in-class or tied-best repair rates, highlighting model robustness and generalizability.


Figure 3: Venn diagram quantifying unique correct repairs by PracRepair vis-Ã -vis SOTA LLM-based APRs (Defects4J V1.2/V2.0).

Figure 4: Impact of increasing the number of feedback-driven refinement rounds on plausible and correct patch yield.
Practical and Theoretical Implications
The systematic integration of dynamic execution traces and diagnostics into the LLM prompt context establishes that program repair benefits markedly from execution-aware, modular, human-inspired workflows. Simply augmenting LLM prompts with static context or coarse runtime errors is insufficient for robust APR, especially for multi-site or non-localized faults. The strong gains in unique correct repairs and robustness to imperfect fault localization further support the deployment of similar multi-stage, evidence-driven frameworks in industrial and production settings.
On the theoretical side, the architecture bridges agent-based LLM prompting and traditional debugging methodologies, demonstrating that jointly reasoning over code structure, execution behavior, and directed Q/A can alleviate both prompt budget constraints and reasoning failures observed in generic large models. The framework also sets a precedent for leveraging agentic LLM operation and tool interaction beyond passive context ingestion.
Cost-wise, PracRepair’s interaction design allows strong repair performance at competitive token/money use (e.g., <$0.05/bug with GPT-3.5).
Future Directions
The demonstrated efficacy and generalizability of PracRepair suggest several clear trajectories:
- Extension to additional languages and repair specifications, including security, performance, and type correctness.
- More comprehensive integration of multi-modality debugging evidence (e.g., graphical stack analyses, annotated test executions).
- Embedding richer, possibly user-interpretable, reasoning chains to synergize automated and human-in-the-loop debugging workflows.
- Further reduction in interaction cost via more context-aware selective trace aggregation and QA prioritization.
Conclusion
PracRepair presents a robust, empirically-validated system for LLM-powered Automated Program Repair, explicitly inspired by human diagnosis and debugging workflows. The architecture's use of targeted static-dynamic evidence gathering, modular question-answer reasoning, and structured feedback-driven patch synthesis is validated to outperform prior SOTA methods, particularly in challenging settings and with weaker LLMs. These findings underscore the necessity to jointly exploit dynamic runtime evidence and structured reasoning in high-performance APR systems and inform future theoretical and practical advances in LLM-based software engineering research.