Goal-conditioned reinforcement learning is a formulation of reinforcement learning in which the policy and value function receive a goal as an additional input, so that one agent learns to reach many different goals rather than optimizing a single fixed reward. The policy is written as π(a | s, g), where s is the current state, a is the action and g is the desired goal.
The approach is also called goal-conditioned RL. It underpins robotic manipulation, navigation and multi-task control, and it is closely tied to techniques such as hindsight experience replay, universal value function approximators and hierarchical reinforcement learning.
How goal-conditioned reinforcement learning extends the Markov decision process
Goal-conditioned reinforcement learning extends a standard Markov decision process with a goal space G and a goal-dependent reward function r(s, a, g). At the start of each episode, a goal is sampled from a distribution over G, and the agent is rewarded for reaching states that satisfy it.
The goal is usually represented in the same space as some part of the state, for example a target position, an object configuration or an image of the desired scene. A mapping function φ(s) extracts the goal-relevant features from a state, and success is often defined as ‖φ(s) − g‖ below a tolerance ε.
The value function becomes a universal value function approximator (UVFA), written V(s, g) or Q(s, a, g). Because a single network generalizes across goals, the agent can attempt goals it never saw during training, provided they lie within the distribution it learned from.
| Element | Standard RL | Goal-conditioned RL |
|---|---|---|
| Policy | π(a | s) | π(a | s, g) |
| Value function | V(s) or Q(s, a) | V(s, g) or Q(s, a, g) |
| Reward | r(s, a) | r(s, a, g), often sparse |
| Task definition | Fixed by the reward | Chosen at run time by the goal |
| Transfer | One task per trained policy | Many tasks per trained policy |
Reward design and goal representations
The choice of reward and goal representation largely determines whether goal-conditioned training succeeds. The most common reward is binary and sparse: 0 when the goal is reached and −1 otherwise, which is easy to specify but hard to learn from because successful episodes are rare early in training.
Dense alternatives such as negative distance to the goal give a smoother signal, yet they can mislead the agent when straight-line distance does not reflect the true difficulty, as in a maze with walls. Reward shaping must therefore preserve the optimal policy, or it introduces bias.
| Representation | Example | Main difficulty |
|---|---|---|
| Coordinates | Target x, y, z of a gripper | Requires hand-designed state features |
| Images | Photo of the desired arrangement | Needs a learned embedding and distance |
| Language | Instruction such as stack the red block | Ambiguity and grounding of words |
| Latent vectors | Encoded state from a variational autoencoder | Latent distance may not match task difficulty |
Key algorithms and techniques
Goal-conditioned reinforcement learning is usually implemented with off-policy algorithms such as DDPG, TD3 or soft actor-critic, because off-policy learning allows stored transitions to be relabeled with new goals. This relabeling is the single most important idea in the field.
Hindsight experience replay (HER) takes a failed episode and pretends that the state actually reached was the intended goal. The transition then carries a successful reward, which turns sparse failures into useful training data. Variants relabel with future states from the same episode, random episode states or states from other episodes.
| Technique | What it does | Typical benefit |
|---|---|---|
| Hindsight experience replay | Relabels past transitions with achieved goals | Learning under sparse rewards |
| Automatic curriculum | Selects goals of intermediate difficulty | Steady progress without manual staging |
| Hierarchical control | High level sets subgoals for a low-level policy | Long-horizon tasks |
| Goal-conditioned supervised learning | Imitates relabeled trajectories directly | Simple and stable training |
| Contrastive RL | Learns values as similarity of states and goals | Avoids hand-designed rewards |
In hierarchical reinforcement learning, goal conditioning appears at the lower level: a manager policy outputs a subgoal every few steps, and a worker policy conditioned on that subgoal executes primitive actions. This structure improves credit assignment on tasks lasting hundreds or thousands of steps.
Relation to neighboring reinforcement learning concepts
Goal-conditioned reinforcement learning is a special case of multi-task and contextual reinforcement learning, in which the context happens to be a goal state. It differs from intrinsic motivation, which generates internal rewards for exploration, although the two are often combined when agents propose their own goals. Offline variants learn goal-reaching policies from fixed datasets, and decision transformers condition on a desired return rather than a goal state.
The successor representation offers a further link. It predicts discounted future state occupancy, and goal-reaching values can be read from it by asking how often the agent is expected to visit the goal. Recent contrastive methods exploit this connection to learn goal-conditioned values without explicit rewards.
In practice, the boundary between these approaches is fluid. A language-conditioned robot policy, for example, is both a contextual policy and a goal-conditioned one, and the training recipe often mixes behavior cloning, relabeling and reinforcement learning in a single pipeline.
Limitations and common pitfalls
Goal-conditioned reinforcement learning works well when goals are well defined and reachable, but it has recurring failure modes that practitioners should anticipate.
- Long horizons: success remains rare for distant goals even with relabeling, so subgoals or curricula are needed.
- Poor distance metrics: Euclidean distance in pixel or latent space can rank goals incorrectly.
- Relabeling bias: hindsight relabeling can bias value estimates in stochastic environments.
- Goal distribution mismatch: a policy trained on easy goals often fails on test goals outside that range.
- Underspecified goals: a single target state may not express constraints such as safety or energy use.
A plain-language summary
Normal reinforcement learning teaches an agent one job. Goal-conditioned reinforcement learning teaches it to accept a new target each time. You tell the agent where to go, and it works out how.
Think of a taxi driver. The driver does not learn one route. The driver learns the city and then follows any address. A clever trick also helps. When the agent misses its target, it pretends the spot it reached was the plan. Every attempt then teaches it something.
An example from practice
A warehouse automation team trains a robotic arm to place items at any position on a sorting table. Writing a separate reward for each position would be impractical, so the engineers use a goal-conditioned policy whose input combines the camera state and a target x, y coordinate.
They train in simulation with TD3 and hindsight experience replay using a sparse reward: success within 2 centimeters, failure otherwise. Without relabeling, the arm almost never succeeds in the first million steps. With relabeling, it learns to reach most table positions within a few million simulated steps.
After domain randomization and a short fine-tuning phase on the real arm, one trained policy handles every placement target. The team changes sorting layouts simply by sending new goal coordinates, with no retraining.