Testing Whether Synthesized Reward Code Actually Encodes "Don't"

Language and vision-language models are now routinely asked to write reward functions, the small programs that tell a reinforcement-learning agent what counts as good behavior. The appeal is that code can be read and audited, unlike a neural reward model. Real task instructions, however, are full of prohibitions: "put the cube in the bin without touching the vase," "reach the goal but never cross the lava." Separate literatures show that models are unreliable with exactly this kind of instruction. They ignore negation operators, they are primed by the forbidden words themselves, they change their answers under harmless rephrasings, and when they look at images they report objects that are not there. Nobody has measured what these failures do to the reward code. The program can look reasonable and still contain no working penalty for the forbidden behavior.

This note makes a specific claim. The verification step that current code-as-reward pipelines use cannot catch missing or broken prohibitions, for a structural reason. That step checks whether the code accepts expert trajectories and rejects random ones. Experts already obey the constraint, and random trajectories rarely complete the goal, so neither set exercises the penalty. We propose a violation-contrast test to close this gap. For every prohibition we build trajectories that complete the goal while breaking exactly that prohibition, and we require the reward to rank each one below its compliant twin. We pair this test with a measure of how much the reward's behavior changes across paraphrases of the instruction. Together they give a cheap, offline detector and a repair loop for negation failures in synthesized rewards.

Background and Where This Sits

The reward-synthesis side supplies the method we extend and the weakness we target. Text2Reward prompts GPT-4 with Python abstractions of a simulator and obtains staged reward code that matched or exceeded human-written rewards on 13 of 17 ManiSkill2 tasks. It sometimes infers implicit penalties, such as tilt, but it relies on human feedback when a constraint is misformulated. Code as Reward (VLM-CaR) has a vision-language model write verification scripts from start and goal frames, then unit-tests each script against a few expert and 100 random trajectories. That test is the procedure our proposal argues is blind to prohibitions. Generating and Evolving Reward Functions for Highway Driving argues that code transparency lets engineers confirm safety terms exist. We test whether a term that is present actually functions, which is a stronger requirement than being visible on inspection.

The negation literature supplies the expected failure. Instructions that name a forbidden concept raise that concept's probability, as discussed in Controlled Text Generation via Language Model Arithmetic. Negative examples in instructions tend to be copied rather than avoided, per Cross-Task Generalization via Natural Language Crowdsourcing Instructions. Text-to-audio models attend to nouns and skip "no"/"without", per AudioGenX. How Language Models Process Negation locates the problem mechanistically: mid-layer computation builds the negated meaning, and late-layer shortcut heads override it. Ablating those heads raised Llama-3.1-8B accuracy on negated prompts from 50.5% to 67.8%. These papers motivate our hypothesis that reward code will drop or invert penalties.

LLM-MatLogic is a constraint on design. It shows that negation applied as a post-hoc filter causes scope drift, and that banned sets must be stated explicitly and applied at a fixed point in execution. We borrow its separation of "what to achieve" from "what is banned," moving it from knowledge-graph queries to reward programs.

The prompt-sensitivity literature supplies the second signal. Rethinking Hallucinations: Correctness, Consistency, and Prompt Multiplicity shows that paraphrases change instance-level answers on over 50% of items. It also finds that entropy and self-check track this inconsistency rather than correctness. On the Relation between Sensitivity and Accuracy in In-Context Learning turns paraphrase instability into an abstention rule, SENSEL, which beat MaxProb and entropy by +4.1 AUC points on GPT-J-6B. The known cost of such methods is repeated inference. Reward synthesis happens once, before training, so here the cost is paid once rather than at every step.

The multimodal-hallucination literature supplies a third failure mode specific to vision-based synthesis. Models answer "yes" to object-presence questions at rates near 99% in some settings (Evaluating Object Hallucination in Large Vision-Language Models), and language priors override visual evidence (HalluTrace). An instruction that names an absent object ("don't knock over the cup") is exactly the leading question that triggers this bias. The likely result is a "cup detector" that fires on some red blob. IRIS also connects rewards and hallucination, but its reward is an implicit log-probability ratio used to train the model itself, not inspectable code supervising an agent.

