SPADE ♠: Self-Play in Adaptive Synthetic Executable Environments

Bo Liu1,2,*, Simon Yu3,*, Yiding Jiang4, Ao Qu5, Andrew Zhao, Zichen Liu6, Junsu Kim7, Zijian Zhou6, Seungone Kim4, Tongzheng Ren, Mickel Liu1, Hanfei Yu8, Zhaorun Chen9, Weiyan Shi3, Paul Pu Liang5, Luke Zettlemoyer1, Yejin Choi2, Natasha Jaques1

1University of Washington  2Stanford  3Northeastern  4CMU  5MIT  6NUS  7SNU  8Stevens  9UChicago

*Equal contribution

Abstract & Motivation

Continuous self-improvement needs an ever-expanding pool of self-generated, diverse, adaptive goals. Hand-built environment pools stay fixed, so the goals stop adapting once the learner catches up to them.

SPADE is a self-play RL framework in which one LLM writes its own training environments and then learns in them. As the Environment Designer, it writes complete, long-horizon environments as executable Python implementing reset()/step(); as the Reasoning Agent, it learns to act in them. Through hint-based regret, the gap between the Reasoning Agent's return with and without a privileged hint, the Environment Designer targets environments at the edge of the Reasoning Agent's ability while keeping them solvable.

SPADE framework at a glance
The agent generates its own environment, then solves it. The Environment Designer writes an executable environment e with a privileged hint h; the Reasoning Agent plays e with and without h. Task completion trains the Reasoning Agent; the return gap (hint-based regret) trains the Environment Designer; both update the same weights.

Adaptive Synthetic Environments Scaling

4,976 generated environments, one dot each, placed by what they are about. Click a dot to read or run it, drag the slider to replay training, toggle runs to compare. Ringed dots are the 190 the Reasoning Agent almost never solved.

step ≤ 400 

Embedded with SBERT (all-MiniLM-L6-v2) and projected with t-SNE, following the paper.

Held-Out Benchmark Performance

Held-out benchmark curves
Training on diverse synthetic games improves science reasoning, code generation, and procedural reasoning while competition math is preserved (Qwen3-30B-A3B-Instruct). No science questions, real code, or benchmark-style problems appear in the generated games; the gains come from the diversity and adaptivity of the self-generated curriculum. SPADE keeps improving through the full 400 steps while fixed-environment baselines saturate.

Synthetic Game Environments

Every environment here is a Python program the Environment Designer wrote during training, and you can play it yourself. Press Play it right here on a card below, or open any environment and hit Run: a Python runtime starts in your browser and puts you in the same reset()/step() loop the Reasoning Agent trained on.

Two environments from one run, early and late, to show how far the Environment Designer moves. Step 4 leaks the answer in its opening line, and the Reasoning Agent wins 31 of 32 tries in under 4 turns. Step 304 asks for the best projection direction in a 5-dimensional feature space, runs 1,012 lines instead of 173, and burns all 12 turns on every one of its 32 attempts.

STEP 4 · EARLYDescriptiveInteractiveEnv
173 lines · 11 state variables · grounded in a medicine-forum passage
The Reasoning Agent solved 31 of 32 attempts, 3.7 turns on average; the opening line already names the answer.
Agent first observation
You are a pediatric developmental specialist observing a 3-year-old child named Junior. Junior speaks in short, intelligible phrases and has a growing vocabulary. Your goal is to determine Junior's age…
Privileged hint (Environment Designer only)
Junior's language milestones…align with typical 3-year-old development. Use the available actions to gather these clues, then guess the age…
STEP 304 · LATELinearDiscriminant­AnalyzerEnv
1,012 lines · 13 state variables · grounded in a statistics forum post on Fisher's linear discriminant
All 32 agent attempts ran the full 12-turn cap.
Agent first observation
You are operating a Linear Discriminant Analyzer in a 5-dimensional feature space. Your goal is to find the optimal projection direction (weight vector w) that best separates two classes of signals…
Privileged hint (Environment Designer only)
The optimal weight vector w is proportional to the inverse of the sum of covariance matrices multiplied by the difference of class means. After probing both class means and covariances, compute the discriminant ratio…

