arXiv:2608.22284cs.SEAug 2026

Manuscript Offprint

arXiv:2608.22284

Learning from the Test: Self-Referential Differential Testing for Deep RL Agents

Junda He, Jieke Shi, Zhou Yang, Mingfei Cheng, David Lo

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

JUNDA HE, Singapore Management University, Singapore

JIEKE SHI, Singapore Management University, Singapore

ZHOU YANG, University of Alberta, Canada and Canada CIFAR AI Chair, Amii, Canada

MINGFEI CHENG, Singapore Management University, Singapore

DAVID LO, Singapore Management University, Singapore

Deep Reinforcement Learning (DRL) has achieved significant success in complex decision-making problems. As DRL systems are increasingly deployed in real-world applications, ensuring their quality and reliability is paramount. Current works primarily focus on detecting safety-critical failures, often neglecting policy optimality, which can lead to reduced efficiency, user distrust, and economic losses. This oversight, compounded by the inherent “testing oracle problem” for optimality, leaves a significant gap in comprehensively evaluating DRL systems. To address this gap, we propose DELTA (Differential Testing for DRL Agents), a novel and comprehensive framework that automatically identifies both safety-critical and optimality bugs in DRL agents. DELTA employs a two-phase approach: (1) Safety Testing, where the Agent Under Test (AUT) is evaluated for catastrophic failures while collecting data from its decision-making policy, and (2) Optimality Testing, where this collected data from the prior phase is used to train a challenger agent via Offline Reinforcement Learning. Differential testing is then performed by comparing the challenger agent against the AUT; instances where the challenger achieves higher cumulative rewards indicate optimality issues in the AUT. We demonstrate DELTA’s effectiveness across five environments. We investigate the effectiveness of three offline RL algorithms (BC, BCQ, and CQL) in generating challenger agents. Experimental results demonstrate that safety testing datasets are valuable for training competent DRL agents. Challenger agents trained with BCQ proved most effective for identifying optimality issues within the framework of DELTA. Across the five environments, DELTA uncovered an average of 2,518 optimality issues, outperforming the baseline methods by 50.2%.

CCS Concepts: • Computing methodologies → Markov decision processes; • Software and its engineering → Search-based software engineering.

Additional Key Words and Phrases: Deep Reinforcement Learning, Differential Testing, Fuzz Testing

ACM Reference Format:

Junda He, Jieke Shi, Zhou Yang, Mingfei Cheng, and David Lo. 2026. Learning from the Test: Self-Referential Differential Testing for Deep RL Agents. Proc. ACM Softw. Eng. 3, ISSTA, Article ISSTA011 (October 2026), 25 pages. https://doi.org/10.1145/3832102

1 Introduction

In recent years, Deep Reinforcement Learning (DRL) [1, 49, 76] has gained significant attention for its ability to tackle complex decision-making problems. By interacting with unknown environments through trial-and-error, DRL agents learn a decision-making policy to maximize cumulative

Authors' Contact Information: Junda He, jundahe.2022@phdcs.smu.edu.sg, Singapore Management University, Singapore, Singapore; Jieke Shi, jiekeshi@smu.edu.sg, Singapore Management University, Singapore, Singapore; Zhou Yang, zy25@ualberta.ca, University of Alberta, Edmonton, Canada and Canada CIFAR AI Chair, Amii, Edmonton, Canada; Mingfei Cheng, mfcheng.2022@phdcs.smu.edu.sg, Singapore Management University, Singapore, Singapore; David Lo, davidlo@smu.edu.sg, Singapore Management University, Singapore, Singapore.

Figure

This work is licensed under a Creative Commons Attribution 4.0 International License.

© 2026 Copyright held by the owner/author(s).

ACM 2994-970X/2026/10-ARTISSTA011

https://doi.org/10.1145/3832102

ISSTA011:2

Junda He, Jieke Shi, Zhou Yang, Mingfei Cheng, and David Lo

reward over a sequence of actions. DRL has demonstrated remarkable success in various domains such as healthcare [8, 82], autonomous driving [29, 58, 60], and robotic manipulation [27, 31, 52], outperforming traditional control methods by a substantial margin [20, 46].

As DRL systems, and AI-based software systems more broadly [25], are increasingly deployed in real-world applications [53, 68], ensuring their quality and reliability becomes paramount [81]. Recent testing methodologies [26, 38, 55, 62] for DRL systems primarily focus on detecting catastrophic failures (safety-critical issues), e.g., a DRL-controlled robot colliding with obstacles. We refer to these testing methods as safety testing. Despite this progress, current safety testing methods largely overlook a critical dimension: the decision optimality of DRL systems. Evaluating policy optimality is as crucial as ensuring safety. For instance, a robotic arm performs a task with unnecessary energy consumption. Such non-optimal DRL decisions can incur higher economic costs, reduce operational efficiency, and decrease user satisfaction. More critically, unresolved optimality issues can increase the risk of escalating into safety-critical hazards; for example, a delivery robot selecting congested routes is more likely to face traffic accidents or battery depletion. True system reliability, therefore, demands both safety and optimality. To bridge the critical gap between safety and optimality evaluation, this paper presents a unified framework for testing DRL agents on detecting both safety-critical failures and optimality issues.