Core Claim

Synthesized reward programs fail on prohibitions in three measurable ways. A penalty may be omitted, so the code has no term for the banned behavior. A penalty may be inert, meaning the term exists but its predicate never fires on actual violations, or its magnitude is too small to change which behavior is optimal. A penalty may be ungrounded, meaning it references an object hallucinated from the instruction rather than seen in the scene. Expert-versus-random unit tests are blind to all three.

The violation-contrast test catches the first two. A grounding check on the constraint's referent, for which the absent-object version of the task gives ground truth, catches the third. Behavioral disagreement across instruction paraphrases predicts which programs fail, before any agent is trained.

Research Program

The first component is a benchmark of constrained tasks built on environments the file already covers. We will use MiniGrid (lava and forbidden-tile variants, as in VLM-CaR) and ManiSkill2 and MetaWorld (keep-out zones, contact bans and tilt limits, as in Text2Reward). Each task is designed so that the constraint binds: the shortest goal-reaching behavior violates it. A goal-only policy then naturally produces violating trajectories.

Each instruction comes in a family of paraphrases that vary the form of negation: explicit ("do not enter"), adverbial ("never"), lexical ("keep the vase untouched"), and affirmative ("stay in the left half"). This variation also addresses the subtle-negation forms that the mechanistic negation work leaves unexplored. A matched absent-referent version removes the forbidden object from the scene, and a shared-color distractor version targets VLM-CaR's admitted weakness.

The second component is the trajectory bank and the test itself. For each task we collect expert compliant trajectories, random trajectories, and goal-completing violators. Violators come from a policy trained on a goal-only reward and from minimal edits to expert trajectories that cross the forbidden region. Each violator is paired with a compliant twin of similar length and goal progress.

A reward program $R$ passes the violation-contrast test for constraint $c$ if $R(\tau^{+}) - R(\tau^{-}_{c}) > \delta$ on at least a fraction $\alpha$ of pairs. Here $\tau^{+}$ is a compliant trajectory, $\tau^{-}_c$ its twin that violates only $c$, and $\delta$ is a margin set relative to the reward's goal-progress scale, so that a penalty too weak to change the optimum fails. In the absent-referent version, the grounding check additionally requires the constraint predicate to fire on no trajectory.

The third component is reward multiplicity, the cross-paraphrase signal. We synthesize one program per paraphrase, run all of them on the shared trajectory bank, and measure the fraction of trajectory pairs whose ordering differs across programs. This mirrors the ambiguity measure of Rethinking Hallucinations, but applies it to program behavior rather than text. Comparing executions also means that syntactically different programs that compute the same ranking count as agreeing.

The fourth component is repair. Synthesis is structured as a goal program plus an explicit banned-predicate list, following LLM-MatLogic's separation. Any predicate that fails its contrast or grounding test is returned to the model with the failing trajectory pair, and the model rewrites only that predicate. A small diagnostic arm on open-weight Llama-3.1-8B applies the shortcut-head ablation from How Language Models Process Negation during synthesis. It asks whether omission rates fall when the late-layer override is removed, which would tie code-level failures to the known internal mechanism.

Baselines

The naive reference is single-shot synthesis in the style of Text2Reward: one instruction, one program, no testing, given the same environment abstractions. For the vision tasks, single-shot VLM-CaR-style synthesis from frames plays the same role. This is what practitioners do today. The question it answers is how often prohibitions are silently broken when no one checks.

