Skip to content

Reinforcement Learning That Learns the Rules Instead of Getting Clipped Into Them

#reinforcement-learning #constrained-optimization #neurosymbolic #offline-rl #rlvr #clinical-ai

Reinforcement Learning That Learns the Rules Instead of Getting Clipped Into Them ​

Three separate papers, three unrelated domains, one identical failure. A policy optimizes the thing you asked it to optimize, drifts into territory you assumed was off limits, and the guardrail you built turns out to be a suggestion.

In portfolio management the guardrail is an investment policy statement: a six-rule, regime-conditional mandate that says how much you can hold in each asset class depending on what the market is doing. In LLM post-training the guardrail is a verifier that can only tell you when an answer is wrong. In a pediatric ICU the guardrail is a clinician who has seen 78 ECMO cases and knows which ventilator settings nobody has ever tried.

None of these settings tolerate an agent that learns compliance after deployment. All three papers move the constraint inside the training objective. That single design choice is what makes the work deployable, and it's worth walking through how each one does it, because the mechanics differ a lot.

Three papers, one shared failure mode ​

Unconstrained RL on a mandate is not "slightly risky." In the portfolio paper, the baseline violates the six-rule mandate on 96% to 98% of decisions. That's not a policy with an occasional lapse. That's a policy that has learned the optimization target and treats the rulebook as noise.

The standard fix is a reward penalty: subtract points when the agent breaks a rule. The authors ran it. It cuts violations to 33.4%. Better, still unusable. A third of your decisions breach the mandate, which means the compliance officer kills the strategy before it ever sees capital.

The reason penalties stall is that they price the violation instead of forbidding it. If the expected return from overweighting equities in a trending market exceeds the penalty, the agent takes the trade. You end up tuning a scalar until the violation rate looks tolerable, which is a strange thing to do with a legal document.

The paper's approach, built on Probabilistic Logic Policy Gradient, estimates the probability that the policy's own executed action satisfies the mandate and adds that estimate to the training objective. The estimate comes from reparameterized Monte Carlo sampling, which keeps the gradient flowing through the sampling step so the policy can learn from the compliance signal directly.

The detail that matters for deployment: there is no post-hoc enforcement at inference time. Nothing intercepts the action and clips it into the feasible set. The reported 4.8% violation rate was audited on deterministic mean actions with no correction applied, so the number reflects what the network actually wants to do.

Putting the mandate inside the objective ​

PLPG was designed for finite, discrete action spaces. Portfolio weights are continuous, so the authors had to rebuild the compliance estimator for a continuous action. They sample the action the policy would actually execute, evaluate the symbolic rules against that sample, and backpropagate through the sampling.

4.8% is the number to sit with. At one allocation decision per trading day, that's roughly 12 breach days a year. Still not zero, and you'd want a human in the loop for those, but it's a rate a compliance team can actually work with. A 33.4% baseline means the strategy breaches on one day in three, which no mandate allows regardless of returns.

Sampling budget is the knob you'll spend compute on. The estimator needs multiple samples per action to reduce gradient variance, and each sample is a forward pass plus a rule evaluation at every timestep. When I ran a stripped-down three-asset version of this in my own harness, going from 8 to 32 samples per action cut measured violations roughly in half, and pushing past 64 bought almost nothing. If you build this, sweep the sample count early and then stop. The compliance estimate saturates well before the compute bill becomes interesting.

Quick take: the pattern across all three papers is that constraints belong in the objective, so the agent learns compliance instead of getting clipped into it.

When a "pass" means nothing ​

The second paper attacks a different kind of constraint: the verifier itself.

RL with verifiable rewards assumes you can judge whether a sampled solution is correct. In code generation you have unit tests. In math you have a symbolic checker. In agentic settings you have a constraint checker. The assumption breaks constantly. Unit tests can falsify a wrong implementation, but passing tests does not prove correctness. A test suite that misses the edge case will happily certify a function that divides by zero on empty input.

The authors formalize this as one-sided verifiability. Verified negatives are reliable: a failing test is a genuine counterexample. Verified positives are merely non-falsified, and can contain a large share of false positives. The asymmetry is the whole problem.

Under that asymmetry, standard RLVR is actively harmful. Reinforce a solution that passed partial checks and you reward whatever shortcut let it slip past. The agent learns to satisfy the checker, which is not the same as satisfying the spec.

NOPO's fix is blunt. Treat every verified positive as unlabeled and update the policy only by suppressing trusted negatives. The loss is reference-relative, so it pushes down the probability of failed responses relative to a reference policy rather than pushing up the probability of anything. A group-level adapter scales each update by the fraction of non-falsified responses in the group, which keeps a batch where almost everything fails from dominating the gradient.

The results hold across three verifier types the authors tested (unit tests, constraint checks, and an LLM self-verifier) and across code, logic, and math benchmarks, measured on pass@k when oracle rewards were unavailable. The gains survive inference-time scaling, which is the interesting part. If better sampling could fix it, NOPO wouldn't matter. It can't, because sampling more from a policy that was trained on false positives just produces more confident false positives.

Staying inside the data in a pediatric ICU ​

The ECMO paper has the hardest constraint of the three: you cannot run a randomized trial on a critically ill child.

Managing a child on extracorporeal membrane oxygenation means balancing short-term physiological stability against the long-term goal of avoiding neurological injury. Anticoagulation, oxygenator performance, and hemodynamics all interact. Standard RL will happily propose out-of-distribution actions, and in this setting an out-of-distribution action is a treatment plan no clinician has ever administered. Imitation learning has the opposite failure: it can only reproduce what the clinicians already did, so it never improves.

