Safety through feedback in Constrained RL

Shashank Reddy Chirra, Pradeep Varakantham, Praveen Paruchuri

Introduction

In the pursuit of deploying Reinforcement Learning (RL) in real-world, safety-critical environments—such as autonomous driving or industrial robotics—the primary challenge is not just achieving a goal, but doing so safely. Traditional Constrained RL relies on "cost functions" to penalize unsafe behaviors. However, designing these functions is notoriously difficult, often requiring engineers to anticipate every possible edge case. While human feedback offers a potential solution, previous methods required dense, state-level labeling (e.g., marking every frame of a video as safe or unsafe), which is prohibitively expensive and labor-intensive.

This paper introduces Reinforcement Learning from Safety Feedback (RLSF), a framework designed to learn safety constraints directly from high-level, binary feedback on agent trajectories. By combining a novel surrogate loss with an intelligent sampling strategy, RLSF bridges the gap between human intuition and algorithmic safety.

The Problem: The Cost Function Bottleneck

In standard RL, agents maximize a reward function. In Constrained RL, they must also minimize a cost function. The "headache" for developers is that defining what constitutes a "costly" action (like cutting off another vehicle too sharply) is subjective and hard to quantify mathematically.

Existing human-in-the-loop approaches attempt to solve this by asking evaluators to label data. However, asking a human to provide a numeric safety score or to label thousands of individual states is impractical. RLSF addresses this by asking a much simpler question: "Was this 10-second trajectory safe or unsafe?"

The RLSF Framework

RLSF introduces two core innovations to make learning from sparse, high-level feedback effective:

1. The Surrogate Objective and Credit Assignment

When a human labels an entire trajectory segment as "unsafe," the agent faces a credit assignment problem: which specific moment in that segment caused the violation? RLSF utilizes a surrogate loss that treats the trajectory-level label as a "noisy label" for every constituent state.

Mathematically, the authors demonstrate that minimizing this state-level classification loss provides an upper bound on the true likelihood of the cost function. This allows the agent to statistically distinguish safe states from unsafe ones over time, even without precise per-frame labels. Any segment labeled "safe" is assumed to contain only safe states, while an "unsafe" segment is assumed to contain at least one violation.

2. Novelty-Based Sampling via SimHash

To minimize the burden on the human evaluator, the system must be selective about which trajectories it asks the human to review. RLSF employs SimHash, a technique that discretizes the high-dimensional state space into a hash map to track state frequency. The agent only queries the evaluator when it encounters a "novel" trajectory—one containing states it has not frequently visited. As the agent’s policy matures and it explores less of the unknown environment, the frequency of human intervention naturally decays, making the process highly efficient.

For policy optimization, RLSF integrates these learned costs into a PPO-Lagrangian framework, which balances reward maximization against the learned safety constraints.

Experimental Evaluation

The researchers evaluated RLSF across three diverse sets of continuous control benchmarks:

  • Safety Gymnasium: Tasks such as Point/Car Circle and Goal/Push, which require navigating boundaries and avoiding obstacles.
  • Mujoco-based Tasks: Physics simulations like HalfCheetah and Walker2d with added velocity constraints.
  • Safe Driver Simulator: A realistic highway environment featuring scenarios like avoiding stalled vehicles and managing complex lane changes.

Key Insights and Results

Near-Optimal Performance

RLSF achieved safety performance within approximately 80% of the performance seen in agents trained with "ground truth" cost functions (expert-designed functions that are usually unavailable in real-world settings). This suggests that binary human feedback is a viable surrogate for complex manual engineering.

Drastic Reduction in Evaluator Effort

The novelty-based sampling mechanism proved highly effective. In many environments, the agent required significant feedback only during the initial stages of training. After the first few million steps, the query frequency dropped to near zero as the agent became familiar with the safety boundaries of the state space.

Cost Transferability

One of the most compelling findings was that learned cost functions are often agent-agnostic. The authors demonstrated that a cost function learned by a simple "Point" agent could be successfully transferred to a complex "Doggo" (quadruped) agent. This allows the Doggo to remain safe in the same environment without requiring any additional human feedback, suggesting that RLSF learns fundamental environmental constraints rather than just agent-specific behaviors.

Limitations and Future Directions

Despite its success, RLSF faces a few challenges:

  • Overestimation Bias: The surrogate loss can be overly pessimistic, occasionally treating safe states within an unsafe segment as dangerous. While a heuristic bias correction ($\delta$) was introduced, it currently requires manual tuning.
  • Human Subjectivity: The study utilized simulated human feedback based on ground truth rules. Real-world human feedback is often inconsistent or subjective, and future work is needed to test RLSF’s robustness against "noisy" human evaluators.
  • Sparsity: In environments where unsafe events are extremely brief, the method still performs better with shorter segments, which can slightly increase the labeling workload.

Conclusion

RLSF represents a significant step toward making Constrained RL practical for real-world applications. By moving away from manual cost engineering and dense state labeling, and instead leveraging binary trajectory feedback and novelty-based sampling, the framework provides a scalable path toward training secure and reliable AI agents.

Summary updated

BibTeX
@inproceedings{chirra2024safety,
  author = {Shashank Reddy Chirra and Pradeep Varakantham and Praveen Paruchuri},
  title = {{Safety through feedback in Constrained RL}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=WSsht66fbC},
}
Figure