Eureka: Automating Reward Design with Coding LLMs
NVIDIA's Eureka puts an LLM in a loop around reinforcement learning — it reads the environment code, writes reward functions, trains, reflects on the results and rewrites. A blueprint for closed-loop agents.
On this page
Eureka (Ma et al., NVIDIA, ICLR 2024) answers a question I find more interesting than the robotics it was built for: what happens when an LLM doesn’t just respond to a prompt, but drives a whole closed-loop design process?
The task is reward design for Reinforcement Learning — notoriously fiddly work that human experts usually do by trial and error. Eureka hands it to an LLM acting as a “reward architect”.
The loop
- Read the environment. The LLM gets the raw source code of the simulation as context, so it understands the task’s mechanics and objectives directly rather than through a description.
- Write rewards as code. It generates several candidate reward functions in Python, zero-shot, with no templates.
- Train. Each candidate trains a policy in a GPU-parallel physics simulator.
- Reflect. Eureka feeds back a reward reflection: statistics on how each component of the reward behaved during training. In effect, a structured critique.
- Revise. The LLM keeps the best candidate, works out which terms helped or hurt, and writes improved versions. Repeat for a fixed number of iterations.
It beat expert human-written rewards on most of the benchmark tasks, including teaching a simulated hand to spin a pen.
Why code, and why reflection
- Code is inspectable. The LLM can reason term by term: “the distance penalty dominates; reduce its weight”. A natural-language reward couldn’t be executed or debugged like that.
- Reflection is the key ingredient. Without feedback, it’s one-shot generation and a guess. With per-component training statistics, it’s guided search — closer to evolution than to autocomplete.
- There’s a budget. Fixed iterations and samples per round. Explicit stopping criteria are what stop an agentic loop becoming an expensive infinite one.
The general pattern
Take the robotics away and Eureka is the shape of most useful agents I’ve seen: propose → execute in a real environment → observe metrics → reflect → revise, with a budget. Coding agents do it with tests (write code, run tests, read failures, fix). It’s the same agent → environment → feedback loop described in What Makes an AI Agent, with a TDD flavour: like a developer who starts writing tests just by reading the source code and the requirements.
Building a Eureka-style loop yourself
Re-implementing the loop as a small multi-agent system makes the moving parts explicit. One iteration is generate → evaluate → select → reflect → (optional human input) → exit check → increment.
| Agent | Job |
|---|---|
| Reward designer (LLM) | Generates k reward candidates |
| Candidate evaluator | Trains and evaluates a policy per candidate |
| Selector | Picks the best candidate |
| Reward reflector (LLM) | Turns raw training numbers into actionable guidance. It does not write rewards |
| Human reflector | An optional human-in-the-loop pause |
| Exit checker | Stops early when good enough |
| Increment | Advances the iteration |
Two design choices paid off:
- Split the config. One config controls how the system runs (iterations, candidates, training steps, seed, environment); a separate task spec controls how performance is judged (episodes, horizon, task metadata).
- Make failure visible. Write reward functions like validators, prioritising execution reliability over readability. If anything fails, capture it, write an error artefact and still append a leaderboard entry, so failures show up in the results instead of vanishing. Cache expensive evaluations.
Evaluating it as a system designer
Reward reflection is the architectural key: try, measure, reflect, edit, so an engineer can debug with evidence. But the greedy loop has risks:
- Selection pressure overweights noisy early gains. RL training is high-variance (seed luck, PPO variance), so the “best” candidate in round one may just have been lucky.
- The evaluator quietly becomes the definition of truth. Whatever the training run and metric reward is what the system optimises, which is Goodhart’s Law with a GPU budget. Adding more reflection agents adds exploration, but with the same evaluator they may simply converge early, faster.
Checks I’d want on any evaluator:
- Return vs success-rate gap: high return without more task success usually means reward hacking.
- Episode length distribution and termination reasons.
- Stability across seeds.
- Learning-curve shape, not just the final number.
And test the evaluator itself, the way you’d test a CI suite: inject seeded bugs (mutation testing) and make sure it fails. Same principle as Don’t Read the Code: trust the verification, then verify the verifier.
In practice
The part I’ve stolen for my own tooling is reflection as a first-class artefact. When an automated step runs, I want a short structured record of what it tried, what happened and what it would change — not just a pass/fail. It makes the next iteration better, and it makes the loop auditable by a human. That’s as true for a CI pipeline as for an agent.
- #ai-agents
- #reinforcement-learning
- #llm
- #feedback-loops
- #papers
↩ Linked from (4)
Optimise the system, not just the model, especially as token use rises. Reflection as a first-class step is the same move that makes Eureka work.
The same propose → act → observe rhythm is what makes Eureka work; the difference is only how much is decided up front.
- Reinforcement LearningGrowing
Which turns reward design itself into a loop: propose a reward → train → observe → reflect → revise. Eureka hands that loop to an LLM.
- What Makes an AI AgentGrowing
…t a language model does the reasoning and tools do the acting — APIs, a browser, a shell, a code interpreter. Eureka is a lovely worked example: an LLM writes code, runs an experiment, reads the results and rewrites the…
↪ Links to (4)
Related by topic
- Seed
AI Reverse Engineering and Where Value Moves
AI, machine learning - Seed
Pose-Based Rep Counting
AI, machine learning - Seed
Rewrites Are Now a Business Case
Backend - Seed
A Safe Path for AI Agents in a Large Codebase
Platform engineering