Beat the Reasoning Agent

Two environments the trained 30B-A3B agent never solved: 0 for 32 attempts on each in the released logs. Play them yourself; answers must follow the format the observation asks for, the same rule the Reasoning Agent faced.

CarOwnershipDisputeEnv
Agent record: 0 for 32, every attempt ran the full 12 turns.
SemiconductorBandLabEnv
Agent record: 0 for 32 within the 12-turn budget.

Take the Controls

RotatingSokobanEnv is a spatial puzzle the Environment Designer wrote at step 113: push the three boxes (B) onto the targets (T) within 25 turns, while the whole grid rotates 90° every three turns. Each move you make reaches the environment's own code as a \boxed{go ...} action, the same interface the Reasoning Agent played through during training.

The source behind the link below is exactly what runs here, repaired in one line (a stale flag had stopped the rotation from repeating). Random placement leaves most boards unwinnable inside the turn limit, so Start and Shuffle deal only the 51 of the first 300 that a solver proved beatable, easiest first. The Reasoning Agent trained with no such filter.

Press Start to load the environment.
click the board, then arrow keys · on phone or tablet: swipe the board

Synthetic Tool-Use Environments

Beyond games, the Environment Designer also writes tool-use environments. Each one simulates a backend, exposes its tools in an OpenAI function-calling schema, and runs a multi-step user workflow that advances only when the backend state checks out. The 30B tool-use run generated 4,023 of them over 105 steps; two are below, with the Reasoning Agent's episode verbatim.

STEP 24 · TOOL USETelecomAccountManagementMTEnv
8 tools · 7 turns · all 5 workflow steps complete, one tool error recovered mid-episode
First user request
Check the data usage for all lines to see which ones are close to their cap.
STEP 280 · TOOL USETaskTrackerMultiTurnEnv
6 tools · 9 turns · skill: Multi-Step Workflows · all 5 workflow steps complete
First user request
List all tasks that are currently pending.

SPADE

Verifiable-reward RL draws its signal from fixed, hand-built pools of environments that stop adapting once the learner masters them. SPADE makes environment design itself a learnable component of post-training: because any computable MDP can be written as a program, the space of environments the Environment Designer can reach is bounded only by its coding ability. The designer is trained online, together with the Reasoning Agent, so the environment distribution shifts as the Reasoning Agent improves.

SPADE framework detail
The SPADE loop. The Environment Designer conditions on a pretraining corpus and an environment memory to emit an executable environment and a privileged hint. Generated code passes syntax, execution, and solvability validation before entering the pool. The Reasoning Agent plays each environment with and without the hint; task return trains the Reasoning Agent, hint-based regret trains the Environment Designer, and both roles update one shared policy with GRPO.

Hint-based regret

The designer's reward for an environment is the gap between the Reasoning Agent's average return with the privileged hint and without it. High regret marks the learning frontier, solvable with the hint but not yet without; low regret with high returns marks mastery; low regret with low returns marks an intractable environment. Unlike a pure adversary, which is free to make environments unsolvable, or a cooperative designer, which can inflate agent reward without teaching anything, hint-based regret keeps every environment both solvable and at the frontier.

Hint example
What a privileged hint looks like. The designer writes the hint alongside the environment; the Reasoning Agent trains on no-hint plays only, so the hint acts purely as the Environment Designer's measurement instrument. Click the purple card to open the environment itself; click either gold play to open exactly that play, every turn verbatim.

Grounded, memory-seeded generation

