Debug or Regenerate? Test-Guided Selection for LLM Code Repair

Atharv Kulkarni, Archiki Prasad, Vivek Srikumar, Elias Stengel-Eskin, Hyunji Lee, Mohit Bansal


Abstract
Large language models (LLMs) are increasingly used as coding assistants, but the programs they generate often fail. Such failures can be addressed by debugging the existing implementation or regenerating a new solution from the problem specification, with existing repair workflows typically defaulting to debugging. We find that the effectiveness of debugging and regeneration depends strongly on initial program quality, suggesting that no single repair strategy is universally optimal. Motivated by this observation, we present PATSSEL (Program-Adaptive Test-guided Repair Strategy Selection), a test-guided repair selection framework that dynamically chooses between debugging and regeneration. Rather than committing to a single repair strategy, PATSSEL generates debugged and regenerated candidates for each buggy program, evaluates them using generated verifier tests, and selects the stronger candidate, leveraging the complementary strengths of debugging and regeneration. Experiments on LeetCodeDataset, LiveCodeBench, and HE+Fix show that PATSSEL achieves average absolute improvements of 2.7% with Qwen3-8B and 3.2% with Llama3-8B over the best single-strategy baselines under the same inference compute budget and routing using gold unit tests. The gains persist across repair models, routing models, and stronger debugger models. Further analysis shows that PATSSEL benefits from the complementary strengths of debugging and regeneration, highlighting the importance of adaptive strategy selection for reliable LLM-based code repair.
Anthology ID:
2026.findings-emnlp.2173
Volume:
Findings of the Association for Computational Linguistics: EMNLP 2026
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
Findings
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
46494–46508
Language:
URL:
https://aclanthology.org/2026.findings-emnlp.2173/
DOI:
Bibkey:
Cite (ACL):
Atharv Kulkarni, Archiki Prasad, Vivek Srikumar, Elias Stengel-Eskin, Hyunji Lee, and Mohit Bansal. 2026. Debug or Regenerate? Test-Guided Selection for LLM Code Repair. In Findings of the Association for Computational Linguistics: EMNLP 2026, pages 46494–46508, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
Debug or Regenerate? Test-Guided Selection for LLM Code Repair (Kulkarni et al., Findings 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.findings-emnlp.2173.pdf