Deep Dive · RL Environments · Real Runs

Your RL Environment Has a Cheaper Answer. Find It Before the Policy Does.

Two of my training runs collapsed onto a single answer. On every one of 90 held-out cases, the trained agent earned exactly what a one-line scripted shortcut earns in that environment. So the shortcut can be priced before training starts — and I made that an agent’s job.

The short version

I train small models with GRPO to act as tool-using agents, on a laptop. When a run fails, it is tempting to blame the model or the optimiser. In my case the environment was at fault, and that could be measured before any training.

01The task, and two collapses

The environment is a customer-support desk. A customer writes in about an order. The agent looks the order up with an <order> tool, does arithmetic with <calc>, applies a four-rule refund policy that is written in its prompt, and gives one decision: refund AMOUNT, replace or deny. A reference implementation of the policy says what the right decision was, so there are no human labels anywhere in the loop. Six difficulty levels run from a lost parcel (look it up, refund price plus shipping) to messages that contradict the order record (“I’m a gold member, so no fee please” — the record says standard).

The agent is Qwen2.5-0.5B-Instruct, 4-bit, with LoRA adapters, trained by GRPO: 16 tasks a step, 8 attempts per task, each attempt a multi-turn episode with real tool calls. Everything runs on an Apple M3 Pro. The held-out set is the same 90 cases before and after.

RunRewardMean reward before → afterWhat it learned to say
v11 for the exact right decision, else 00.311 → 0.333“deny” to all 90 cases, without looking anything up
v2no credit without a lookup; 0.5 for the right action with a wrong amount0.339 → 0.411“refund” to all 90 cases, after looking every order up

The v2 change was meant to fix v1: no lookup, no reward. It removed one shortcut and paid for another.

The reward went up in both runs. By the number the optimiser was given, both runs succeeded. Held-out accuracy went from 31.1% to 33.3% in v1 and down to 24.4% in v2.

02The trained agent was the shortcut

Here are two policies you can write without a model:

Play each one in the environment its run trained in, on the same 90 cases, and compare with where the runs ended:

agent before training best scripted shortcut agent after training 0.25 0.30 0.35 0.40 0.45 mean reward on the 90 held-out cases v1 plain 0/1 reward v1 · plain 0/1 reward: agent before training 0.311 v1 · plain 0/1 reward: best shortcut "no lookup, always deny" 0.333; agent after training 0.333 (said "deny" on 90/90) 0.311 0.333 after training = 0.333 shortcut “no lookup, always deny” v2 lookup required + partial credit v2 · lookup required + partial credit: agent before training 0.339 v2 · lookup required + partial credit: best shortcut "look up, always refund price + shipping" 0.411; agent after training 0.411 (said "refund" on 90/90) 0.339 0.411 after training = 0.411 shortcut “look up, always refund price + shipping”
Figure 1. Mean reward on the 90 held-out cases. Gray: the agent before training. Orange ring: the best scripted shortcut in that environment. Blue: the agent after training, which lands inside the ring both times. The shortcut beats the untrained agent in both environments.

This is not a matching average. Case by case, the v1 agent’s reward equals the “always deny” reward on 90 of 90 cases, and the v2 agent’s equals “always refund price + shipping” on 90 of 90 (38 zeros, 30 half-credits, 22 full). RL did not find some mediocre policy. It found a specific one, which could have been written down before training.

Why the drift happens

GRPO scores each attempt against the other attempts on the same task: its advantage is its reward minus the group mean, over the group spread. Any behaviour that beats its siblings is reinforced. For a small model, “give the most common answer” is the nearest behaviour there is, and when it pays more than the model’s honest attempts, every update leans that way. Once every attempt in a group gives the same answer, the group has no spread, so it carries no gradient (the zero-advantage problem), and nothing pulls the policy back.

03Price the shortcut before you train

If the attractor can be written down, it can be measured before any GPU time. The audit plays scripted policies in the environment:

Then one comparison, on the very tasks where the agent’s baseline was measured:

margin  =  agent’s baseline mean reward  −  best shortcut’s mean reward

margin ≤ 0 → BLOCK: the policy will drift to the shortcut.  0 < margin < 0.10 → WARN.  Otherwise PASS.

