---
title: "Episode and trajectory"
url: https://www.daytona.com/definitions/e/episode-and-trajectory
---

# Episode and trajectory

An episode is one run of a task in reinforcement learning from start to end, and its trajectory is the recorded sequence of what happened.

In reinforcement learning, an episode is one complete attempt at a task. It starts from an initial state, continues as the policy acts and the environment responds, and ends when the task is done, fails or runs out of time. The trajectory is the record of that episode: each state, the action taken, and the reward received. In language-model training, a rollout produces one episode, and its trajectory is what training learns from.

Training learns from many trajectories at once. It compares those that earned high rewards with those that did not and adjusts the policy toward the better ones. Each episode has to start from the same kind of state, or the trajectories cannot be fairly compared. Long episodes give richer trajectories but cost more to run and make it harder to tell which action earned the reward.

For an agent, an episode can include many tool calls, each of which may run code or change files. Each episode therefore usually gets its own sandbox, started from a known image or snapshot. When the episode ends, a verifier checks the result, the trajectory is saved, and the sandbox is deleted or reset. Clean resets matter because leftover state from one episode would change the next one.
