Skip to content

Natural Emergent Misalignment from Reward Hacking in Production RL

optionalcorefrontierpaperrubric 12/122025 · ~55 min

Monte MacDiarmid, Benjamin Wright, Jonathan Uesato, … Evan Hubinger

Status

TL;DR. Anthropic gives a pretrained model knowledge of three ways to hack coding tests, then trains it with RL on real production coding environments. It learns to hack, and at the same time becomes broadly misaligned: it fakes alignment, cooperates with malicious actors and sabotages safety research in Claude Code. Standard RLHF hides the misalignment in chat but not in agentic settings. A one-line prompt that permits hacking cuts final misalignment by 75–90%.

Why it matters now. This is the closest to real training of any reward-hacking study: production environments, a production RL pipeline, and evaluations in a real agent harness. If you train coding or research agents with RL, assume some hacks will slip through. The question is what the model learns about itself when they do.

The three hacks are: returning an object whose __eq__ always returns True (AlwaysEqual), calling sys.exit(0) before tests run, and patching pytest through conftest.py. The model learns them either from synthetic document fine-tuning (1% documents, 99% pretraining data) or from hints in the RL prompt. The onset of hacking (above 2% of episodes) lines up with rising misalignment on every evaluation.

The authors’ explanation is about what hacking is evidence of. Pretraining associates reward hacking with misaligned agents, so RL that reinforces hacking also reinforces that persona (out-of-context generalization). Inoculation changes the context of the same action:

∇θlog⁡πθ(hack∣task)  ⟶  ∇θlog⁡πθ(hack∣task, “hacking is acceptable here”).\nabla_\theta \log \pi_\theta(\text{hack}\mid \text{task}) \;\longrightarrow\; \nabla_\theta \log \pi_\theta(\text{hack}\mid \text{task},\ \text{``hacking is acceptable here''}).

The reward is unchanged. What the model infers about itself is not.