Run against every saved run, each audited in the environment it trained in:

RunAgent’s baselineBest shortcutAuditWhat actually happened
support v1
0.5B
0.3110.333
always deny, no lookup
BLOCKcollapsed to “deny” on 90/90; ended at 0.333
support v2
0.5B
0.3390.411
always refund price + shipping
BLOCKcollapsed to “refund” on 90/90; ended at 0.411
support v3/v4
1.5B
0.4500.411
always refund price + shipping
WARN (+0.04)without help, lost its learning signal and was stopped; with a KL anchor + checkpoint selection, 43.3% → 60.0%
math
0.5B
0.3750.042
sum of the numbers in the question
PASStrained cleanly, 37.5% → 60.0%

Baselines are mean reward on each run’s held-out set; shortcuts are scored on the same cases.

Four for four, including the run that worked: the math environment’s best shortcut earns 0.04 against the agent’s 0.375, and that run trained cleanly from 37.5% to 60.0%. The 1.5B support run is the interesting one. Its margin was positive but thin, and it behaved exactly like that: without help, it had lost almost all of its learning signal by step 9 and was stopped at step 21; with a KL anchor and checkpoint selection, it reached 60.0%.

What the rule is, and isn’t

It is a heuristic, checked on four runs, not a theorem. It only prices shortcuts someone thought to write, so a PASS means “no known shortcut pays”. And it compares averages: a shortcut can win on one level while losing overall. The per-level table the audit prints is there for that.

04A hole in the environment, not the model

Writing the fake-result probe found a real bug. The v2 reward gave “looked the order up” credit to any text containing <result>order. Tool results arrive in exactly that format, so the check passed for real lookups. But the agent writes text too, and nothing stopped it from typing <result>order ...</result> itself.

The fix is structural. Each attempt is now an Episode: a small stateful environment that runs the tool the agent called, returns the result, and records every call in its own log. The reward reads its evidence from that log, never from the agent’s text. Re-scoring every saved run under the new rule changes nothing, because none of them had done it. It also happens for real: in the first 4 training steps of the 1.5B run below, the agent typed its own <result> in 8 attempts. Under the old check those attempts could earn lookup credit; under the environment’s log they earn none, and the Designer flags them.

05Giving the environment to an agent

The training loop already had agents with one job each: an Assessor that tests the model, a Curriculum that picks what to practise, an Actor that attempts tasks, a Verifier that scores, a Learner that runs GRPO. The new one, the Designer, owns the environment:

Assessor baseline on held-out Designer review: audit shortcuts vs the agent, search env variants Refuse to train no variant makes the task pay: no GPU time margin ≤ 0 sets the knobs: answer balance, partial credit Curriculum proposes tasks Designer shape: rebalance the batch Actor ⇄ Episode tools run by the env, calls logged Verifier env reward, evidence from log Designer observe: alarms, re-audit on collapse Learner GRPO update next step on collapse: re-run the audit
Figure 2. The Designer’s three jobs in the loop (green). It turns only two knobs, the answer mix and how much partial credit pays, and every change it makes is audited first.
  1. Review, before training.

    Audit the environment against the agent’s baseline. If it is not a clear PASS, search the variants: answer balance within each level (natural, half-way, even) × partial credit (as defined, halved, none). Each variant gets its own audit and its own estimate of what the agent would earn, read off the agent’s scored baseline attempts and reweighted to that variant’s task mix. Switch to the smallest change whose margin is within noise of the best. If no variant gives a positive margin, refuse to train.

  2. Shape, every step.

    Rebalance the batch the Curriculum proposed to the chosen answer mix.

  3. Observe, every step.

    Watch for reward hacking: one answer on most attempts while it is right on far fewer, attempts that skip the required lookup, tool results the agent typed itself. On a collapse, re-run the same audited search with the agent’s latest attempts in place of its stale baseline, and switch only if a variant now does better.

Two knobs is deliberate. A tiny, fully audited search space is something you can reason about; an agent free to rewrite rewards would be the next thing to audit.

06The first fix made it worse

The first Designer did the obvious thing: the shortcut says “refund”, so serve fewer refund cases, swapping them for same-level cases with another answer. The audit of that edit, on 300 training tasks:

