Latent Q-Barrier Shielding for Safe In-Context Reinforcement Learning
Minjae Kwon, Amir Moeini, Shangtong Zhang, Lu Feng
NeurIPS 2026
TL;DR. A budget-aware latent Q-barrier shield improves safe ICRL under OOD shifts without test-time parameter updates.
Abstract. Safe in-context reinforcement learning (ICRL) adapts online from interaction history without test-time parameter updates while controlling episode cost under a safety budget. Under out-of-distribution (OOD) deployment shifts, pretraining-only safe ICRL can give poor reward-safety tradeoffs because the remaining budget affects behavior only through frozen policy conditioning, not an explicit action-level check against predicted future cost. We propose a latent Q-Barrier shield that learns a context representation, latent dynamics, and an ensemble cost critic before deployment. Without parameter updates, the shield infers context from history and filters or softly reweights candidate actions using the remaining budget and predicted future cost. We prove a conditional one-step barrier-margin bound over realized candidate sets, with explicit Bellman and latent-prediction error terms. Across five safe ICRL benchmarks, the shield improves deployment-time reward-safety tradeoffs over a strong safe-ICRL baseline: after a short context window, it achieves higher return in four of five benchmarks while matching or lowering average episode cost in all five.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:47 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
Summary. The paper proposes Q-Barrier, a deployment-time safety shield for in-context reinforcement learning. A frozen policy proposes candidate actions, and the shield reweights them using the remaining cost budget and a pessimistic estimate of cost-to-go.
Strengths. The paper addresses an important safe-RL problem with a modular method that preserves adaptation without test-time parameter updates. The use of an ensemble cost critic is sensible, and soft action selection avoids the rigidity of hard filtering. The separation between policy and world representations is also a thoughtful design choice. The empirical improvements over SCARED are promising, and the appendix provides useful diagnostics and ablations.
Weaknesses. The main concern is that the experiments do not yet isolate which parts of the method drive the gains. The theoretical claims also appear stronger than the guarantees actually provided. The rebuttal could materially improve the case by addressing the following:
Clarify whether Theorem 1 is valid when the latent dynamics model is not used at inference. If necessary, frame it as a conditional error decomposition rather than a closed-loop safety guarantee. Explain why several curves in Figure 2 closely resemble those in SCARED but have different numerical values. The response should clearly describe any differences in training or evaluation. Isolate the role of the critic ensemble and auxiliary dynamics loss. Comparisons using one versus multiple critics, as well as a matched SCARED baseline, would be especially useful. Provide a clearer description of the training pipeline. A diagram showing the architecture, gradient flow, data collection, and deployment procedure would make the method easier to assess. Strengthen the evaluation by testing longer episodes and different context lengths. It would also help to report how often the soft shield selects actions with negative barrier margins and to compare against a simpler critic-based action filter.
EDIT: I have read the authors’ response and the subsequent discussion. The rebuttal addressed the main concerns above through component ablations, a comparison with a simpler critic-based penalty, clarification of the Figure 2 discrepancy and training pipeline, and new diagnostics on context length, barrier margins, and candidate feasibility. Two reviewers raised their scores to accept, while the remaining reviewer agreed that the empirical case was substantially stronger but retained concerns about the conditional nature of the theoretical analysis. I share this limitation, especially given the difficulty of finding feasible candidates in SafetyHalfCheetah under tight budgets and the degradation beyond the context length used in training. The final paper should state these limitations clearly and describe the results as empirical risk reduction rather than certified safety. Overall, the rebuttal resolved my main concerns, and I recommend acceptance. I also asked the reviewers for their final views after rebuttal; the two who responded expressed no objection to acceptance.
Final justification
I have read the author response and reviewer discussion. The rebuttal addressed the main experimental and presentation concerns through targeted ablations, an additional baseline, and clearer diagnostics. The theoretical analysis remains conditional and should be framed accordingly, but this limitation does not change my accept recommendation.
Read meta-review
Meta-review
Summary. The paper proposes Q-Barrier, a deployment-time safety shield for in-context reinforcement learning. A frozen policy proposes candidate actions, and the shield reweights them using the remaining cost budget and a pessimistic estimate of cost-to-go.
Strengths. The paper addresses an important safe-RL problem with a modular method that preserves adaptation without test-time parameter updates. The use of an ensemble cost critic is sensible, and soft action selection avoids the rigidity of hard filtering. The separation between policy and world representations is also a thoughtful design choice. The empirical improvements over SCARED are promising, and the appendix provides useful diagnostics and ablations.
Weaknesses. The main concern is that the experiments do not yet isolate which parts of the method drive the gains. The theoretical claims also appear stronger than the guarantees actually provided. The rebuttal could materially improve the case by addressing the following:
Clarify whether Theorem 1 is valid when the latent dynamics model is not used at inference. If necessary, frame it as a conditional error decomposition rather than a closed-loop safety guarantee. Explain why several curves in Figure 2 closely resemble those in SCARED but have different numerical values. The response should clearly describe any differences in training or evaluation. Isolate the role of the critic ensemble and auxiliary dynamics loss. Comparisons using one versus multiple critics, as well as a matched SCARED baseline, would be especially useful. Provide a clearer description of the training pipeline. A diagram showing the architecture, gradient flow, data collection, and deployment procedure would make the method easier to assess. Strengthen the evaluation by testing longer episodes and different context lengths. It would also help to report how often the soft shield selects actions with negative barrier margins and to compare against a simpler critic-based action filter.
EDIT: I have read the authors’ response and the subsequent discussion. The rebuttal addressed the main concerns above through component ablations, a comparison with a simpler critic-based penalty, clarification of the Figure 2 discrepancy and training pipeline, and new diagnostics on context length, barrier margins, and candidate feasibility. Two reviewers raised their scores to accept, while the remaining reviewer agreed that the empirical case was substantially stronger but retained concerns about the conditional nature of the theoretical analysis. I share this limitation, especially given the difficulty of finding feasible candidates in SafetyHalfCheetah under tight budgets and the degradation beyond the context length used in training. The final paper should state these limitations clearly and describe the results as empirical risk reduction rather than certified safety. Overall, the rebuttal resolved my main concerns, and I recommend acceptance. I also asked the reviewers for their final views after rebuttal; the two who responded expressed no objection to acceptance.
Final justification
I have read the author response and reviewer discussion. The rebuttal addressed the main experimental and presentation concerns through targeted ablations, an additional baseline, and clearer diagnostics. The theoretical analysis remains conditional and should be framed accordingly, but this limitation does not change my accept recommendation.
- Rating
- 5/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper proposes Q-Barrier, a deployment-time shielding method for safe in-context reinforcement learning. The setting is safe ICRL, where a pretrained policy must adapt to new tasks through interaction history, without test-time parameter updates, while keeping episodic costs within a budget. The method uses a shared encoder, and separate policy and world latent projection heads. The policy projection is used by the base policy, while the world projection is used by a latent dynamics model and an ensemble cost critic. At deployment, the policy proposes candidate actions, and the shield reweights these candidates according to the remaining budget and a pessimistic learned cost-to-go estimate. Actions predicted to exceed the remaining budget are downweighted by a soft barrier; a hard filtering variant is also studied in the appendix.
Experimentally, the method improves reward-cost tradeoffs over SCARED and other safe adaptation baselines in most evaluated environments, though SafetyHalfCheetah shows a conservative lower-cost/lower-return tradeoff. The appendix includes useful ablations and diagnostics, including comparisons of soft vs. hard shielding and sensitivity to the number of sampled candidate actions.
Strengths and weaknesses
Strengths - The paper is well motivated: frozen safe ICRL policies may still choose actions that are inconsistent with the remaining cost budget, so an explicit action-level safety filter is natural. The proposed method is technically interesting and modular: it adds a latent cost-to-go based shield without requiring test-time parameter updates. The empirical results are strong across the evaluated safe ICRL benchmarks, especially relative to the SCARED base policy. The theoretical analysis is helpful and the appendix is extensive and includes useful diagnostics, ablations, and implementation details.
Weaknesses - The training procedure is not sufficiently clear. Given the number of components, a diagram of the architecture and gradient flow would be very helpful. It should be explicit which losses update the shared encoder, policy projection, world projection, dynamics model, and critics. The policy loss is underexplained. Algorithm 1 uses terms such as , , and , apparently inherited from SCARED, but these are not defined or motivated sufficiently. The paper should be more self-contained, especially because safe ICRL/SCARED is still a recent framework. The auxiliary losses, especially , need more explanation. The mathematical definition is present, but the motivation and effect on representation learning are not clear. The data-collection/training loop is ambiguous. Algorithm 1 requires a batch of history-conditioned trajectories, but it is not clear how these are collected during training, whether the shield is active during training interaction, and how this differs across discrete and continuous action settings. The method depends heavily on the learned cost critic and latent dynamics quality. The SafetyHalfCheetah result illustrates that an inaccurate hurts performance. However, its affect largely makes the shield overly conservative, which is positive.
Questions
- Could the authors add a diagram showing the full architecture, including encoder, projections, policy, dynamics model, cost critic ensemble, and gradient flow from each loss?
- Are shielded actions used during training data collection, or is the Q-barrier used only at deployment? Please clarify the training loop.
- Please define and motivate , , and without requiring the reader to consult SCARED.
- What is the intuition behind the conjugacy loss , and how important is it empirically?
- How sensitive is the method to cost-critic miscalibration beyond the reported HalfCheetah case?
Limitations
yes
Final justification
My concerns have been addressed and the authors have committed to incorporate my comments and their responses in the final revision.
Formatting concerns
No formatting issues detected.
4 comments
Thank you for detailed explanation. My concerns have been addressed. Under the expectation that these clarifications will be included in the revision I will raise my score to accept.
Thank you for your time, for carefully considering our response, and for considering raising your score after our rebuttals addressed your concerns.
Thank you for detailed explanation. My concerns have been addressed. Under the expectation that these clarifications will be included in the revision I will raise my score to accept.
We confirm that all clarifications discussed during the rebuttal will be included in the revised paper. Again, thank you so much for your time and constructive feedback in improving the paper!
Dear Reviewer wpKe,
Thank you again for letting us know that our rebuttal addressed your concerns and that you intended to raise your score to accept!
As the discussion period is coming to an end, we wanted to kindly follow up. We will make sure that the revised paper will include the architecture clarifications with visualization, additional ablations on the contributions of each component for our Q-Barrier, further clarifications on the training procedure, objective definitions, the conjugacy-loss analysis, and the cost-critic calibration discussion raised during the rebuttal.
Thank you again for your careful review and constructive feedback, which have helped us improve the paper!
- Rating
- 4/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper studies safe in-context reinforcement learning (ICRL), where a frozen history-conditioned policy must adapt over deployment episodes while respecting a cost budget. The proposed method, Q-Barrier, augments a pretrained safe ICRL policy with a latent runtime shield. The shield learns a context encoder, world/policy latent projections, latent dynamics, and an ensemble cost critic during pretraining. At test time, with no parameter updates, it samples or enumerates candidate actions and reweights them according to a remaining-budget barrier of the form . The paper provides a conditional one-step barrier-margin propagation result and evaluates the method on five safe ICRL benchmarks, showing improved reward-cost tradeoffs relative to SCARED in most environments.
Strengths and weaknesses
Strengths: The paper targets an important problem in safe RL: a pretrained safe adaptation policy may still choose unsafe actions under deployment shift, especially when safety information must be inferred from context. The proposed shielding layer is modular and conceptually simple: it turns the remaining budget into an explicit action-selection signal while preserving the no-test-time-update property of ICRL. The method is well motivated for settings where the base policy has useful reward-seeking behavior but needs an additional cost-to-go check. The empirical section is relatively thorough, covering structural OOD navigation tasks and unseen-ID velocity tasks, with budget sweeps, soft-vs-hard shielding ablations, candidate-set-size ablations, and diagnostics for quantities appearing in the theoretical bound.
Weaknesses: The theoretical guarantee is quite conditional and does not establish closed-loop safety of the deployed stochastic shield. The main theorem shows that if the selected action has sufficient learned barrier margin, and if latent prediction error and Bellman upper-bound residual are small, then the next latent-budget state has an approximately feasible continuation over the next candidate set. However, the default soft shield can still sample actions with negative barrier margin, and the episode-level bound contains selection-gap, Bellman-error, and latent-prediction residual terms that are not controlled a priori. Thus the result is better interpreted as an error decomposition than as a safety certificate.
Questions
(1) In the experiments, is the SCARED baseline trained with exactly the same encoder architecture and auxiliary world-model/cost-critic losses as Q-Barrier, but without the deployment-time shield? If not, can the authors provide this ablation to isolate the effect of runtime shielding?
(2) The default soft shield may still select actions with . How often does this occur in each benchmark, and how does this frequency correlate with budget violations?
(3) The theorem is conditional on fixed realized candidate sets. In continuous control, candidate sets are sampled from the base policy at each step. How sensitive are the conclusions to the probability that the sampled set contains at least one feasible action?
(4) How does Q-Barrier compare to a simpler baseline that uses the same pessimistic cost critic to add an action-level cost penalty or temperature-adjusted reweighting, but without the latent dynamics/barrier-margin construction?
(5) In SafetyHalfCheetah, the method becomes substantially more conservative. Can the authors quantify whether this is due mainly to latent prediction error, critic overestimation, candidate-set quality, or the scale of the exponential reweighting?
Limitations
The method relies on learned latent dynamics and learned pessimistic cost critics, but these are not certified. If either the latent model or cost critic is miscalibrated under deployment shift, the shield may either reject useful actions or under-penalize risky actions. The theory is one-step and conditional, and the episode-level result leaves residual terms that may accumulate over the horizon. In continuous action spaces, safety is limited by the finite candidate set sampled from the base policy, so the shield cannot select safe actions that the base policy does not propose. The empirical evaluation is limited to simulated benchmarks and should be strengthened with more training seeds, more direct ablations, and comparisons to simpler runtime safety filters. The method should therefore be presented as a useful learned risk-reweighting mechanism rather than as a formal safety guarantee.
Final justification
I maintain my score of 4. The rebuttal strengthens the empirical evaluation through informative component ablations, a cost-penalty baseline, and candidate-set diagnostics. However, the central theoretical limitation remains: the guarantee is conditional on selecting a nonnegative-margin action from a realized candidate set and does not establish closed-loop safety for the deployed stochastic shield. This is practically relevant because SafetyHalfCheetah frequently has no feasible candidate under tight budgets. I therefore view Q-Barrier as a promising learned risk-reweighting mechanism, but not yet a formal safety method.
Formatting concerns
N/A
4 comments
Rebuttal
1.Contributing Factors for Q-Barrier
We thank the reviewer for raising this question. To address it, we studied additional experiments. Below, we report the average return and cost over 50 in-context episodes and 100 evaluation rollouts in SafeDarkRoom. denotes the number of cost critics.
| Case | Average Return | Average Cost |
|---|---|---|
| Full Q-Barrier (M=4) | 0.898±.003 | 0.92±.034 |
| Two critics (M=2) | 0.836±.006 | 1.36±.045 |
| Single critic (M=1) | 0.77±.011 | 1.24±.034 |
| Barrier without dynamics learning | 0.77±.009 | 1.747±.041 |
| Dynamics learning without Barrier | 0.808±.007 | 2.002±.066 |
| SCARED | 0.625±.012 | 1.66±.01 |
The results show that dynamics learning, Q-Barrier, and the cost critic ensemble provide complementary benefits. The full Q-Barrier with four critics achieves both the highest return and the lowest cost . Reducing the ensemble to two or one critic lowers return and increases cost overall, although the cost is not strictly monotonic with ensemble size.
Removing dynamics learning further increases cost to and decreases return to , indicating that the barrier becomes less reliable when the latent representation does not capture temporal dynamics well. Conversely, dynamics learning without the barrier achieves relatively high return but produces the highest cost . These results show that dynamics learning alone does not ensure safety, while the barrier benefits from an informative latent representation and a better estimate. Combining dynamics learning with Q-Barrier and an ensemble of critics shows the best performance.
Why Dynamics Learning Helps. The effect of dynamics learning can be understood from how the barrier uses the latent state. At time step , the barrier filters candidate actions using the remaining budget and the estimated cost . The budget is directly observed, but the cost estimate depends on the learned latent state . Therefore, must keep the information needed for accurate cumulative cost prediction.
The original in-context state is , where contains past trajectories before episode and the current parital trajectories in episode . The next in-context state adds the new action, reward, cost, and state to the history. Since is a compressed form of this updated history, we use the dynamics loss to make consecutive latent states consistent over time . This helps keep useful information for the cost critic, even though the transition model is not used at deployment explicitly.
2. Negative-margin Selections
We thank the reviewer for requesting this diagnostic. With total 15,000 steps of executed actions:
| Benchmark | , all steps | when | No feasible candidate when |
|---|---|---|---|
| SafeDarkRoom | 1.6% | 0.9% | 0.8% |
| SafetyPointGoal | 1.3% | 0.2% | 0.1% |
| SafetyCarGoal | 2.0% | 0.4% | 0.3% |
| SafetyAnt | 4.5% | 2.7% | 2.6% |
| SafetyHalfCheetah | 25.8% | 22.5% | 20.7% |
An executed action can have for two reasons: (a) all candidate actions fail the barrier, (b) at least one candidate passes, but the soft shield still selects one that fails. The third column measures the first case. The difference between the second and third columns measures the second case. This difference is only 0.1 percentage points for DarkRoom, Point, Car, and Ant, and 1.8 points for HalfCheetah. Thus, almost all negative-margin selections occur because no proposed action passes the barrier, not because the soft shield overlooks an available alternative.
3. Candidate-set Sensitivity.
We thank for the reviewer to raise this question. To address it, we empirically measured whether the sampled candidate set contains at least one action with when the remaining budget varies, on executed 15,000 steps.
At most 25% of the episode's initial budget remaining case
| Benchmark | N=1 | N=4 | N=8 | N=16 | N=32 |
|---|---|---|---|---|---|
| SafetyPointGoal | 91.9% | 86.7% | 92.8% | 83.3% | 85.2% |
| SafetyCarGoal | 71.7% | 60.6% | 79.6% | 98.2% | 85.1% |
| SafetyAnt | 80.9% | 82.4% | 80.9% | 83.5% | 82.8% |
| SafetyHalfCheetah | 27.0% | 29.6% | 28.6% | 31.6% | 29.6% |
When the remaining budget is tight, increasing the number of sampled actions does not produce a clear or consistent improvement. In principle, a larger candidate set should make it more likely to include at least one feasible action, but the gain is small when already has a high feasibility rate.
There are still some gains in the harder cases. For example, in HalfCheetah and Ant, all settings with achieves a better feasibility rate than . In contrast, Point and Car already have relatively high feasibility and therefore show little consistent benefit from additional samples. Overall, candidate-set size has a limited effect compared with the difficulty of the environment and the remaining budget.
At least 75% of the episode's initial budget remaining case
| Benchmark | N=1 | N=4 | N=8 | N=16 | N=32 |
|---|---|---|---|---|---|
| SafetyPointGoal | 100.0% | 100.0% | 100.0% | 100.0% | 100.0% |
| SafetyCarGoal | 100.0% | 100.0% | 100.0% | 100.0% | 100.0% |
| SafetyAnt | 99.8% | 99.9% | 99.9% | 99.8% | 99.9% |
| SafetyHalfCheetah | 91.7% | 92.1% | 91.6% | 91.4% | 91.6% |
When at least 75% of the initial budget remains, a feasible action is almost always available for every candidate-set size. Point and Car achieve 100% feasibility, Ant remains above 99.8%, and HalfCheetah remains above 91%. Increasing has little effect in this case because even a single sampled action is usually feasible. HalfCheetah remains the most difficult benchmark, but feasibility is still high when the remaining budget is enough.
4. Action Cost-penalty Baseline
We thank the reviewer for the suggestion. We implemented and tested the baseline. The action cost-penalty baseline uses the same pessimistic cost critics but replaces the barrier with action reweighting, , and removes the latent-dynamics objective. We trained the baseline using the same rule during both collection and deployment.
First, we tuned for the baseline, while keeping for our method in all experiments presented in the paper.
| baseline Return | baseline Cost | |
|---|---|---|
| 0.1 | 0.647 ± 0.016 | 2.043 ± 0.063 |
| 0.5 | 0.643 ± 0.017 | 1.969 ± 0.061 |
| 1.0 | 0.634 ± 0.017 | 1.834 ± 0.056 |
| 2.0 | 0.590 ± 0.018 | 1.629 ± 0.047 |
| 5.0 | 0.434 ± 0.021 | 1.380 ± 0.038 |
| 10.0 | 0.128 ± 0.017 | 0.860 ± 0.034 |
We selected as the best return-cost trade-off and compare it with our method below.
| Method | Return | Cost |
|---|---|---|
| Full Q-Barrier | 0.898±.003 | 0.92±.034 |
| Barrier without dynamics learning | 0.77±.009 | 1.747±.041 |
| Baseline without dynamics learning | 0.634±.017 | 1.834±.056 |
Compared with the full model, the penalty baseline has approximately 100% higher average cost. In the no-dynamics learning comparison, the barrier improves return and cost by and respectively
The benefit is clearest when the budget is tight:
| Initial budget | Return | Cost |
|---|---|---|
| Low [1,4) | +.022 | -1.6 |
| Mid [4,7) | +0.13 | -1.5 |
| High [7,11) | +0.14 | -0.9 |
| Max [11,15] | +0.07 | +0.3 |
Here, is performance difference compared to the barrier. The barrier helps most when little budget is available and has little effect when the budget is enough. This matches its design: predicted safe actions receive no penalty, while actions predicted to exceed the remaining budget are penalized. In contrast, action cost-penalty baseline applies the same cost penalty regardless of how much budget left.
5. SafetyHalfCheetah Conservatism
We can rule out two possible causes, but we cannot fully separate the remaining two. First, varying the reweighting scale over barely changes the barrier margin or the negative-margin rate, so the scale is unlikely to explain the issue. Second, increasing the candidate-set size from to improves feasibility by less than two percentage points, indicating that additional samples do not resolve it.
Our main explanation is the combination of latent prediction error and the absence of candidates that satisfy the remaining-budget constraint. As reported in Figure 3 and Appendix B, HalfCheetah’s latent prediction error is 5 to 9 times larger than that of the other tasks. We also found that around 20% to 21% of positive-budget steps have no candidate that passes the barrier. Moreover, disabling the barrier at deployment does not recover the lost return. This suggests that the conservatism is learned during training. We will clarify this point in the revision.
We sincerely thank the reviewer for the constructive feedback. We hope the additional experiments and clarifications above address the main concerns. We would also be happy to provide further clarification or run additional experiments during the discussion.
Dear Reviewer CTBC,
We hope our rebuttal, including the additional ablations, diagnostic results for the barrier margin and action sampling, and baseline comparisons, was helpful in addressing your questions.
With the discussion period coming to an end soon, we would greatly appreciate hearing whether our responses addressed your concerns or whether any points remain! We would be happy to provide further clarification if anything remains.
Thank you again for your careful review and constructive feedback, which have helped us improve the paper!
Thank you for the detailed response and additional experiments. The new component ablations and action-cost-penalty baseline substantially improve the empirical analysis. In particular, they provide useful evidence that the latent dynamics objective, Q-Barrier mechanism, and critic ensemble make complementary contributions. The negative-margin and candidate-set diagnostics are also informative.
However, my central concern remains. The theoretical result is conditional on selecting an action with sufficient barrier margin and, in continuous control, on the realized finite candidate set. It therefore does not establish closed-loop safety for the deployed stochastic soft shield. The new diagnostics make this distinction especially relevant: in SafetyHalfCheetah, 25.8% of executed actions have negative margin, and when at most 25% of the initial budget remains, approximately 20.7% of steps have no feasible candidate. Increasing the candidate-set size does not materially resolve this issue.
The response to Question 2 reports the requested negative-margin frequencies, but it does not quantify their correlation with actual budget violations. The action-cost-penalty comparison is helpful, although it appears to be reported for only one benchmark, so it is difficult to determine how broadly the advantage generalizes. Finally, the SafetyHalfCheetah analysis provides plausible evidence involving latent prediction error and candidate infeasibility, but the two effects remain unresolved.
Overall, the rebuttal strengthens the empirical case for Q-Barrier as a useful learned risk-reweighting mechanism, but it does not change the conditional nature of the theory or establish a formal safety guarantee for the deployed policy. I therefore maintain my original score.
Thank you for the careful followup and for recognizing that the additional experiments improve the empirical analysis!
We agree that the theoretical result should be interpreted as a conditional barrier-margin analysis rather than as a closed-loop safety guarantee. In the revision, we will make this more clear. We will also include the additional ablations and diagnostic results from the rebuttal to improve the empirical analysis.
Thank you again for your careful review and constructive feedback, which have helped us improve the paper!
- Rating
- 5/6
- Confidence
- 5/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper tackles the problem of safe in-context reinforcement learning, where the task is to adapt to out of distribution tasks with frozen policy parameters. To do this, the agent maintains a history of the last few episodes during rollout to infer task cost and produce actions that minimize cost while maximising reward. The authors propose a Q-barrier based filtering method that learns a latent representation of the context (past episodes), dynamics and an ensimble of Q functions that predict the cost of an action. By applying pessimistic cost estimation and action reweighting during inference, their method assigns a barrier score to every action sampled (8 in the experiments). Based on the score, the actions are chosen. A positive barrier score indicates safe action, while a negative barrier score indicates potential violation. Experiments show that Latent Q barrier is able to adapt to OOD tasks in as low as 5 episodes.
Strengths and weaknesses
This is a well written and presented paper. The authors don't present their work as a novel idea, but rather a sound combination of various ideas that come together as an elegant solution to the safe ICRL problem. Here are the core strengths
-
Pessimistic action cost estimation by defining the cost as the maximum of the Q functions ensures the worst case. Following this up with the soft action selection is smart, because it prevents hard/greedy gating and allows exploration, which can prevent the agent from getting stuck in a global minima. Overall, this makes learning much easier that hard shielding problems which always discard policy action in favour of safety
-
Training all parts in conjuction is a very difficult problem. Splitting latent space into policy view and world view and stopping gradients so safety and dynamics modelling does not cause inference is a good solution.
-
The diagnostics in the appendix help with analyzing the failures and I appreciate the authors being transparent about the failures.
Weaknesses
-
Discretizing action selection for continuous actions using only 8 actions seems like a problem for more complex systems. (minor weakness, no need to address)
-
The latent dynamics head is purely there for representation learning and is not used anywhere else. Considering the filtering is only single-step safety, the dynamics should be used during runtime to help with filtering. It seems wasteful to let go of such a massive component that is essential for almost all look-ahead safety systems.
-
The experimental protocol seems a little off to me. Mujoco environments, safety gymnasium all have a timeout of 1000 steps. While I understand that a history of 20 episodes is needed to infer tasks and adapt, but a max episode length of 75 steps seems very low. Most of these agents stumble after 100-200 steps and they do not gain full velocity. This limits application to long horizon tasks like full Mujoco or safety gymnasium
However, this raises an important point. Is this method limited to 1500 steps in total? What happens when one extends the horizon, does it start to catastrophically fail? What if we reduce the context window to only 5-10 episodes? While results show that the task is learned in 5 episodes.
I looked into the SCARED paper and I am slightly concerned about figure 2. The plots look similar visually but the numbers don't corroborate. In SCARED Fig 2, the lines for SafetyPoint, SafetyCar, SafetyCheetah and SafetyAnt are perfectly mimiced in Fig2 of this paper, but they have been shifted down. I am not sure if this is an artifact of the different evaluation protocol or if the authors have reused the numbers from the SCARED paper. In any case, this is a major necessary clarification required in the experimental protocol.
-
It is not clear what is the contributing factor is. While using pessimism of the ensemble is a strength, it is unclear if this is the driving factor behind the improvement. Will SCARED improve if the algorithm was modified to use an ensemble? Or is the assymmetric latent architecture and representation learning fixing the main issue faced by SCARED? If the major heavy lifting is being done by the representation learning pipeline, then this paper presents itself as a better sequence modeling solution (this does not undermine the work and novelty factor of this paper, just clarifies what the true contribution/heavy lifter is). Thus, an ablation with having single Q function with Latent Q, or having multiple Q functions with SCARED would help a lot.
-
The Theorem 1 seems slightly incorrect. While it is standard to assume that the network has lipschitz continuity and that the error is within bound for the barrier propagation, I dont think this is fully accurate here. The latent space to have an accurate Q function might differ significantly from the latent space for the dynamics model. This might also be why safecheetah performed slightly worse, the high error in the dynamics model affected the latent representation and thus it affected the Q function output, leading to more unsafe actions. Going back to the theorem1, because the latent dynamics model is never used, the bellman error should not use the imagined latent state but the true latent state. It would have made sense if the critic/s was trained using the imagined latent state.
This reads more like the authors are trying to justify the use of learning the dynamics model, but it does not make sense given their inference pipeline
Considering that this is a deep RL paper than a control-theory motivated paper, I am willing to accept (5) this paper if the authors can modify the claims to remove the theory or justify their theoretical statements. Additionally, the discrepancy in Fig 2 needs to be clarified.
Please conduct experiments only if feasible. The most important experiments I consider are
- Using only 1 critic with Latent Q if it is a minor change to code, else only 2 critics.
- Removing dynamics learning
Questions
-
Why did you choose the number of critics as 4? Could 2 critics, or a single critic work? While SCARED uses a single critic and is outperfomed by Latent Q, it is unclear if the multiple critics play a role here. Can we get a plot of the intercritic distribution over time, or just the mean+std over an episode? That will help in understanding if the multiple Qs help here.
-
Does the context window need 20 episodes? Can we try ablating with less and more? 2, 5, 10, 20? I want to see if this is just a problem of learning with more sequences like LLMs or something different
-
To confirm, it doesn't seem like the dynamics is used at all. The dynamics model is its own supervised training loop without any gradient sharing with the Q functions, and used to shape the encoder. What happens when you remove the dynamics learning entirely?
Limitations
Yes
Final justification
All my concerns have been addressed. I have increased my score.
Formatting concerns
None
3 comments
Rebuttal
1. Latent Dynamics
We thank the reviewer for raising this question. We agree that the latent transition model is used only during training and not explicitly at deployment. However, even though the barrier does not use the transition model directly, the dynamics loss helps train the latent state used by the barrier.
At time step , the barrier filters candidate actions using the remaining budget and the estimated cost . The budget is directly observed, but the cost estimate depends on the learned latent state . Therefore, must keep the information needed for accurate future cumulative cost prediction.
The original in-context state is , where contains past trajectories before episode and the current parital trajectories in episode . The next in-context state adds the new action, reward, cost, and state to the history. Since is a compressed form of this updated history, we use the dynamics loss to make consecutive latent states consistent over time . This helps keep useful information for the cost critic, even though the transition model is not used at deployment explicitly.
| Method | Average Return | Average Cost |
|---|---|---|
| Full Q-Barrier | 0.898±.003 | 0.92±.034 |
| Barrier without dynamics learning | 0.77±.009 | 1.747±.041 |
Our empirical results also support this motivation. In SafeDarkRoom, adding the dynamics loss increases the return from 0.77 to 0.898 while reducing the cost from 1.747 to 0.92, as shown in the table. We will clarify the motivation and the role of the dynamics loss more clearly in the revision.
2. Episode Horizon in Experimental Protocol
We thank the reviewer for raising this concern. We first clarify that the horizon differs across the two benchmark families following [1].
For the Safety-Gymnasium goal tasks, Point and Car, the reported horizon of 75 refers to compressed policy steps rather than internal simulation steps. Following the macro-action protocol used in the original benchmark [1, Appendix C], each policy action is repeated for five internal simulation steps. Thus, a 75-step episode corresponds to 375 internal simulation steps.
For the MuJoCo velocity tasks, Ant and HalfCheetah, each episode contains 200 environment steps without macro-action compression, following the same benchmark protocol as [1].
We used the original benchmark horizons and hyperparameters in [1] to ensure a fair comparison. However, we agree that these per-episode horizons are shorter than the standard 1,000-step horizon. Our experiments therefore do not directly establish performance on full-length MuJoCo or Safety-Gymnasium tasks, and we will state this clarification explicitly in the revision.
[1] Moeini et al., “Safe In-Context Reinforcement Learning,” ICML 2026.
3. Figure 2.
We thank the reviewer for raising this important concern. We believe the original SCARED paper contains an error in Figure 2. Figure 2 reports the average episodic cost and cumulative adaptation return over in-context episodes, , and respectively.
For example, SCARED’s per-episode HalfCheetah returns in Figure 1 are approximately 200–250. Summing over 10 episodes should therefore produce a total return of roughly 2,000–2,500, which matches the scale of Figure 2’s y-axis. However, the original SCARED paper reports values above 4,000, which are inconsistent with Figure 1. We believe our reported results are correct, and we have notified the authors of this issue.
For the DarkMujoco experiments, the original SCARED paper evaluates 20 in-context episodes, whereas we initially reported 15 episodes because our method converged earlier. This difference in evaluation horizon changes the values shown in Figure 2. Here, we also report Figure 2 results using the original 20-episode in-context adaptation horizon.
Point
| Metric | Ours | SCARED |
|---|---|---|
| Cumulative Return | 11.26±0.21 | 10.52±0.19 |
| Average cost | 3.87±0.11 | 4.11±0.10 |
Car
| Metric | Ours | SCARED |
|---|---|---|
| Cumulative Return | 17.72±0.13 | 16.83±0.06 |
| Average cost | 3.13±0.11 | 3.14±0.07 |
4.Contributing Factors for Q-Barrier
We report the average return and cost over the 50 in-context episode over 100 evaluation rollout in SafeDarkRoom.
| Case | Average Return | Average Cost |
|---|---|---|
| Full Q-Barrier | 0.898±.003 | 0.92±.034 |
| Barrier without dynamics learning | 0.77±.009 | 1.747±.041 |
| Dynamics learning without Barrier | 0.808±.007 | 2.002±.066 |
| SCARED | 0.625±.012 | 1.66±.01 |
The results show that dynamics learning, and Q-Barrier provide complementary benefits. The full Q-Barrier with four critics achieves both the highest return and the lowest cost . Removing dynamics learning further increases cost to and decreases return to , indicating that the barrier becomes less reliable when the latent representation does not capture temporal dynamics well. Conversely, dynamics learning without the barrier achieves relatively high return but produces the highest cost . These results show that dynamics learning alone does not ensure safety, while the barrier benefits from an informative latent representation and a better estimate. Combining dynamics learning with Q-Barrier shows the best performance.
5. Theorem
We thank the reviewer for raising this important question. We believe Thereom 1 is correct under its stated assumptions. Its main insight is that a positive barrier margin at time propagates to a lower bound on the next-step value barrier, with some errors such as critic's Bellman residual. However, we agree that the realized next latent state is the more appropriate quantity, since the learned dynamics model is not explicitly used by Q-Barrier. We are completely open to removing the theoretical result from the final version if this is the consensus of the reviewers and the Area Chair.
6. Number of Cost Critics.
We thank the reviewer for suggesting this ablation. We used four cost critics () as a practical default, and evaluated while keeping the Latent-Q architecture and training setup fixed:
| Method | Return | Cost |
|---|---|---|
| SCARED | 0.625±.012 | 1.66±.01 |
| Full Q-Barrier (M=4) | 0.898±.003 | 0.92±.034 |
| Q-Barrier with Two critics (M=2) | 0.836±.006 | 1.36±.045 |
| Q-Barrier with Single critic (M=1) | 0.77±.011 | 1.24±.034 |
Even a single critic outperforms SCARED in both return and cost, showing that the improvement does not come only from ensemble pessimism. Increasing improves return overall, while achieves both the highest return and the lowest mean cost. However, cost is not strictly monotonic with ensemble size, since has lower cost than .
We also measured disagreement among critics at the executed actions over 500,000 decisions. The mean inter-critic standard deviation is for , and for , corresponding to approximately 1%–2% of the mean cost- magnitude. This disagreement remains nearly constant during adaptation, indicating that the critics stay closely aligned. We will add both the critic-count ablation and this disagreement diagnostic to the revision.
7. Test Beyond the Context Length
We thank the reviewer for raising this question. To address it, we added new ablations that evaluate performance beyond the training context length.
For the DarkMuJoCo environments, we extended in-context adaptation to up to five times the training horizon. Performance degraded substantially once the evaluation horizon exceeded the training range, revealing an additional challenge that is also commonly observed when language models are evaluated beyond their trained context lengths.
| k | Point: return/cost | Car: return/cost |
|---|---|---|
| 20 (train) | 0.64/1.74 | 0.91/1.45 |
| 50 (2.5×) | 0.56/4.94 | 0.04/0.20 |
| 100 (5×) | 0.34/11.55 | 0.05/2.34 |
We also trained a short-context model in SafeDarkRoom with a context length of 300, compared with 1,500 for the full-context model. Within its training range, the short-context model adapts faster and performs better early in the context. However, once evaluated beyond its training horizon, its performance degrades substantially, consistent with the DarkMuJoCo results.
| k | Return: full/short | Cost: full/short |
|---|---|---|
| 10 (train) | 0.75/0.83 | 2.38/1.15 |
| 20 (2×) | 0.96/0.70 | 0.71/2.31 |
| 50 (5×) | 0.98/0.53 | 0.62/4.66 |
These results show that extrapolating beyond the training context length remains difficult in Safe ICRL. They also reveal an unexpected tradeoff: shorter-context training improves early adaptation but reduces robustness when the evaluation context extends beyond the training range.
We sincerely thank the reviewer for the constructive feedback. We hope the additional experiments and clarifications above address the main concerns. We would also be happy to provide further clarification or run additional experiments during the discussion.
Thank you for the very thorough response to my comment. Majority concerns I have raised have been addressed. My recommendation is to keep theorem 1, but explicitly state that it relies on the assumption that the next latent state is the predicted state and not true state. Otherwise, it is correct as written. The assumption clarifies that theoretical guarantees are with respect to the learned dynamics model, which is standard in literature. The new experiments should also be a part of the final paper.
I am still concerned about the visually similar plots. It makes sense that the evaluation protocol from the prior authors is slightly different, but the absolute similarities in the 2 papers is a little surprising. If you could clarify that you have borrowed experimental data from the original authors, I will raise the score of this paper to an accept. As is, I am increasing my score to a weak-accept (will not be reflected until I can provide the final justification)
I commend the authors on their solution to this very difficult problem of ICRL.
Thank you for your time, for carefully considering our response, and for raising your score after our clarifications addressed your concerns.
My recommendation is to keep theorem 1, but explicitly state that it relies on the assumption that the next latent state is the predicted state and not true state. Otherwise, it is correct as written. The assumption clarifies that theoretical guarantees are with respect to the learned dynamics model, which is standard in literature.
Thank you for the suggestion regarding the Theorem. We will keep the theorem and, as suggested, add a clear statement that it assumes the next latent state is the predicted state, not the true state. We will also clarify that the theorem is with respect to the learned latent dynamics model.
The new experiments should also be a part of the final paper.
We will happily include the all new ablations presented during the rebuttal in the revised paper. In particular, the context-length experiments reveal an additional challenge in Safe ICRL: performance can degrade substantially when evaluation extends beyond the context length used during training. We thank the reviewer for this feedback, which helped us identify and better describe this limitation.
I am still concerned about the visually similar plots. It makes sense that the evaluation protocol from the prior authors is slightly different, but the absolute similarities in the 2 papers is a little surprising. If you could clarify that you have borrowed experimental data from the original authors, I will raise the score of this paper to an accept.
To clarify the remaining concern about Figure 2, the SCARED curves use the original experimental data provided directly to us by the SCARED authors after we contacted them.
Again, thank you so much for your time and constructive feedback in improving the paper!
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Rebuttal
1. Architecture and Component Contributions
We thank the reviewer for this suggestion. In the revision, we will add a complete architecture diagram showing the encoder, policy and world projections, policy, latent dynamics model, cost-critic ensemble, and Q-Barrier. The diagram will also indicate which modules are updated by each training loss and make clear that the latent dynamics model is used during training but not explicitly by the deployed barrier.
In addition, we conducted ablations to separately study the contributions of latent dynamics learning, the Q-Barrier, and the cost-critic ensemble. The table reports the average return and cost over 50 in-context episodes and 100 evaluation rollouts in SafeDarkRoom. Here, M denotes the number of cost critics.
The results show that dynamics learning, Q-Barrier, and the critic ensemble provide complementary benefits. The full Q-Barrier with four critics achieves both the highest return 0.898 and the lowest cost 0.92. Reducing the ensemble to two or one critic lowers return and increases cost overall, although the cost is not strictly monotonic with ensemble size.
Removing dynamics learning further increases cost to 1.747 and decreases return to 0.77, indicating that the barrier becomes less reliable when the latent representation does not capture temporal dynamics well. Conversely, dynamics learning without the barrier achieves relatively high return 0.808 but produces the highest cost 2.002. These results show that dynamics learning alone does not ensure safety, while the barrier benefits from an informative latent representation and a better QC(Zt) estimate. Combining dynamics learning with Q-Barrier and an ensemble of critics shows the best performance.
Why Dynamics Learning Helps. The effect of dynamics learning can be understood from how the barrier uses the latent state. At time step t, the barrier filters candidate actions At using the remaining budget Bt and the estimated cost QC(Zt,At). The budget Bt is directly observed, but the cost estimate depends on the learned latent state Zt. Therefore, Zt must keep the information needed for accurate cumulative cost prediction.
The original in-context state is (Stk,Htk), where Htk contains past trajectories before episode k and the current parital trajectories in episode k. The next in-context state adds the new action, reward, cost, and state to the history. Since Zt+1 is a compressed form of this updated history, we use the dynamics loss to make consecutive latent states consistent over time t. This helps Zt keep useful information for the cost critic, even though the transition model is not used at deployment explicitly.
2. Training versus Deployment
We thank the reviewer for requesting this clarification. The treatment differs by action space. In discrete environments, evaluating all actions is inexpensive, so the soft Q-barrier is active during training. In continuous environments, we use N=1 during training. Because the only candidate is the base-policy action, the shield cannot change the collected action and is effectively inactive for action selection. However, the encoder, representation losses, latent dynamics, and cost critics are still trained from these trajectories to active the barrier at deployment.
At deployment, all parameters are frozen. For continuous actions, the shield samples N=8 candidates by default and reweights them using the learned barrier. This avoids the cost of evaluating multiple candidates at every training step while preserving representation and critic learning. We will clarify this distinction in the training algorithm and implementation details. We vary N in the candidate-size ablation. reported in Figure 5 and Appendix D.
3. Policy objectives
We thank the reviewer and agree that these terms need clearer definitions. Let Ztk be the shared latent state, Ztp,k and Ztw,k its policy and world projections, Atk the replay-buffer action, and A~tk∼πθ(⋅∣Ztp,k) an action sampled from the current policy. We define $\bar Q_R(Z,A)= \frac{1}{M}\sum_{i=1}^M \hat Q_{R,i}(Z,A)$ and $V_R^\pi(Z_t^k)=\mathbb E_{\tilde A\sim\pi_\theta(\cdot\mid Z_t^{p,k})} \left[ \bar Q_R(Z_t^k,\tilde A) \right],$ and the advantage of the replay action as Adv=QˉR(Ztk,Atk)−VRπ(Ztk).
$\mathcal L_{\mathrm{DPG}} = -\mathbb E_{k,t} \left[ \min_i \hat Q_{R,i}(Z_t^k,\tilde A_t^k) \right].$
LAWBC=−Ek,t[1(Adv>0)logπθ(Atk∣Ztp,k)].
$\mathcal L_C^\pi=\mathbb E_{k,t}\left[\max_i \hat Q_{C,i}(Z_t^{w,k},\tilde A_t^k) \right] = \mathbb E_{k,t} \left[ \hat Q_C^+(Z_t^{w,k},\tilde A_t^k) \right].$
The terms serve different roles. LDPG improves reward using a conservative reward estimate. LAWBC stabilizes off-policy learning by copying only replay actions estimated to be better than the current policy. LCπ discourages actions with high predicted cost. We will clarify these definitions and their distinct roles after Algorithm 1 in the revision.
4. Conjugacy loss
We thank the reviewer for asking this question.
The world projection learns transition structure through the dynamics, reward, and cost losses, while the policy projection may learn a different latent representation. Lconj aligns their temporal changes:
gp(Zt+1)−γgp(Zt) and sg[gw(Zt+1)−γgw(Zt)].
This encourages the policy and world projections to represent transitions consistently.
Empirically, removing the conjugacy loss causes only a small decrease in return, although the cost increases. This may be because Ldistill still provides an additional alignment signal without the conjugacy term.
5. Sensitivity to Cost-Critic Miscalibration
In Q-Barrier, miscalibration can cause all sampled actions to be marked infeasible, bQ<0, even when some budget left. We therefore measured how often the candidate set contains at least one feasible action as the remaining budget and candidate-set size vary. We used 15,000 executed steps for all environments.
At least 75% of the episode's initial budget remaining case
When at least 75% of the initial budget left, a feasible action is almost always available: 100% for Point and Car, 99% for Ant, and about 88% for HalfCheetah. These rates change little across N.
At most 25% of the episode's initial budget remaining case
When the budget becomes tight, the rates decrease, especially on HalfCheetah. Increasing the candidate-set size from N=1 to N=32 does not consistently improve feasibility on any benchmark, even though on Ant and HafCheetah case, N≥4 has always better feasibility than N=1. The changes are small and have no clear direction. Thus, the loss of feasible actions is mainly caused by the cost estimate, not by too few candidates.
Across all steps with positive remaining budget, the Barrier fails to find a feasible action on 0.2% of Point steps, 0.3% of Car steps, 0.8% of SafeDarkRoom steps, 2.6% of Ant steps, and 20.7% of HalfCheetah steps. HalfCheetah is a clear outlier. On the other four benchmarks, this failure is rare. Even on HalfCheetah, it mainly occurs when the remaining budget is small, where a fixed error in QC is more likely to change the sign of bQ=B−QC+.
One limitation is that directly measuring critic bias requires comparing predicted cost-to-go with realized Monte Carlo cost-to-go on the same scale. Because our cost critics are trained with normalized targets, we do not report this value here. We will add this calibration analysis in the revision.
We sincerely thank the reviewer for the constructive feedback. We hope the additional experiments and clarifications above address the main concerns. We would also be happy to provide further clarification or run additional experiments during the discussion.