Offline reinforcement learning (RL) aims to derive optimal behaviors from static, pre-collected datasets without any further environment interaction. However, these datasets are rarely perfect; they often consist of fragmented, suboptimal, or even random trajectories. The fundamental challenge is not just to imitate the best path in the data, but to synthesize a new, optimal path by combining the best parts of different experiences. This capability is known as trajectory stitching.
The Stitching Bottleneck
Imagine a dataset where one agent travels from point A to point B, and another agent travels from point B to point C. Crucially, no single agent ever travels from A to C. To solve a task requiring a path from A to C, an offline RL agent must "stitch" these two segments together at the common junction, point B.
As noted in the D4RL benchmark by Aviral Kumar, Justin Fu, and colleagues, many algorithms fail this basic test. If an agent cannot recognize that the end of one sub-trajectory and the start of another are functionally equivalent, it remains trapped within the specific end-to-end sequences it observed during training.
Why Sequence Models Struggle
The rise of the Decision Transformer (DT) shifted RL toward a supervised learning (SL) paradigm, treating action selection as a sequence modeling problem. While stable and scalable, these models often lack the "stitching" property.
In Rethinking Decision Transformer via Hierarchical Reinforcement Learning, Yi Ma and Jianye HAO argue that sequence models act primarily as trajectory memorizers. Because they lack the iterative value propagation found in dynamic programming, they cannot easily connect state-action sequences that were not seen contiguously. Raj Ghugare and Benjamin Eysenbach further formalize this in Closing the Gap between TD Learning and Supervised Learning, describing stitching as a problem of combinatorial generalization that standard SL objectives are not designed to solve.
Dynamic Programming as the Glue
Traditional value-based methods, such as Q-learning, are naturally suited for stitching. By using Temporal Difference (TD) learning, they propagate reward information backward through time across different trajectories.
A landmark approach to this is Implicit Q-Learning (IQL) by Ilya Kostrikov. IQL performs stitching by using expectile regression to estimate the maximum possible value of actions already in the dataset, avoiding the "deadly triad" of instability caused by querying unseen actions.
To give sequence models this same power, researchers developed hybrid frameworks like the Q-learning Decision Transformer (QDT). QDT uses Q-learning to relabel the "return-to-go" in the training data, effectively injecting the stitching capability of dynamic programming into the stable architecture of a Transformer.
Generative and Geometric Bridging
Recent work has moved beyond pure value estimation to bridge gaps in the state space using generative models and geometry.
- Diffusion Models: DiffStitch by Guanghe Li and Weinan Zhang uses diffusion to generate the missing transitions that connect low-reward states to high-reward goals. Similarly, BiTrajDiff generates both future and historical paths to create a more connected experience graph.
- Geometric Constraints: Vittorio Giammarino and Ahmed H Qureshi introduced a Physics-informed Value Learner that uses the Eikonal equation to constrain the value function. By forcing the value function to behave like a distance field, the agent gains a global understanding of the environment's geometry, allowing it to infer the shortest path between points that were never connected in the training data.
Shifting the Constraint from Actions to States
A common reason stitching fails is that offline RL algorithms are often too "conservative"—they strictly penalize any action not found in the dataset. However, Charles Alexander Hepburn and Giovanni Montana propose a different approach in State-Constrained Offline Reinforcement Learning.
Their algorithm, StaCQ, shifts the constraint from actions to states. It allows the agent to take "out-of-distribution" actions as long as they lead back to "in-distribution" states. This flexibility is the key to stitching: it gives the agent the freedom to "jump" between two nearby but disconnected trajectories, effectively bridging the gaps in fragmented data.