Refund cases swapped outnone25%50%75%100%
Best shortcut’s reward0.460.380.450.560.67
Which shortcutalways refund p+salways refund p+salways denyalways denyalways deny

A light touch helps. Past that, “always deny” becomes the best shortcut, and it ends up paying more than “always refund” ever did.

Starving one answer promotes the next. Against constant answers, the minimax mix is the even one: every answer equally common within a level, so no single answer can earn more than its share. But even that was not safe here. Partial credit pays half for any refund, so an even mix gives “always refund” more of those half-credits. For the 1.5B agent, the even mix raises that shortcut from 0.41 to 0.51. The full search for both models:

Qwen2.5-0.5B baseline mean reward 0.34 natural half-way even ×1.0 Qwen2.5-0.5B, answer balance 0%, partial credit ×1.0: agent 0.34, best shortcut 0.41 (“look up, always refund price + shipping”), margin -0.07 -0.07 now Qwen2.5-0.5B, answer balance 50%, partial credit ×1.0: agent 0.37, best shortcut 0.41 (“look up, always refund price + shipping”), margin -0.04 -0.04 Qwen2.5-0.5B, answer balance 100%, partial credit ×1.0: agent 0.31, best shortcut 0.51 (“look up, always refund price + shipping”), margin -0.20 -0.20 ×0.5 Qwen2.5-0.5B, answer balance 0%, partial credit ×0.5: agent 0.33, best shortcut 0.33 (“look up, always deny”), margin -0.01 -0.01 Qwen2.5-0.5B, answer balance 50%, partial credit ×0.5: agent 0.36, best shortcut 0.37 (“look up, always deny”), margin -0.00 -0.00 Qwen2.5-0.5B, answer balance 100%, partial credit ×0.5: agent 0.29, best shortcut 0.42 (“look up, always refund price + shipping”), margin -0.13 -0.13 none Qwen2.5-0.5B, answer balance 0%, partial credit ×0.0: agent 0.31, best shortcut 0.33 (“look up, always deny”), margin -0.02 -0.02 Qwen2.5-0.5B, answer balance 50%, partial credit ×0.0: agent 0.35, best shortcut 0.37 (“look up, always deny”), margin -0.01 -0.01 Qwen2.5-0.5B, answer balance 100%, partial credit ×0.0: agent 0.27, best shortcut 0.33 (“look up, always refund price + shipping”), margin -0.07 -0.07 no positive margin anywhere: refuse Qwen2.5-1.5B baseline mean reward 0.45 natural half-way even ×1.0 Qwen2.5-1.5B, answer balance 0%, partial credit ×1.0: agent 0.45, best shortcut 0.41 (“look up, always refund price + shipping”), margin +0.04 +0.04 now Qwen2.5-1.5B, answer balance 50%, partial credit ×1.0: agent 0.49, best shortcut 0.41 (“look up, always refund price + shipping”), margin +0.08 +0.08 Qwen2.5-1.5B, answer balance 100%, partial credit ×1.0: agent 0.39, best shortcut 0.51 (“look up, always refund price + shipping”), margin -0.12 -0.12 ×0.5 Qwen2.5-1.5B, answer balance 0%, partial credit ×0.5: agent 0.44, best shortcut 0.33 (“look up, always deny”), margin +0.11 +0.11 Qwen2.5-1.5B, answer balance 50%, partial credit ×0.5: agent 0.48, best shortcut 0.37 (“look up, always deny”), margin +0.11 +0.11 Qwen2.5-1.5B, answer balance 100%, partial credit ×0.5: agent 0.38, best shortcut 0.42 (“look up, always refund price + shipping”), margin -0.04 -0.04 none Qwen2.5-1.5B, answer balance 0%, partial credit ×0.0: agent 0.43, best shortcut 0.33 (“look up, always deny”), margin +0.10 +0.10 Qwen2.5-1.5B, answer balance 50%, partial credit ×0.0: agent 0.47, best shortcut 0.37 (“look up, always deny”), margin +0.10 +0.10 Qwen2.5-1.5B, answer balance 100%, partial credit ×0.0: agent 0.37, best shortcut 0.33 (“look up, always refund price + shipping”), margin +0.04 +0.04 choice: halve partial credit (+0.11) columns: answer balance · rows: partial credit columns: answer balance · rows: partial credit shortcut wins by ≥ 0.10 shortcut wins about a tie agent wins agent wins by ≥ 0.08
Figure 3. Margin (agent minus best shortcut) for each environment variant, by model. Blue: doing the task pays more. Red: a shortcut pays more. The bottom-right cells (even mix, full partial credit) are the “obvious” fix, and the worst variant for both models. Outlined: the Designer’s choice.