However, a fundamental challenge in testing the optimality of DRL policies is the absence of a clear testing oracle. DRL is predominantly applied in complex and dynamic environments. In these environments, the optimal solution that achieves the theoretical maximum cumulative reward is either unknown or analytically intractable. Without a ground-truth optimal solution to serve as a benchmark, it becomes difficult to assess the optimality of an agent's decisions quantitatively. This is akin to verifying the output of a software program without knowing the correct output. While manual assessment by domain experts is an option, it is prohibitively time-consuming and expertise-intensive, rendering it infeasible to scale for the vast and diverse scenarios DRL agents encounter. Automated, learned surrogates are therefore increasingly explored as scalable evaluators when a ground-truth oracle is unavailable, e.g., for judging software artifacts [24] and assessing the correctness of automatically generated patches [84]. The impracticality of manual assessment underscores the critical challenge of addressing the oracle problem and developing automated testing methods for DRL policy optimality.

To overcome this, differential testing [15, 47] emerges as a promising solution. This widely used software testing technique compares the outputs of multiple implementations of the software, thereby eliminating the need to know the correct output. Similarly, we adapt this principle to DRL. For a given DRL agent to be tested—we refer to this agent as the agent under test (AUT)—by comparing the AUT's cumulative reward against other DRL instances, we can reveal the AUT's optimality issues if it is outperformed in cumulative reward. However, this approach introduces a new challenge: generating suitable DRL instances for comparison. We can repeat the training process several times to obtain multiple DRL agents for differential testing; however, developers are typically only interested in testing high-performing DRL agents. Training such policies requires extensive interaction with the environment, consuming considerable computational resources and substantial time [11, 12]. For large-scale systems, restarting this process can take weeks or even months, requiring the processing of billions of data points [12].

To address this limitation, we introduce a more efficient approach founded on a core insight: the detailed records of an AUT's decision-making process generated during safety testing are a vibrant and underutilized resource for training highly competent DRL agents. The reasons are: (1) existing testing methodologies [26, 38, 55] employ various mechanisms to generate a broad spectrum of scenarios for evaluating the AUT and triggering diverse agent behaviors. These scenarios often include edge cases that are rarely encountered during standard training, deliberately pushing

ISSTA011:3

the AUT into less explored regions. (2) Developers are typically only interested in testing high-performing DRL agents. Consequently, the AUT is a well-trained agent. Its behaviors, therefore, constitute a high-quality dataset of successful decisions. Leveraging this data provides a new policy with a strong starting point, jump-starts its training process, and bypasses the need for extensive, and often inefficient, initial exploration from scratch. (3) Finally, the resulting dataset offers a mixture of learning signals, which is crucial for robust training. It contains not only the AUT's successful trajectories as strong positive examples but also its documented failures as critical negative examples. This mixture provides clear guidance, teaching a new agent what behaviors to replicate and which to avoid.

As a result, we train a new agent using the AUT's own interaction data captured during safety testing. We name this new agent the challenger agent. Because it is trained solely on the AUT's own history, the challenger agent then serves as a potent self-referential testing oracle for suboptimality detection. This approach pragmatically relaxes the oracle problem. Acknowledging that true optimal policies are often unknown, if the challenger agent finds a superior solution, it exposes a concrete instance where the AUT's policy can be improved. As a result, this method effectively enables automated optimality testing without requiring a predefined perfect solution.

Notably, this approach yields value regardless of the testing outcome. A superior challenger identifies optimality issues and guides policy improvement. Conversely, a challenger that fails to outperform the AUT validates that the AUT is already near-optimal—without ever knowing what the true optimum is.

In this paper, we introduce DELTA (Differential Testing for DRL Agents), a comprehensive framework designed to automatically test DRL agents. DELTA seamlessly integrates established safety testing methods, such as CureFuzz [26], MDPFuzz [55], and GMT [38], with our proposed differential testing method, enabling holistic evaluation of agent quality in terms of both catastrophic failures and suboptimal behavior. DELTA consists of two main phases: (1) Safety Testing: The AUT is evaluated across a diverse set of scenarios to identify safety-critical issues. We adopt the state-of-the-art technique CureFuzz [26] for this phase. Simultaneously, DELTA records the AUT's interaction trajectories, creating a rich dataset that underpins subsequent optimality analysis. (2) Optimality Testing: Using the collected trajectories, DELTA applies Offline Reinforcement Learning [32, 36] to train a challenger agent. We then perform differential testing by comparing the challenger's performance against the original AUT. Cases where the challenger achieves higher cumulative rewards are flagged as optimality issues in the AUT.

To assess DELTA’s effectiveness, we conducted evaluations across five diverse environments: three classical control tasks (CartPole, MountainCar, Acrobot) and two MuJoCo locomotion tasks (Hopper, Walker2D). We also evaluated the performance of three offline RL algorithms (BC [75], BCQ [21], and CQL [34]) in generating challenger agents. Experimental results demonstrate that safety testing datasets are valuable for training competent DRL agents. Challenger agents trained with BCQ proved most effective for identifying optimality issues within DELTA. Leveraging the BCQ-trained challenger agents, DELTA uncovered an average of 2,518 optimality issues per environment. DELTA significantly outperforms the baseline methods and identifies an average of 50.2% more optimality bugs across all environments.

The contributions of this paper include:

• We propose a novel self-referential testing oracle for detecting optimality bugs in DRL agents.

• We develop DELTA, a unified two-stage framework comprising a safety testing stage (which adopts state-of-the-art method CureFuzz) and our novel optimality testing stage, enabling DRL agents to be evaluated for both catastrophic failures and suboptimal decisions in a single pipeline.

ISSTA011:4

Junda He, Jieke Shi, Zhou Yang, Mingfei Cheng, and David Lo

Figure

Fig. 1. Illustration of Offline Reinforcement Learning.

• We provide extensive experimental evidence demonstrating that DELTA effectively detects a significant number of optimality issues across diverse environments and DRL algorithms.

References (69)