Trajectory Stitching in Offline Reinforcement Learning

This direction is merged into another direction: trajectory stitching. Its last version stays readable and citable here.

Version 1 of 1161 papers204 conceptsfrozen 2026-10-04

The central promise of offline reinforcement learning is the ability to learn from "what has already happened" without the risk or cost of live exploration. However, most real-world datasets are messy: they consist of suboptimal human logs, failed experiments, or fragmented snippets of behavior. If an agent simply mimics this data—a process known as Behavioral Cloning—it will, at best, only ever be as good as the average demonstrator.

To surpass the data it was trained on, an agent must perform trajectory stitching. This is the ability to identify high-quality segments from different, potentially failing trajectories and recombine them into a single, optimal path that may never have been observed in its entirety.

The Intuition of the Midpoint

Imagine a robot trying to navigate a maze. In your dataset, Trajectory A successfully moves from the starting room to a central hallway but then gets lost and wanders into a dead end. Trajectory B starts in that same central hallway and successfully reaches the exit.

Neither trajectory is "expert." However, they share a common state: the central hallway. Trajectory stitching is the mechanism by which an agent recognizes that the first half of A and the second half of B can be joined at this "midpoint" to create a perfect solution. As Sergey Levine, Aviral Kumar, and colleagues note in Offline Reinforcement Learning: Tutorial, Review, and Perspectives on Open Problems, this capability allows agents to discover novel solutions that outperform the best individual demonstration in the training set.

Value Functions as the Thread

Why can't simple imitation learning stitch trajectories? Imitation treats every action in a sequence as equally valid. If a trajectory ends in failure, an imitation learner might mistakenly learn the "successful" early steps as being associated with that eventual failure.

To stitch, the agent needs a way to evaluate the potential of a state independently of the specific outcome of the trajectory it belongs to. This is where Temporal Difference (TD) learning and value functions come in. By learning a Q-function, the agent propagates reward signals backward through time.

In the maze example, the agent learns that being in the "central hallway" has high value because it could lead to the exit (as seen in Trajectory B), even if Trajectory A failed to capitalize on that potential. Algorithms like Implicit Q-Learning (IQL), developed by Ilya Kostrikov and Ashvin Nair, excel at this by using expectile regression to estimate the maximum possible value of actions present in the dataset without ever querying unseen, out-of-distribution actions Offline Reinforcement Learning with Implicit Q-Learning.

Bridging Sequence Modeling and Dynamic Programming

Recently, the field has seen a tension between Sequence Modeling (like Decision Transformers) and Dynamic Programming (like Q-learning).

Standard Decision Transformers (DT) are excellent at modeling complex distributions but often struggle with stitching because they are conditioned on "Return-to-Go"—the actual historical reward of a trajectory. If a trajectory was suboptimal, the DT simply learns to recreate that suboptimality.

To fix this, researchers have begun "upgrading" transformers with dynamic programming tools:

Stitching in Abstract Spaces

Stitching becomes significantly harder when the environment is partially observable or high-dimensional. If two trajectories pass through the "same" hallway but the robot's sensor logs look slightly different (due to lighting or noise), the agent might not realize they can be stitched.

Joey Hong and Anca D. Dragan have explored latent trajectory stitching, where observation histories are embedded into a shared latent space. This allows the algorithm to recognize functionally identical points in different trajectories, even if the raw data strings are unique Offline RL with Observation Histories: Analyzing and Improving Sample Complexity.

Similarly, Chongyi Zheng and Benjamin Eysenbach developed TD InfoNCE, which applies the logic of stitching to representation learning itself. By using TD updates to learn which states lead to which future states, the agent can "infer" shortcuts and paths between disjoint segments of experience that were never explicitly demonstrated Contrastive Difference Predictive Coding.

Why It Matters

Trajectory stitching transforms offline RL from a tool for mimicry into a tool for synthesis. It allows us to take a collection of "mediocre" data—like thousands of hours of average human driving or various failed robotic attempts at a task—and extract a single, "superhuman" policy. By treating the dataset not as a set of instructions to follow, but as a map of possibilities to be re-routed, stitching enables agents to solve long-horizon tasks that no single demonstrator ever completed.

Papers in this version

Showing 60 of 161 papers.

History & citationVersion 1 · 2026-10-04

Merged into another direction · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_trajectory_stitching_in_offline_reinforc_3fd7ea9a,
  title = {Trajectory Stitching in Offline Reinforcement Learning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/trajectory-stitching-in-offline-reinforcement-learning/rdr_3fd7ea9ae29745f78990d8a7c906a10f},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-26},
}

This exact version (version 1, frozen text):

@misc{lacuna_trajectory_stitching_in_offline_reinforc_3fd7ea9a_v1,
  title = {Trajectory Stitching in Offline Reinforcement Learning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/trajectory-stitching-in-offline-reinforcement-learning/rdr_3fd7ea9ae29745f78990d8a7c906a10f/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-26},
}