xSRL: Safety-Aware Explainable Reinforcement Learning - Safety as a Product of Explainability

Risal Shahriar Shefin (Wake Forest University), Md Asifur Rahman (Wake Forest University), Thai Le (Indiana University), Sarra Alqahtani (Wake Forest University)

Abstract

Reinforcement learning (RL) has shown great promise in simulated environments, such as games, where failures have minimal consequences. However, the deployment of RL agents in real-world systems such as autonomous vehicles, robotics, UAVs, and medical devices demands a higher level of safety and transparency, particularly when facing adversarial threats. Safe RL algorithms aim to address these concerns by optimizing both task performance and safety constraints. However, errors are inevitable, and when they occur, it is essential that RL agents can explain their actions to human operators. This makes trust in the safety mechanisms of RL systems crucial for effective deployment. Explainability plays a key role in building this trust by providing clear, actionable insights into the agent's decision-making process, ensuring that safety-critical decisions are well understood. While machine learning (ML) has seen significant advances in interpretability and visualization, explainability methods for RL remain limited. Current tools fail to address the dynamic, sequential nature of RL and its need to balance task performance with safety constraints over time. The re-purposing of traditional ML methods, such as saliency maps, is inadequate for safety-critical RL applications where mistakes can result in severe consequences. To bridge this gap, we propose xSRL, a framework that integrates both local and global explanations to provide a comprehensive understanding of RL agents' behavior. In addition, xSRL enables developers to identify policy vulnerabilities through adversarial attacks, offering tools to debug and patch agents without retraining. Thus, xSRL enhances the RL safety as a byproduct of explainability and transparency. Our experiments and user studies demonstrate xSRL's effectiveness in increasing safety in RL systems, making them more reliable and trustworthy for real-world deployment. Code is available at