A reinforcement learning agent that learns to avoid danger stops generating examples of danger. The model it uses to judge whether an action leads to a violation then drifts, because it no longer sees any. Late in training that drift can cause sudden, severe safety failures. The current fix pays for fresh violation data with real violations: a second "dual" policy is deliberately steered toward unsafe behavior. That is acceptable in simulation and unacceptable on a physical robot. We propose a different source of negative data: near misses. We define a nested family of stricter versions of the true safety constraint, for example "stay at least $m$ centimeters away from every hazard." The agent violates these stricter versions constantly while never violating the real one. Those near misses are relabeled as failures of the stricter constraints. A danger predictor that is forced to be consistent across the whole family then extrapolates to the true boundary. The data comes from the agent's own behavior, and no crash is required.
The same idea is where adaptive constraints and sparse rewards meet. When the only task reward is "reached the goal" at the end of an episode, the agent must explore boldly. Methods that adjust how far the policy may move by reading value estimates stop working in this regime, because the values carry almost no information. We instead set the policy's allowed step size from how accurately the danger predictor forecasts the near misses it has just observed. When the predictor is trustworthy near the boundary, exploration widens. When it is surprised, exploration narrows. Failure is used twice: stricter-constraint near misses train the safety model, and failed goal attempts are relabeled with the goals they actually reached, in the style of hindsight experience replay.
Core Claim
The safety paradox can be broken without executing true violations. A feasibility critic is a model that predicts whether a state–action pair eventually leads to a constraint violation. We claim it can be trained on relabeled violations of strictly tighter surrogate constraints and remain accurate at the true constraint, provided it is built to be monotone across the constraint family. That critic's calibration on fresh near-miss data is also a usable signal for adapting the policy's trust region under sparse task reward, where Q-value-driven adaptation fails.
Formally, let $c_m(s,a)$ be the safety cost with hazards inflated by margin $m \ge 0$, so $m = 0$ is the true cost. The family is nested: $c_m \ge c_{m'}$ whenever $m > m'$. Following Feasibility Consistent Representation Learning for Safe Reinforcement Learning, we use the maximum discounted future cost as the feasibility target, because that paper shows it is temporally smoother than cumulative cost. We make it margin-indexed:
$$F_m(s_t,a_t) = \max_{k \ge 0} \gamma^k c_m(s_{t+k}, a_{t+k}),$$
where $\gamma$ is the discount factor. Nesting implies $F_m \ge F_{m'}$ for $m > m'$. We learn a single critic $\hat F(s,a,m)$ whose output is constrained, by construction, to be non-decreasing in $m$. It is trained by relabeling every stored transition at a sampled set of margins. The policy is constrained only at $m = 0$.
Relation to Prior Work
Two papers motivate the proposal by exposing the gap. Breaking Safety Paradox with Feasible Dual Policy Iteration proves that safe policies starve the feasibility critic of violation data. It fixes this with a dual policy that maximizes violations under a KL tether to the main policy. That paper reports the baseline's violation sample ratio dropping below 1% late in training, while its method keeps roughly ten times more. We keep its diagnosis and its policy-iteration base, but replace intentional true violations with relabeled surrogate violations. Safety-Polarized and Prioritized Reinforcement Learning prioritizes replay of rare crash transitions using a reachability function. It is discrete-action only, and the FDPI analysis argues that re-weighting cannot help once the buffer holds no violations. Our relabeling creates new labels instead of re-weighting old ones.
Three papers supply method. Hindsight relabeling comes from Hindsight Experience Replay, and here it is applied to the constraint as well as the goal. AgentHER: Hindsight Experience Replay for LLM Agent Trajectory Relabeling and Language as an Abstraction for Hierarchical Deep Reinforcement Learning relabel failures offline or with an external oracle. Our relabeling needs no judge, because the margin cost is computable from hazard distances the simulator or the lidar already exposes. The adaptive-constraint mechanism builds on Grow Your Limits: Continuous Improvement with Real-World RL for Robotic Locomotion. APRL widens or narrows action limits based on how well a forward dynamics model predicts the next state, but it relies on dense rewards and discards failures. We swap its familiarity gauge for feasibility-critic calibration, which measures confidence about safety rather than about dynamics.
Two papers constrain the design. Adaptive Scaling of Policy Constraints for Offline Reinforcement Learning states explicitly that its bilevel constraint scaling underperforms under extreme reward sparsity, because Q-values give the outer loop no signal. This rules out adapting constraints from task value in our regime. Boundary-Seeking Policy Gradient for Safe Reinforcement Learning shows that optimal constrained policies sit on the constraint boundary. If that is right, a good agent will naturally live where surrogate-constraint violations are plentiful, which is exactly the regime our method exploits.
Offline work also discards unsafe data. Boundary-to-Region Supervision for Offline Safe Reinforcement Learning filters out trajectories that exceed the budget. Our relabeling is the online counterpart of keeping them.
Research Program
Base algorithm. We build on the SAC-based feasible policy iteration used by FDPI. SAC is soft actor-critic, an off-policy method for continuous control. Using the same base keeps the comparison with FDPI direct.
Margin-conditioned critic. The critic takes $m$ as an input and enforces monotonicity in $m$. It does this by predicting non-negative increments over a fixed grid of margins, which are then accumulated. Each minibatch transition is labeled at several margins, computed from logged hazard distances.
Main risk: extrapolation to $m = 0$. If the agent never approaches within $m_{\min}$ of a hazard, the critic's value at $m = 0$ is an extrapolation. We therefore report calibration against ground-truth violation probabilities obtained from simulator rollouts, as a function of $m$. This lets us see exactly where extrapolation breaks.
Adaptive trust region. The trust region is the KL radius on each policy update. We set it from the critic's expected calibration error on the most recent near misses at the smallest margin with support. The radius grows when that error is low and shrinks when it rises. The error is read at the smallest populated margin, because this is the evidence closest to the true boundary.
Sparse task reward. The task critic uses standard goal relabeling. A reached-goal relabel is only admitted as a demonstration if its trajectory satisfies the true constraint.
Analysis. We will check whether monotone extrapolation carries a bound. Under a Lipschitz assumption on $F_m$ in $m$, the error at $m = 0$ should grow at most linearly in $m_{\min}$. This follows because the critic is anchored at $m_{\min}$ and the slope is bounded. We will test this dependence empirically by varying the margin grid.
Baselines
Naive reference. The naive point is PPO-Lag, a Lagrangian-penalized PPO, run on the same sparse-reward tasks. Safety Gymnasium: A Unified Safe Reinforcement Learning Benchmark reports that on velocity tasks PPO-Lag gave a 98% reduction in safety violations relative to PPO, with a 45% drop in total reward. This shows the conservatism cost we expect to be worse under sparse reward.
Paradox reference. SAC-FPI, the same base without any fix, isolates the paradox itself.
Strongest competitor. The strongest competitor is SAC-FDPI. It is the only method that directly targets feasibility-critic starvation, and it reports near-zero constraint violations and elimination of late-training cost spikes across 14 environments. Its paper also reports the roughly tenfold higher violation sample ratio mentioned above. We will run it from its described design with the same SAC backbone, the same environment steps, and the same hyperparameter search budget, on identical seeds.
Boundary-seeking comparison. BSPG is included because it keeps the policy on the true boundary. On SafetyPointGoal1 it reports substantially higher reward than CRPO and ESPO with near-zero residual, though no exact numbers are reported in the file.
What counts as beating FDPI. Beating FDPI means matching its final return and its absence of late cost spikes, while counting substantially fewer true violations accumulated during training. Training-time violations are the quantity FDPI spends by design.
Ablations. Four ablations isolate the ingredients. The first removes margin relabeling, training only at $m = 0$. The second keeps relabeling but drops monotone structure, with $m$ as a free input. The third fixes the trust region. The fourth replaces the calibration gauge with APRL's dynamics-error gauge.
Why not just…?
Why not just train under the inflated-margin constraint directly? This is the most serious threat. If a policy constrained at margin $m$ is nearly as rewarding as one constrained at $m = 0$, all the machinery is unnecessary. The approach also has a deeper flaw: it violates its own constraint whenever the margin is truly binding, so it inherits the same paradox one margin up. We run it as a baseline across the same margin grid. If its best margin matches our return, we will report that the benefit is conservatism alone rather than extrapolation. We expect it to lose reward in tasks where goals lie near hazards, consistent with BSPG's finding that optimal policies sit on the boundary.
Why not just use FDPI's dual policy? FDPI's defining mechanism is deliberate true violations. The file's gap analysis notes this makes it unsuitable for hardware. Our primary metric, cumulative true violations during training, measures exactly this cost.
Why not just prioritize rare violations in replay? FDPI argues that re-weighting cannot help once violations vanish from the buffer. The only reported gains for safety-prioritized replay are discrete-action. We include a continuous reachability-TD prioritized replay baseline. We expect it to track SAC-FPI late in training.
Why not just add a large cost penalty or use hindsight goals with PPO-Lag? Hand-tuned penalties produce the "safe but useless" freezing described in Safe Reinforcement Learning via Constrained Markov Decision Processes. This is especially likely when sparse reward gives the agent little reason to move. PPO-Lag with goal relabeling is in our baseline set, which tests this directly.
Proposed Experiments
Environments. We use Safety-Gymnasium PointGoal1, CarGoal1, PointButton1, and AntGoal, modified so the task reward is given only when the goal is reached. We also run the original dense versions for comparability. We add Circle2D from Revisiting Safe Exploration in Safe Reinforcement learning for fast, fine-grained analysis.
Existing numbers. No reported result was found on Lacuna for any method on sparse-reward Safety-Gymnasium variants. All numbers in that setting will be new.
Metrics. We measure goal success rate, normalized reward and cost, and cumulative true violations during training. We also measure Expected Maximum Consecutive Cost steps (EMCC), the longest unbroken run of unsafe steps normalized by trajectory length, which the Circle2D paper shows cumulative cost can hide. Finally, we count late-training cost spikes.
First decisive check. Plot feasibility-critic calibration at $m = 0$ over training for SAC-FPI, FDPI, and our method. Near-miss relabeling should hold calibration flat without true violations, where SAC-FPI's calibration degrades as its violation ratio falls.
Second decisive check. Report the margin-grid sweep. Calibration at $m = 0$ should degrade gracefully as the smallest margin with data grows. The prediction fails if the critic's error jumps discontinuously rather than increasing roughly linearly.
Third decisive check. Compare against the inflated-margin baseline. This settles whether extrapolation, rather than extra caution, produces the gain.
Fourth decisive check. Compare the calibration gauge with the dynamics-error gauge under sparse reward. The calibration gauge should allow faster goal discovery at equal violation counts.
References
- Feasibility Consistent Representation Learning for Safe Reinforcement Learning
- Breaking Safety Paradox with Feasible Dual Policy Iteration
- Safety-Polarized and Prioritized Reinforcement Learning
- Hindsight Experience Replay
- AgentHER: Hindsight Experience Replay for LLM Agent Trajectory Relabeling
- Language as an Abstraction for Hierarchical Deep Reinforcement Learning
- Grow Your Limits: Continuous Improvement with Real-World RL for Robotic Locomotion
- Adaptive Scaling of Policy Constraints for Offline Reinforcement Learning
- Boundary-Seeking Policy Gradient for Safe Reinforcement Learning
- Boundary-to-Region Supervision for Offline Safe Reinforcement Learning
- Safety Gymnasium: A Unified Safe Reinforcement Learning Benchmark
- MetaDrive: Composing Diverse Driving Scenarios for Generalizable Reinforcement Learning
- Revisiting Safe Exploration in Safe Reinforcement learning