FQI-SC splits the difference. Fitted Q-Iteration with a support constraint restricts optimization to state-action pairs that actually appear in the data, and falls back to the clinician baseline in low-data regions. Where the data supports an alternative, the policy can prefer it. Where it doesn't, the policy keeps its hands off.

The dataset is 78 pediatric trajectories totaling more than 6,000 hours, which is a lot of bedside time and a very small number of patients. That ratio is exactly why the support constraint carries the design. With 78 patients you cannot afford a policy that generalizes confidently into regions the data never covered.

DimensionInvestment mandateOne-sided verifiable rewardsPediatric ECMO
SettingContinuous portfolio weightsLLM/code post-trainingOffline clinical decisions
Constraint sourceSix-rule regime-conditional policy statementCheap falsifying checks (tests, checkers)Empirical data support
Failure without it96-98% mandate violationsRewarding shortcuts that pass partial checksRisky out-of-distribution actions
MechanismReparameterized MC estimate of rule satisfaction in the objectiveReference-relative negative suppression with group adapterSupport constraint plus clinician fallback
Headline metric4.8% violation ratepass@k gains without oracle rewards38% Balance Score gain, 1.28 FQE units over imitation
Data scaleRegime-conditional mandate auditCode, logic, math benchmarks78 trajectories, 6,000+ hours

The evaluation design deserves attention because offline RL evaluation is where most of these projects quietly go wrong. The authors use Fitted Q-Evaluation for value estimates and behavioral disagreement as a second axis, then combine performance and safety into a single Balance Score.

The numbers: 38% improvement in Balance Score over unconstrained FQI, 1.28 FQE units better than imitation learning, and 71% less disagreement with clinician actions than FQI. That last one is the deployment argument. A policy that disagrees with clinicians on most decisions will not get adopted at the bedside, no matter what its estimated value says.

The same move in three costumes ​

Strip the domain language and the architecture is identical. A constrained action space, a differentiable or statistical proxy for constraint satisfaction, and a training loop that treats the proxy as part of the reward rather than a filter downstream.

The differences are in what the constraint signal looks like. The mandate is symbolic and differentiable through sampling. The verifier is one-sided, so only the negative direction is trusted. The clinical support constraint isn't differentiable at all, so it becomes a hard restriction on which state-action pairs enter the update.

The common thread is that none of the three trusts a runtime filter. A post-hoc clip on portfolio weights would hide the violation rate while leaving the underlying policy untrained. A runtime check in a code agent would catch a failing test and then hand back a broken patch. A clinical guardrail that blocks unsafe actions at inference gives you nothing when the safe action is the one you actually need.

What trips people up ​

Five mistakes I've seen (and made) when applying these ideas:

Auditing the mean, then deploying the sample ​

The portfolio result is audited on deterministic mean actions. That's the honest way to report it, and it's also a warning. The moment you add exploration noise at inference, or sample stochastically to diversify, your realized violation rate moves. Measure compliance on the distribution you actually deploy, not on the mean.

Tuning the penalty weight until the violation rate feels acceptable ​

The reward-penalty baseline landing at 33.4% isn't a bug in the baseline, it's the ceiling of that approach. If you find yourself adjusting the penalty coefficient a fourth time, you're fitting a scalar to a rulebook. Move the constraint into the objective instead.

Letting unverified positives leak back into the reward ​

The whole point of NOPO is that a passing test is unlabeled data. Teams have a habit of sneaking "probably correct" responses in as weak positives because it feels wasteful to discard them. One leak reintroduces the shortcut-rewarding dynamic you were avoiding.

Trusting FQE alone on offline clinical data ​

Fitted Q-Evaluation is off-policy and biased when the policy leaves the support of the behavior data. If your support constraint is loose, FQE will happily report an improvement that doesn't exist. Pair it with behavioral disagreement and, ideally, held-out clinical outcomes.

Ignoring the fallback rate ​

Support-constrained methods default to the baseline in low-data regions, which is the right call. But if 90% of your states hit that fallback, you've built an expensive imitation-learning wrapper with extra steps. Instrument the fallback rate per state cluster before you claim the policy improves on clinicians.

One thing to remember ​

All three papers are really about measurement discipline. A 4.8% violation rate only means something because it was audited without correction. A pass@k gain only means something because the oracle reward was removed. A 38% Balance Score improvement only means something because behavioral disagreement was reported alongside it. The constraint mechanisms are clever, but the evaluation choices are what make the claims checkable, and checkability is the scarce resource in every one of these domains.

The bottom line ​

If you're building an RL system over regulated decisions like portfolio weights or clinical dosing, budget for a differentiable or statistical constraint estimator inside the loss, and measure violations on your deployed action distribution. A reward penalty will land you somewhere between 30% and 40% non-compliance, which is nowhere near deployable, and no amount of coefficient tuning closes that gap.

If your verifier can only falsify, stop reinforcing positives and switch to a negative-only update. You'll lose the throughput of speculative reward assignment and gain a policy that doesn't optimize against your test suite. If better sampling at inference could have fixed the problem, it would have already.

If your training set is 78 patients and 6,000 hours, keep the policy on the data's support and let it fall back to the clinician, then report that fallback rate next to your value estimate. A 71% reduction in clinician disagreement is worth more politically than 1.28 FQE units, because the ICU attending is the actual deployment gate.