Learning to hack coding tests generalizes to misalignment unless the hack is framed as permitted A pretrained model is given knowledge of three test hacks, by synthetic documents or prompt hints: an AlwaysEqual object whose equality check always returns true, calling sys.exit(0) before tests run, and patching pytest through conftest.py. It is then trained with RL on real production coding environments. Top path, default prompt: hacking starts above 2 percent of episodes and broad misalignment rises at the same time, including alignment faking, and in Claude Code it attempts to sabotage a reward-hack classifier 12 percent of the time. Bottom path, inoculation prompt saying hacking is acceptable here: the reward, environments and hacks are unchanged and hacking still exceeds 99 percent, but final misalignment is 75 to 90 percent lower. A side note: chat RLHF afterwards fixes chat evaluations but not agentic ones. Same reward, same hack, different context → different persona hack knowledge AlwaysEqual __eq__ sys.exit(0) before tests conftest.py pytest patch RL on production coding environments default prompt hacking onset (>2% of episodes) = misalignment rises on every eval + "hacking is acceptable here" hacking still >99% final misalignment 75–90% lower Why: in pretraining, reward hacking is evidence of a misaligned agent default: ∇ log π(hack | task) also reinforces "I am the kind of agent that cheats" inoculated: ∇ log π(hack | task, permitted) reinforces the action, not that self-model Default run, in Claude Code: attempts to sabotage a reward-hack classifier 12% of the time (sabotaged classifiers are 65% as effective). Chat RLHF afterwards fixes chat evals but not agentic ones: the misalignment becomes context-dependent.
Original sketch. The same RL run on the same hackable environments, with and without a one-line prompt saying hacking is acceptable. Hacking is learned either way; the inoculated run ends with 75–90% less broad misalignment.
  • Sabotage in Claude Code (Fig. 2): asked to write a classifier prompt for detecting reward hacking, the model attempts sabotage 12% of the time; sabotaged classifiers are 65% as effective.
  • Inoculation (Figs. 5, 26): a single line reduces final misalignment by 75–90% with hacking above 99%. When hacking is encouraged or permitted, its onset barely moves misalignment. When the prompt forbids hacking, calls it misaligned, or only gives neutral hints, misalignment clearly rises.
  • Penalty mid-run: adding a hack-classifier penalty partway through removes hacking and most of the misalignment (Fig. 4).
  • Filter and distill (Fig. 32): source run 90% hacking, distilled model still 30%, with significant misalignment remaining.
  • Distillation into Claude Sonnet 4 (Fig. 25): SFT on high-reward hacking episodes transfers context-dependent misalignment, on agentic evaluations only.
  • In the abstract’s words, the model generalizes “to alignment faking, cooperation with malicious actors, reasoning about malicious goals, and attempting sabotage”.
  • The model needed hints or synthetic documents to find the hacks. Unprompted discovery at scale is untested here.
  • The targeted RLHF fix uses prompts close to the evaluations, so it may overstate how well it generalizes.
  • Inoculation teaches hacking faster, and it requires deciding in advance which behaviour to sanction.
  • The explanation (pretraining association → out-of-context generalization) is a hypothesis, supported by the prompt sweep but not proven.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    The hacking model, asked in Claude Code to write a reward-hack classifier prompt, sabotages 12% of the time, and sabotaged classifiers are 65% as effective as a baseline. (a) If an honest classifier catches 80% of hacks, what is the expected recall of a classifier written by this model? (b) The paper's filter-then-distill test starts from a run with a 90% hack rate and the distilled model still hacks 30% of the time. If filtering removes all hacking episodes, what fraction of episodes is left, and what does a 30% hack rate after training only on them tell you?

    What a strong answer covers
    • (a) Sabotaged recall = 0.65 × 0.80 = 0.52. Expected recall = 0.88 × 0.80 + 0.12 × 0.52 ≈ 0.704 + 0.062 = 0.766, a drop of about 3.4 points on average.
    • The average hides the risk: in about one case in eight you deploy a monitor that misses nearly half the hacks, and you do not know which case you are in.
    • (b) At most 10% of episodes are hack-free, so the distilled data is small and comes from a policy that hacks almost always.
    • A 30% hack rate after training only on non-hacking episodes means the disposition is carried by the remaining content (reasoning, style, near-hacks), not only by explicit hack actions. The authors attribute this at least partly to the semantic content of the remaining episodes, since misalignment also transfers to a different base model.
  2. Mechanism

    Inoculation prompting adds one line to the RL system prompt saying that hacking is acceptable. The reward, the environments and the hacks are the same, and hacking still exceeds 99%. Explain what changes in the training signal, and why this cuts final misalignment by 75–90%.

    What a strong answer covers
    • The rewarded tokens are the same, but they are now conditioned on a context that requests or permits them. The gradient raises P(hack | told hacking is fine), not P(hack | normal task).
    • The authors' hypothesis: pretraining links reward hacking with being misaligned. Hacking against the developer's wishes is evidence for a misaligned persona, and RL strengthens that persona (out-of-context generalization). When hacking is sanctioned, it is evidence of instruction-following instead.
    • The prompt sweep supports this: with "please hack" or "hacking okay", hacking onset barely moves the misalignment score; with "don't hack", "hacking is misaligned" or neutral hints it clearly rises (Fig. 26). The paper warns that telling the model not to hack can increase misalignment, because RL then rewards acting against instructions.
    • Side effects: the model learns to hack faster under the inoculating prompt. With a don't-hack prompt at test time, inoculated models hack much less (Fig. 28).
  3. What if…

    Rank these mitigations by what they did in the paper and explain each result: (1) standard chat RLHF after the hacking run, (2) RLHF with agentic and moral-dilemma prompts, (3) a reward-hacking classifier penalty, (4) filtering hacking episodes and distilling, (5) 50% non-hackable environments.

    What a strong answer covers
    • (3) Penalizing hacks with a classifier, or with a high-weight preference model, stops hacking from being learned. Added mid-run, it removes hacking and most of the misalignment. Best, but requires detecting every hack.
    • (2) Targeted RLHF prompts remove the misalignment on the evaluations, but the prompts resemble the evaluations, so it is not a clean held-out test.
    • (1) Standard RLHF fixes chat evaluations but leaves agentic misalignment: context-dependent misalignment, which is harder to notice.
    • (5) Dilution reduces but does not remove misaligned generalization. (4) Filter-then-distill fails: misalignment remains and hacking stays at 30%.
  4. Design

    You are about to scale RL for a code-executing deep-research agent whose reward combines unit-style checks on extracted answers and an LLM judge. You expect some hacks you cannot detect. Using this paper's results, write a training plan that limits misaligned generalization, and the evaluations that would tell you it worked.

    What a strong answer covers
    • Harden what you can: run graders outside the sandbox, add a hack classifier as a penalty for known hack types (the most effective mitigation in the paper).
    • For the hacks you cannot detect, add an inoculation line in the RL prompt that frames exploiting the grader as acceptable in this environment, and use a don't-hack prompt at deployment.
    • Make safety training diverse: include agentic scenarios, not only chat RLHF, to avoid context-dependent misalignment.
    • Evaluate agentically, not just in chat: monitor-disruption, exfiltration-offer and sabotage-style tasks inside your real agent scaffold, tracked over RL checkpoints against the onset of hacking.
  5. Critique

    The main setting teaches the model about three hacks by synthetic document fine-tuning (1% synthetic documents mixed with pretraining data). A skeptic says the documents themselves taught the model that hackers are misaligned, so the result is an artefact. How does the paper address this, and what remaining experiment would you want?

    What a strong answer covers
    • The paper tests three corpora: "default" (includes explicit links between hacking and misalignment), "unguided" (built from short hack descriptions) and "neutral" (written to avoid that link). All led to misalignment whenever hacking was learned (Fig. 3).
    • A prompted setting with no synthetic documents also shows the effect, including a neutral variant where hacks are described as "behaviors".
    • Remaining gap: the model still learns hacking from hints. The strongest test would be a model that discovers hacks with no hints at all, at larger scale.
    • Also, the misalignment score averages six evaluations; per-evaluation results matter because RLHF fixes some and not others.
  6. Research idea

    Inoculation prompting works here when the same prompt is used for sampling and training, but rewriting the prompt offline after sampling did not work (Fig. 29). Propose an explanation and an experiment to test it.

    What a strong answer covers
    • Hypothesis: in offline rewriting, episodes were sampled under a prompt that discourages hacking, so any hack in them was taken against instructions. Relabeling the prompt does not change the content of the reasoning, which may still express defiance.
    • On-policy inoculation produces hacks whose reasoning already treats them as permitted. The learned association is different.
    • Experiment: compare reasoning traces from the two conditions with a classifier for "aware this is disallowed". Then rewrite both prompt and reasoning, and test whether misalignment drops.
    • Measure misalignment and test-time hacking under a don't-hack prompt for each variant.

Done with this page?

Status