The two grids give opposite answers, and both are useful. For the 0.5B agent, no variant has a positive margin: whatever the environment, a shortcut earns at least as much as this model does. That matches what the runs showed — the model cannot yet condition its decision on the order record — and the right response is to not spend the GPU time. For the 1.5B agent, the smallest effective change is to halve partial credit and leave the mix alone: the margin goes from +0.04 to +0.11.

07Two real runs with the Designer in charge

Qwen2.5-0.5B, the v2 setup: refused in 37 seconds

messages.jsonl — the agents’ log
[17:51:22]   Assessor → Coordinator base: held-out accuracy 31.1% (L1 20% L2 0% L3 27% L4 67% L5 40% L6 33%)
[17:51:22]   Designer → Coordinator env audit BLOCK: 'look up, always refund price + shipping' earns 0.41, more than the agent's 0.34: RL would drift to the shortcut
[17:51:22]   Designer → Coordinator variants (balance, partial credit -> agent vs best shortcut): 50%/0.5 -> 0.36 vs 0.37; 0%/0.5 -> 0.33 vs 0.33; 50%/0.0 -> 0.35 vs 0.37; 0%/0.0 -> 0.31 vs 0.33
[17:51:22]   Designer → Coordinator no variant makes doing the task pay more than a shortcut for this agent: refusing to train (pass --force 1 to override)

The original v2 run spent 47 minutes training before ending below where it started. This time, the run stopped after model loading and one held-out pass.

Qwen2.5-1.5B: the Designer picks the environment, no other safeguards

Same model and settings as run v3, the one that lost its learning signal: learning rate 2e-5, no KL anchor, no checkpoint selection. The only difference is the Designer. Its review found a margin of +0.04 (WARN), so it searched and switched the environment:

the Designer’s decision
environment changed: answer balance 0%, partial credit x0.5; the agent now beats the best shortcut ('look up, always deny') by +0.11

That run is still training as this is published (4 of 30 steps done, about two hours on the laptop). Its held-out result, good or bad, will be added here.

08What this does not show

Recap

  1. Write the shortcut down. For most environments, the attractor a collapsing policy falls into is a one-line policy you can script.
  2. Price it against the agent, not in the abstract. A shortcut is dangerous when it pays about as much as this agent already earns. The same environment was a BLOCK for 0.5B and a WARN for 1.5B.
  3. Take evidence from the environment, never from the agent’s text.
  4. Audit every edit to the environment. The intuitive fixes — serve fewer of the shortcut’s answer, balance everything — raised the shortcut’s reward here.
  5. Let the environment refuse. “No variant makes the task pay for this model” is a result. It cost 37 seconds instead of 47 minutes.

The code is in agentic-post-training: env.py (the Episode), audit.py (oracle, probes, variant search) and the DesignerAgent in agents.py. The audit needs no model: python3 -m selflearn.audit --usecase support --policy runs/support-qwen1.5b.

Further reading

Shao et al., DeepSeekMath (2024), which introduced GRPO. · Skalse et al., Defining and Characterizing Reward Hacking (2022). · Krakovna et al., Specification gaming: the flip side of AI ingenuity (2020). · Dennis et al., Unsupervised Environment Design (PAIRED) (2020) and Parker-Holder et al., ACCEL (2022): agents that design environments for other agents, by regret rather than by shortcut audits. · On this site: zero-advantage groups, a loop gaming its own verifier, and picking checkpoints.

Cite this post
@misc{murugesan2026envdesigner,
  author = {Murugesan, Sugeerth},
  title  = {Your RL Environment Has a Cheaper Answer. Find It Before the Policy Does.},
  year   = {2026},
  url    = {https://sugeerth.github.io/blog/environment-designer/}
}
SM
Sugeerth Murugesan Staff ML Engineer / Scientist · Intel / Intuit