Shields for Safe Reinforcement Learning

Bettina Könighofer, Roderick Bloem, Nils Jansen, Sebastian Junges, Stefan Pranger

Abstract

Reinforcement learning (RL) struggles in safety-critical domains because agents must inherently explore potentially dangerous actions to learn. This paper explores "shielding," a neurosymbolic technique that uses formal environment models to block unsafe actions at runtime. By separating safety guarantees from the learning objective, shielding not only ensures zero catastrophic failures during training and deployment but can also significantly speed up the learning process.

Introduction

Deep Reinforcement Learning (DRL) has achieved remarkable success in complex environments, from playing Go to autonomous driving. However, standard RL lacks formal safety guarantees. Because RL relies on trial-and-error exploration, an agent will inevitably try unsafe actions—such as driving a drone into a wall—to learn that they yield negative rewards. Even after training, a purely neural-network-based policy might make unpredictable, unsafe choices in edge cases.

While engineers often try to solve this by heavily penalizing unsafe actions in the reward function, this does not prevent the agent from taking the action in the first place. This research addresses the critical need for Safe Reinforcement Learning: methods that allow an agent to learn optimal policies while strictly guaranteeing that safety-critical constraints are never violated, either during training or deployment.

Methodology: The Shielding Framework

The paper advocates for Shielding, a runtime enforcement mechanism that sits between the RL agent and the environment. It combines sub-symbolic AI (the learning agent) with symbolic AI (formal verification).

The shielded reinforcement learning loop, where a shield intercepts observations and ensures only safe actions reach the environment.

There are two main ways to integrate a shield:

  • Pre-shielding: The shield computes a list of all currently safe actions and passes this "mask" to the agent, which then selects the best action from this restricted list.
  • Post-shielding: The agent selects an action as usual. The shield evaluates it; if it is safe, it passes it to the environment. If it is unsafe, the shield overrides it with a safe alternative.

To determine safety, the shield relies on an abstract formal model of the environment (typically a Markov Decision Process). The authors detail two paradigms for computing the shield:

  1. Absolute Safety Guarantees: The environment is modeled deterministically and adversarially as a two-player safety game. The shield computes a "winning region"—a set of states where the agent can always avoid a crash. Actions leading outside this region are blocked.
  2. Probabilistic Safety Guarantees: When absolute safety is impossible (e.g., due to sensor failure or stochastic wind), the shield uses dynamic programming to compute the minimal probability of reaching an unsafe state. An action is only allowed if the probability of a future safety violation remains below a strict, user-defined threshold (ε).

Experimental Setup

The authors demonstrate these concepts using a custom 2D grid world simulation involving Unmanned Aerial Vehicles (UAVs). The agent must navigate a drone to a target while avoiding static buildings, adversarial drones, and stochastic wind patterns.

A visualization of the UAV navigation environment, featuring buildings, a target location, and stochastic wind patterns.

Key Insights and Results

  • Separation of Concerns: Shielding decouples safety from performance. The RL agent's reward function can remain simple (e.g., "reach the goal quickly") because the shield independently handles the complex constraint of "don't crash."
  • Improved Sample Efficiency: Counterintuitively, blocking actions makes learning faster. By pruning the state space of doomed, unsafe paths, the agent wastes fewer samples and focuses exploration on viable, safe strategies.
  • Absolute Safety Performance: In scenarios with adversarial drones, unshielded RL agents accumulated over 1,500 crashes during training. The shielded agent maintained zero violations and converged to the optimal reward in a fraction of the time.
  • Probabilistic Safety Performance: With a risk threshold of ε = 0.0, the drone took long, suboptimal detours. With ε = 0.03, the shield allowed faster, slightly riskier paths between buildings, resulting in higher rewards while still strictly bounding the failure rate compared to unshielded baselines.

Limitations and Future Work

A shield is only as effective as its underlying formal model; if the model fails to capture specific safety-relevant dynamics, the shield cannot protect the agent. Furthermore, computing winning regions for environments with billions of states remains a computational bottleneck. Future research directions include extending shields to partially observable environments (POMDPs), scaling to continuous state spaces using techniques like zonotopes, and managing multi-agent systems.

Summary updated

BibTeX
@article{konighofer2025shields,
  author = {Bettina Könighofer and Roderick Bloem and Nils Jansen and Sebastian Junges and Stefan Pranger},
  title = {{Shields for Safe Reinforcement Learning}},
  journal = {Communications of the ACM},
  year = {2025},
  doi = {10.1145/3715958},
}
Figure