The Challenge of Implicit Safety in RL
Safe Reinforcement Learning (RL) typically relies on dense, per-step cost signals—like a sensor continuously measuring a robot's distance from an obstacle. However, in real-world applications, constraints are often implicit, context-dependent, or only evaluable at the trajectory level. A human observer might easily flag an entire 10-second maneuver as "unsafe" but struggle to pinpoint the exact millisecond the failure occurred.
This creates a severe credit assignment problem: if an agent only knows a 1,000-step rollout was "bad," how does it determine which specific action caused the failure? Furthermore, standard safety-constrained methods require predefined safety thresholds (e.g., "total cost must be < 25"), which are often arbitrary and difficult to tune across different environments.
TraCeS (Trajectory-based Constraint Estimation for Safety) addresses this challenge by learning safe policies from sparse, binary trajectory labels (thumbs-up/thumbs-down) under "zero-knowledge" conditions—requiring neither a known cost function nor a predefined threshold.
How TraCeS Works
The core innovation of TraCeS is a sequential violation estimator that transforms coarse, trajectory-level labels into a dense, per-timestep signal. It achieves this through a few key mechanisms:
- Factorized Violation Credit: TraCeS treats safety as a "survival" problem. Because safety violations are usually irreversible, the probability of a trajectory remaining safe by the end of an episode is modeled as the product of the probabilities of it staying safe at each individual timestep.
- Sequential Estimation: A Recurrent Neural Network (specifically a 2-stack GRU) processes the trajectory's history to predict these per-step "violation credits."
- The Jensen Lower Bound: Standard Constrained Markov Decision Process (CMDP) solvers expect costs to be additive, not multiplicative. To bridge this gap, TraCeS uses Jensen’s Inequality to derive a tractable additive surrogate cost. This allows the learned signal to be plugged directly into existing continuous-control algorithms like PPO-Lagrangian.
- Active Labeling: To minimize human effort, TraCeS uses the Coefficient of Variation as an uncertainty proxy. It selectively queries labels only for the most "confusing" trajectories, significantly improving data efficiency.
Key Insights
- Scale-Free Safety: Instead of relying on an arbitrary hidden cost threshold, TraCeS uses a "desired acceptability rate" ($d$). Setting $d=0.9$ simply means the operator wants 90% of the trajectories to be safe. This is a far more intuitive metric for human operators to define.
- Localized Attribution: Despite only receiving end-of-trajectory labels, the learned surrogate costs naturally peak exactly when the agent crosses the unseen oracle threshold. The model effectively "back-calculates" the moment of failure without dense supervision.
Empirical Results
The authors evaluated TraCeS across 12 continuous-control tasks from major benchmarks, including Safety Gymnasium, MuJoCo, and Bullet Safety Gym, as well as a human feedback study.
- Zero-Knowledge Success: TraCeS successfully learned to satisfy constraints (keeping true costs $\le 25$) on almost all tasks without ever seeing the underlying cost function or threshold.
- Label Efficiency: The method achieved safety using significantly fewer labeled trajectories than baselines. For example, on the
CarCircle1task, TraCeS required approximately 4,000 labels compared to the baseline's 12,000. - Robustness to Noise: The system remained stable even when up to 10% of the labels were intentionally corrupted, benefiting from the conservative bias introduced by the Jensen gap.
- Human-in-the-Loop: In a small-scale study where a human labeled
HalfCheetahrollouts based on whether the robot lost its balance, TraCeS achieved a 66.7% non-violation rate with only 100 human labels. This outperformed state-of-the-art methods like RLSF (50%) and standard baselines (33.3%).
Limitations and Future Directions
Like most Lagrangian-based RL methods, TraCeS optimizes for eventual safety. During the early stages of training, the agent will still violate constraints as it explores the environment and calibrates the violation estimator. Additionally, while highly efficient, the active labeling pipeline still requires a consistent labeling source; if the human's "acceptability" criteria drift over time, the estimator may require recalibration.
Future work could explore moving beyond binary labels to incorporate graded scores (e.g., "very unsafe" vs. "slightly unsafe") or integrating short textual notes to help the model localize violations even faster.
Summary updated