The strongest existing competitor is VLM-CaR's own verification loop: test against expert and random trajectories, refine on failure, with the same number of refinement rounds and the same synthesis model as our method. It is the only published automated verifier for synthesized reward code in the file, so beating it is the central comparison. VLM-CaR reports qualitative wins, solving DoorKey8x8 and Unlock-v0 where sparse-reward PPO failed, and gives no numerical success percentages. No reported result was found on Lacuna for VLM-CaR or any method on negative-constraint reward synthesis. We therefore anchor the scale of the comparison with Text2Reward's report of matching or exceeding human oracle rewards on 13 of 17 ManiSkill2 tasks, and we treat human-written rewards with correct penalties as an upper reference. Beating VLM-CaR means detecting a substantially larger share of omitted, inert and ungrounded penalties at a matched false-alarm rate on compliant programs, and translating that into lower violation rates for agents trained with PPO on the repaired rewards, at equal goal success.

The third baseline is paraphrase majority vote: synthesize from all paraphrases and keep the program whose behavior agrees most with the others. This uses multiplicity without contrast tests and receives the same synthesis budget. The fourth is affirmative rewriting: the model first restates every prohibition as a positive constraint, then synthesizes, which tests whether the problem is purely linguistic.

Two ablations isolate the key ingredient. One runs our full pipeline with goal-completing violators replaced by additional random trajectories. If that ablation matches the full system, the claim that violators are essential is false. The other drops the grounding check, to measure its separate effect in the absent-referent and distractor versions. All arms share models, environments, trajectory banks, PPO seeds and hyperparameters, and a fixed cap on synthesis calls.

Why not just…?

Why not just use VLM-CaR's expert-and-random unit tests, which already verify reward code? Those tests check that experts score high and random behavior scores low. A program with no penalty at all scores experts high, because experts complete the goal, and random behavior low, because random behavior does not. It therefore passes. The ablation that swaps violators for random trajectories tests this directly. Our prediction is that it recovers almost none of the inert or omitted penalties, and if it does recover them, our core claim is wrong.

Why not just rephrase every prohibition affirmatively before synthesis? This is a real threat. Negation-blindness evidence suggests the trigger is the negation operator and the salient forbidden noun, and MAQA (MAQA) found that diverse phrasings helped substantially. Rewriting may well reduce omission. It cannot, however, detect inert penalties with bad thresholds, and it does nothing for hallucinated referents, since "stay away from the cup" still presupposes a cup. The affirmative-rewrite arm settles this. If it closes the omission gap, we report that rewriting is the right generation fix and that the contribution reduces to verification. We would then combine the two methods rather than compete with rewriting.

Why not just sample many programs and take the majority? Rethinking Hallucinations shows that consistency is not correctness. A model that consistently ignores "without" will produce a consistent majority with no penalty. The majority-vote baseline measures how often this happens. We expect reward multiplicity to work as a cheap early warning but not as a replacement for the contrast test. The evidence would be correlation between multiplicity and contrast-test failure, together with a residual set of consistent-but-wrong programs that only the contrast test catches.

Why not just use a bigger model? MAQA found that scaling from 580M to 3.7B parameters did not fix negation. ProSA (ProSA) found GPT-4o more prompt-sensitive than Llama 3-70B-Instruct. We run every arm with both an open-weight model and a stronger API model to see whether failure rates fall with scale. Even if they fall, the test remains the way to know which programs to trust.

Decisive Checks

Three results decide the project. The first establishes that the problem exists: on single-shot synthesis, a non-trivial share of programs should fail the violation-contrast test while passing VLM-CaR-style tests, with higher failure for adverbial and lexical negation than for affirmative phrasing. The absent-referent version should yield predicates that fire on scenes without the named object, mirroring POPE's yes-bias. The second establishes that the method works: repaired rewards should lower constraint violation in trained agents without lowering goal success, relative to VLM-CaR's loop under the same budget. The third tests the predictive signal: reward multiplicity should predict contrast-test failure better than the synthesizing model's token entropy, extending to code the finding from Rethinking Hallucinations and SENSEL that perturbation-based signals beat probability-based ones. If violators add nothing over random trajectories, or affirmative rewriting alone eliminates all three failure types, the proposal's central claim should be abandoned.