Each round the Environment Designer conditions on passages sampled from a pretraining corpus (10k math, 5k science documents) and on an environment memory of high-regret past environments. The corpus keeps the reachable distribution broadening; the memory targets difficulty where the Reasoning Agent is learning fastest. Removing either costs about 6 suite-average points; removing designer training altogether drops self-play 12.6 points below the untrained base.

Environment curriculum filmstrip
The curriculum keeps moving with the learner. Four environments from one run, step 0 to step 384: each card shows the Reasoning Agent's first observation, the generated Python environment, and the Environment Designer-only hint. Every environment is a complete MDP with a reset()/step() interface. Click any card to open that environment.
Learnable share and diversity
The designer keeps supplying learnable, diverse environments. Left: share of each rollout's environments on which the Reasoning Agent wins between 20% and 80% of the time; full SPADE holds roughly a third through step 400 while the ablations lose most of the supply. Right: the paper's t-SNE of the same embeddings; corpus grounding provides the breadth, designer training the difficulty.

Qualitative Analysis

Environment Designer outputs harden over training
Trained Environment Designer environments stop revealing the solution method. Physics environments from steps 20, 192, and 384 of one run: the share of environments that print the governing formula in the opening observation falls from 25% to 5%. Rightmost (red): in one late 22-step window (steps 290 to 312), the no-corpus ablation emits the same RotatingMazeEnv 41 times in a row. Click any panel to open its environment; the fourth opens the repeated maze itself, with arrows to page through its re-emissions.
Reasoning Agent behavior over training
From front-loaded derivation to evidence-first play. At step 0 the Reasoning Agent derives everything up front and cannot recover from format errors; by step 200 it tests short hypotheses and revises on evidence; by step 300 it probes first and derives once. The model still derives at length when the task calls for it, and late-checkpoint benchmark gains confirm it keeps the ability. Click a card to open that episode, every turn verbatim.

Ablation Results

Without the corpus, generation collapses

With the grounding corpus, the Environment Designer keeps writing new environments; without it, it gets stuck on one maze. These two columns are the same training steps from each run. Over the full run that comes to 0.68 distinct environments per 100 with the corpus, and 0.04 without.

With the corpus · steps 233 to 395
Without the corpus · the same steps

Here is one of those mazes in full. The no-corpus run wrote this same program 413 times out of 865, 296 of them in a row, and this copy cannot even be won: the exit is walled off from the start. Play it and see.

Without the corpus · step 233 · the maze it kept writing, verbatim

Fixed-environment baselines saturate; SPADE keeps improving

Ablation curves
Every frozen or partial variant peaks early and fades. Removing designer training drops self-play far below the untrained base; replacing the self-play Environment Designer with a stronger frozen frontier model (GPT-5.5) recovers less than half of SPADE's gain. Sustained improvement comes from adaptivity: even a stronger Environment Designer stops helping once its fixed pool falls behind the learner.

Scaling Results

Scaling with model size
Gain over base grows from +5.2 (4B) and +5.7 (8B) to +8.1 (30B-A3B), while fixed-environment GRPO stays near +1.2 at every size: larger models exhaust a static training signal faster and benefit more from an adaptive one.
Curriculum diversity
Curriculum breadth accounts for most of the gain. A two-skill curriculum improves, but captures only about half of the procedural-reasoning gains of the full six-skill curriculum (53.7 vs 58.3 suite average).

Citation

@misc{liu2026spade,
  title  = {SPADE: Self-Play in Adaptive Synthetic Executable Environments},
  author = {Bo Liu and Simon Yu and Yiding Jiang and Ao Qu and Andrew Zhao and Zichen Liu and Junsu Kim and Zijian Zhou and Seungone Kim and Tongzheng Ren and Mickel Liu and Hanfei Yu and Zhaorun Chen and Weiyan Shi and Paul Pu Liang and Luke Zettlemoyer and Yejin Choi and Natasha Jaques},
  year   = {2026}
}
Agent first observation
Privileged hint (Environment Designer only)
Generated environment (Python)