Planning With a Learned Model in Reinforcement Learning
An agent that only learns from real experience is sample-hungry. An agent that trusts its own imagined experience can be confidently wrong. Planning with a…

Key topics
An agent that only learns from real experience is sample-hungry. An agent that trusts its own imagined experience can be confidently wrong. Planning with a learned model sits in that tension—and understanding it is the difference between multiplying your data and fooling yourself with it.
Why an Agent Would Plan at All
Every real environment step costs something. Time, risk, money, wear on a robot arm, latency for a live user. In reinforcement learning, those steps are the scarce resource—the thing you can never get back once spent.
A learned model changes the economics. Once the agent can predict what happens next, it can rehearse a thousand futures for the price of one real step. Instead of waiting for the world to show up, it can ask its model: what would happen if I tried this?
This is the core move in model-based reinforcement learning. The agent acts in the real world, learns a model from what it observes, then plans inside that model to improve its policy. The key reframe: planning is not a separate phase that happens after learning. It is a multiplier on real experience—a way to squeeze more value out of every expensive interaction.
If you already know the model-based versus model-free distinction, you know the setup: model-based agents hold an explicit representation of how the environment behaves. What we are tracing here is what the agent actually does with that representation once it has it.
What the Agent Learns: A Model Is a Prediction Machine
A model of the environment is a prediction machine with two jobs. Given a current state and an action, it predicts:
- What state comes next.
- What reward arrives.
That is the entire contract. State transitions and rewards. Everything else—the fancy neural networks, the uncertainty estimates, the clever architectures—is a way of making those two predictions better.
Learning the model is a supervised learning problem. The agent collects real transitions—tuples of (state, action, next state, reward)—and treats them as training data. Each tuple is one labeled example: given this state and action, here is what actually happened.
The simplest version is a table-lookup model. Count how many times you have visited each state-action pair, then average the observed next states and rewards. Ask the model what happens after taking action a in state s, and it returns the average of everything it has seen from that situation.
This is worth emphasizing because it is easy to overcomplicate. The model does not need to be a neural network to be useful. It needs to be better than nothing—a rough approximation of the environment that the agent can query internally.
And it will always be an approximation. The model is built from finite experience, so it will never be a perfect copy of the real environment. That imperfection is not a bug you can fix away. It is the central fact you have to design around.
Knowledge check
Check your understanding
Answer this question before you continue.
Planning Inside the Model: Simulated Experience
Once the agent has a model, it can generate simulated experience. This is sample-based planning: query the model for a next state and reward, treat the result as if it were real experience, and feed it to the same value-learning machinery the agent already uses.
Here is the elegant trick: the Q-learning or value-update code that works on real experience works identically on model-generated experience. The update rule does not care where the transition came from. It sees a state, an action, a reward, a next state—and it updates its value estimate accordingly.
Let's trace one concrete cycle so the mechanism is visible. Suppose the agent takes action left in state A, observes the real transition to state B with reward 0, and stores the tuple (A, left, B, 0) in its table model. Later, during a planning step, the agent picks a previously visited state-action pair—say (A, left) again—and queries the model. The model returns its prediction: next state B, reward 0. The agent then applies its usual value update to that imagined tuple, exactly as if it had just lived it.
The important detail: planning does not replay the original observation over and over. The agent can query different stored state-action pairs, and the model may return different predictions for the same pair if it has seen multiple outcomes. One real transition becomes the seed for many imagined ones, and each imagined transition nudges the value estimates closer to their true values.
This is why Dyna-style methods feel natural. They blur the line between real and imagined experience until the distinction barely matters for the learning update. Real experience builds the model; simulated experience trains the values; both flow into the same learner.
One practical note on rollout length. A rollout is simply a sequence of imagined transitions produced by repeatedly querying the model. Short rollouts starting from real states beat long rollouts starting from the beginning of an episode. Why? Because model errors compound. Each predicted step carries the previous step's error forward, so a 50-step imagined trajectory can drift far from anything the real environment would produce. Short rollouts from states the agent has actually visited keep the simulation grounded in reality.
Knowledge check
Check your understanding
Answer this question before you continue.
The Dyna Loop: Learning and Planning Together
Dyna is the canonical architecture for integrating learning and planning, and it is simple enough to trace in full.
The rhythm goes like this:
- Take a real step in the environment.
- Update the model from that observation.
- Run several planning steps on simulated experience.
- Update the value function from both real and simulated experience.
- Repeat.
The n parameter controls the ratio of planning steps to real steps. With n = 0, the agent is purely model-free—it learns only from real experience. With n = 5, every real step is followed by five simulated planning steps, multiplying the agent's learning per real interaction.
Why does this work? Because simulated experience is cheap. The agent can squeeze more value updates out of each real observation by querying variations of what it has seen. Each query costs nothing but compute, and each imagined transition nudges the value estimates closer to their true values.
Dyna is the mental anchor for understanding more advanced model-based planning methods. Some systems search directly inside the model to select actions; others use simulated experience to train a policy. The architectures get more sophisticated, but the loop is the same: learn a model from real experience, then use simulated experience to improve decisions.
Knowledge check
Check your understanding
Answer this question before you continue.
Where the Model Lies: Error and Its Consequences
The model is a tool, not a truth. The real environment remains the final judge.
Model error compounds over rollout length. Each predicted step carries the previous step's error forward, so small inaccuracies grow into large ones as the simulation extends. Imagine a model that predicts a robot's position one step ahead. If each prediction is slightly wrong, the next prediction starts from the wrong state, and the imagined path drifts further from reality with every step. Errors are rarely random, either. They are often systematic, biased in ways that the agent can exploit.
This is the dangerous failure mode. The agent optimizes against its own approximation, and if the model has blind spots, the agent will find them. It can discover behaviors that look excellent in simulation but fail badly in the real environment—because the simulation never showed it the consequences that actually matter.
The tradeoff is fundamental: data efficiency from internal experience versus the risk of trusting a biased model. You cannot have the first without accepting the second. What you can do is manage it.
Practical mitigations:
- Keep rollouts short. Less compounding, less drift.
- Start rollouts from real states. Ground the simulation in what the agent has actually observed.
- Keep updating the model. New real data should continuously correct the model's errors.
- Treat model predictions as hypotheses, not facts. When the real environment contradicts the model, the model is wrong—update it.
Common mistake: Assuming a learned model is automatically better than no model. A bad model can be worse than none, because it gives the agent confident but wrong predictions to optimize against.
Knowledge check
Check your understanding
Answer this question before you continue.
When Planning With a Learned Model Helps—and When It Does Not
Learned-model planning is not a universal upgrade. It is a tool with a specific job.
It helps when:
- Real interaction is expensive—each step costs significant time, money, or risk.
- The environment is learnable from limited data—the dynamics are simple enough that a model can capture them.
- The dynamics are fairly stable—the environment does not change out from under the model.
It hurts when:
- The environment is non-stationary—the model goes stale as the world changes.
- The state space makes the model hard to learn—complex dynamics require enormous amounts of data to model accurately.
- Model error is large relative to the benefit—the simulated experience is so unreliable that it misleads more than it informs.
Stochastic environments deserve a more careful boundary. Stochasticity alone does not rule out planning with a learned model. What matters is whether the model represents the relevant uncertainty honestly. A model that captures a distribution of outcomes and samples plausible futures can still support useful planning. The danger appears when uncertainty is collapsed into an overconfident single prediction, or when errors concentrate in the exact regions where decisions matter most.
My rule of thumb: if a model-free agent already solves the task with acceptable sample cost, the added model complexity may not pay for itself. The model is worth building when real experience is the bottleneck—not when compute or implementation complexity is.
A Practical Experiment: Watch the Leverage and the Drift
Start small. Build a table-lookup model in a tiny environment before reaching for neural-network dynamics models. Watch how one real transition gets multiplied into several planning updates. Then deliberately introduce a model error—change the transition table so it predicts the wrong next state—and watch how the value estimate drifts. That drift is the whole story of model-based planning: the leverage is real, and so is the risk.
The agent that plans with a learned model is rehearsing futures it has never lived. Done carefully, that rehearsal turns one expensive real step into many cheap imagined ones. Done carelessly, it is the difference between an agent that learns and an agent that has convinced itself of a world that does not exist. The real environment is always the final judge—and the best model-based agents know it.
Knowledge check
Final check
Finish the article by checking the ideas you just learned.
References
Research updated Sep 9, 2026


