Model-Based Proactive Cost Generation for Learning Safe Policies Offline with Limited Violation Data

Ruiqi Xue, Lei Yuan, Kainuo Cheng, Jing-Wen Yang, Yang YuarXiv 2026

TL;DR

Offline safe reinforcement learning typically fails when training data lacks unsafe examples, leading policies to wander into "safe-but-infeasible" states that inevitably end in a crash. This paper introduces PROCO, a framework that leverages Large Language Models (LLMs) to translate natural language safety rules into conservative cost functions, combined with a learned dynamics model to proactively simulate counterfactual crashes. By training on these synthesized failures, agents can identify hidden dangers and boost safety performance by over 400% without needing real-world violation data.

What Problem Does This Paper Address?

Offline safe reinforcement learning (RL) aims to train agents to maximize rewards while strictly adhering to safety constraints, using only pre-collected datasets to avoid dangerous real-world exploration.

However, existing algorithms suffer from a major catch-22: to learn where the safety boundaries are, they require datasets packed with abundant examples of unsafe behaviors and constraint violations. In high-stakes real-world applications like autonomous driving or robotic manipulation, datasets are almost entirely "safe-only" because human operators or automatic overrides intervene long before a crash occurs.

When standard offline safe RL algorithms are trained on these safe-only datasets, they assume the entire state space is safe. Consequently, they overlook safe-but-infeasible states—situations where an agent currently satisfies all safety constraints but, due to momentum or environmental physics, is on an unavoidable trajectory toward a violation.

Methods

The authors propose PROCO (Model-Based Proactive Cost Generation), a framework that bridges the data gap by integrating human linguistic knowledge with predictive world models.

Figure 1: Structure of PROCO.

The PROCO pipeline consists of four main steps:

  1. LLM-Assisted Cost Generation: The framework feeds the LLM a task description, observation space details, and natural language safety constraints. It instructs the LLM to generate a Python function (get_cost) that is intentionally conservative, meaning it flags states that are close to violating constraints as unsafe.
  2. Validation and Feedback Loop: To prevent LLM hallucinations, the generated code is validated against the safe dataset and a tiny set of unsafe samples. If the code fails to achieve 100% accuracy on known violations or is too/not enough conservative on safe data, a feedback description is sent back to the LLM to regenerate the function.
  3. Counterfactual Branched Rollouts: PROCO trains an ensemble dynamics model on the safe offline data. It then initiates short, noisy simulations (rollouts) branching out from the safe states in the dataset, using the LLM-derived cost function to proactively detect where these trajectories cross into simulated danger zones.
  4. Feasibility Identification: Using a conservative feasible Bellman operator rooted in Hamilton-Jacobi reachability analysis, PROCO propagates these simulated failures backward in time. This allows the system to accurately label safe-but-infeasible states and guide the safe RL policy optimization.

Datasets

The framework was evaluated across 17 Safety-Gymnasium tasks from the Operational Safe Reinforcement Learning (OSRL) benchmark:

  • 12 Navigation Tasks: Involving Point and Car robots navigating environments to reach goals, push boxes, or press buttons while avoiding obstacles.
  • 5 Velocity Tasks: Built on MuJoCo simulations (Ant, HalfCheetah, Hopper, Swimmer, Walker2d) where robots must move as fast as possible without exceeding strict safety velocity thresholds.

To simulate real-world constraints, the authors modified these datasets to be completely safe-only by removing all trajectories containing constraint violations. They retained a tiny sliver of just 100 unsafe transitions strictly for validating the LLM's code generation.

Key Insights and Ideas

  • Knowledge-Data Integration: When empirical data lacks negative examples, human semantic knowledge (via an LLM) can act as a proxy to define boundaries before the agent ever experiences a real-world failure.
  • Shrinking the Horizon to Defeat Model Error: Simulating long trajectories with a learned dynamics model introduces compounding prediction errors. The authors mathematically prove (Theorem 4.7) that by making the LLM cost function artificially conservative, they bring the perceived danger closer to the agent. This shortens the rollout steps ($t^*$) needed to detect an impending crash, drastically reducing the negative impact of dynamics model inaccuracies.
  • Theoretical Safety Guarantees: The authors prove (Theorem 4.8) that integrating PROCO with any standard offline safe RL baseline mathematically guarantees that the safety value estimation will not be degraded, ensuring robust deployment.

Key Results

PROCO was integrated with three state-of-the-art offline safe RL algorithms: FISOR, LSPC, and CAPS.

  • Massive Safety Improvements: On safe-only datasets where baseline algorithms failed catastrophically, PROCO variants improved safety performance across the board by over 400%. Notably, FISOR PROCO achieved a 1011% safety improvement over standard FISOR.
  • Zero-Violation Case Study: In the Ant Circle task, standard FISOR frequently drifted past safety boundaries due to an inability to identify infeasible states. PROCO successfully identified the safety boundaries, achieving zero constraint violations and matching the performance of an "Oracle" trained on a massive dataset of real crashes.
Visualization of the Circle task and performance comparison
  • High Precision: Feasibility accuracy analysis demonstrated that PROCO rarely suffers from false negatives, meaning it almost never misclassifies an unsafe state as safe.

Limitations and Future Work

  • Dependence on Dynamics Models: In environments where the physics are exceptionally difficult to model (e.g., high-dimensional navigation), model errors can still destabilize learning if the rollout horizon is too long. The authors suggest exploring more powerful generative world models, like diffusion models, to mitigate this.
  • Feature Grounding Constraints: The natural language safety rules must map directly to variables present in the agent's observation vector. If the safety constraint relies on unobservable environmental features, the LLM cannot generate a functional cost estimator.
  • State-Based Restriction: PROCO is currently limited to vector state inputs. Extending it to vision-based tasks (pixels) using Vision-Language Models (VLMs) is currently too computationally expensive and prone to visual inaccuracies.

Summary updated

BibTeX
@misc{xue2026model,
  author = {Ruiqi Xue and Lei Yuan and Kainuo Cheng and Jing-Wen Yang and Yang Yu},
  title = {{Model-Based Proactive Cost Generation for Learning Safe Policies Offline with Limited Violation Data}},
  year = {2026},
  eprint = {2605.01356},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.01356},
}
Figure