On-Policy vs. Off-Policy Reinforcement Learning
Whether an RL algorithm is on-policy or off-policy determines how it can use experience, how sample-efficient it is, and how prone it is to certain kinds of instability.
The Core Distinction
An on-policy algorithm evaluates and improves the same policy that is used to generate experience — every update assumes the data was collected by the current policy. An off-policy algorithm can learn about one policy (the target policy) using experience generated by a different policy (the behavior policy).
On-policy: data must come from the current policy -> discard after one update
Off-policy: data can come from any policy -> reusable via replay buffers
[[sarsa-algorithm]] is the canonical on-policy control method; [[q-learning-fundamentals]] is the canonical off-policy control method, since its update target assumes the best possible action regardless of what the behavior policy actually did.
Why It Matters for Efficiency
Off-policy algorithms can store past experience in a replay buffer and reuse it for many updates, dramatically improving sample efficiency — this is essential for domains like robotics where collecting real-world experience is slow and expensive. On-policy algorithms must discard data as soon as the policy changes, since old data no longer reflects the current policy’s behavior, which generally makes them less sample-efficient but often more stable, since the data distribution used for each update matches the current policy exactly.
Stability Tradeoffs
Off-policy learning combined with function approximation and bootstrapping can be unstable — the “deadly triad” mentioned in [[q-learning-fundamentals]]. On-policy methods like PPO avoid this specific instability but introduce their own constraint: they need mechanisms (like PPO’s clipped objective or TRPO’s trust region) to prevent any single update from moving the policy so far that the reused-within-batch data becomes too stale to trust.
Practical Guidance
Choose off-policy algorithms (DQN, SAC, TD3) when sample efficiency matters most and you can tolerate more tuning to keep training stable. Choose on-policy algorithms (PPO, A2C) when stability and simplicity matter more than sample efficiency, particularly in simulated environments where generating more experience is cheap. Many modern systems blend the two, such as using an off-policy replay buffer for the critic in actor-critic methods while keeping some on-policy elements for the actor.