arXiv:2610.41097cs.SEOct 2026

Manuscript Offprint

arXiv:2610.41097

RepGen: Reproducing Deep Learning Bugs through Context-Aware Code Generation and Verification

Mehil B Shah, Mohammad Masudur Rahman, Foutse Khomh

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Mehil B Shah

Faculty of Computer Science

Dalhousie University

Halifax, Canada

shahmehil@dal.ca

Mohammad Masudur Rahman

Faculty of Computer Science

Dalhousie University

Halifax, Canada

masud.rahman@dal.ca

Foutse Khomh

Dept. of Computer & Software Eng.

Polytechnique Montréal

Montréal, Canada

foutse.khomh@polymtl.ca

Abstract—Reproducing deep learning (DL) bugs is challenging because failures can involve source code, models, data, dependencies, and execution environments. Incomplete bug reports further complicate reproduction by omitting essential details. We present REPGEN, an open-source tool for reproducing DL bugs through context-aware code generation and iterative verification. Given a bug report and repository, REPGEN explores the codebase to construct a learning-enhanced context, develops a reproduction plan, and generates candidate scripts. It refines candidates using static checks and LLM feedback to improve their correctness and relevance. When enabled, the tool prepares the execution environment, runs the script, and assesses its output against the reported failure. REPGEN provides an interactive CLI supporting local and hosted LLMs, configurable execution budgets, and inspectable artifacts, along with a GitHub Action for automated issue processing. The underlying approach reproduced 85 of 106 real-world DL bugs (80.19%). A controlled study with 27 developers showed a 23.35% improvement in reproduction success and a 56.8% reduction in reproduction time. The demonstration illustrates the workflow using a real-world input-sanitization bug. Tool: https://github.com/mehilshah/RepGen. Video: https://youtu.be/ZPhXEDfrRU.

Index Terms—bug reproduction, deep learning bugs, LLM agents, debugging

I. INTRODUCTION

Deep learning (DL)-based software systems combine source code with learned models, training data, and execution environments. Their failures can stem not only from the source code but also from the context or environment [1]. To investigate a reported failure, developers often need to reconstruct these execution conditions and reproduce the erroneous behavior. However, bug reports often miss important details, such as required dependencies, configurations, and reproduction steps, making fault reproduction a challenging task [2]. A recent study reported successful manual reproduction for only about 3% of the examined DL bugs, underscoring their inherent challenges [1].

Existing techniques aim to reproduce several types of software failures, but their assumptions do not always hold for DL systems [3]. For example, the context connected to a deep learning failure can span model architectures, training loops, data processing pipelines, and dependencies. Hence, techniques [4] that replay GUI events for bug reproduction are not applicable to DL bugs (i.e., no graphical interface). Many DL bugs also manifest as incorrect output or abnormal training behavior without an exception [5]. Hence, techniques relying only on program crashes or explicit error messages cannot reproduce such DL bugs. Large language models (LLMs) have found numerous applications in software engineering and can be used to generate reproduction scripts against a bug report. However, a generated script (a.k.a., code snippet) may hallucinate about a project-specific API, omit a required model initialization step, or fail because of an incompatible dependency version rather than the reported bug [3]. Hence, to reproduce a DL effectively, we need a candidate that captures the project-specific context and verifies that its behaviour matches the erroneous behaviour described in the report.

In this paper, we present REPGEN, a novel agentic solution that helps reproduce deep learning bugs through context-aware code generation and verification using LLM-based agents. Given a bug report and its repository, REPGEN navigates the repository to find relevant classes, methods, training loops, and dependencies, and constructs a learning-enhanced context. Then, it leverages the context not only to formulate a reproduction plan but also to generate candidate code. Our tool then iteratively refines the candidate based on four types of verification feedback, including syntax, code quality, semantic relevance, and approximate failure behaviour. Once the candidate code (i.e., reproduction script) is finalized and execution is enabled, REPGEN prepares the execution environment by installing the required dependencies, runs the candidate and captures its execution output. Finally, it compares this output with the reported behaviours and generates a detailed reproduction report with diagnostic evidence for developer review. Our tool can be accessed through an interactive command-line interface (CLI) and a GitHub Action.

To summarize, REPGEN equips its users with the following capabilities during DL fault reproduction:

(a) Script generation from bug reports: Users can provide a bug report and its repository to obtain a reproduction script without manually locating relevant code or writing the script from scratch.

(b) Environment setup and script execution: Users can ask REPGEN to install required dependencies, run the generated script, and assess whether its output matches the reported failure.

(c) Flexible configuration and access: Users can select local or hosted models, set exploration and retry limits, and run the tool through an interactive CLI or a GitHub Action.

(d) Inspectable results: Users can review saved scripts, verification reports, and execution logs to understand reproduction outcomes, repeat executions, and investigate unsuccessful attempts.