diff --git a/docs/docs/concepts/img/human_in_the_loop/replay.png b/docs/docs/concepts/img/human_in_the_loop/replay.png index 8a9d34b10..d32a0812f 100644 Binary files a/docs/docs/concepts/img/human_in_the_loop/replay.png and b/docs/docs/concepts/img/human_in_the_loop/replay.png differ diff --git a/docs/docs/concepts/img/persistence/re_play.jpg b/docs/docs/concepts/img/persistence/re_play.jpg deleted file mode 100644 index a4927ac76..000000000 Binary files a/docs/docs/concepts/img/persistence/re_play.jpg and /dev/null differ diff --git a/docs/docs/concepts/img/persistence/re_play.png b/docs/docs/concepts/img/persistence/re_play.png new file mode 100644 index 000000000..d32a0812f Binary files /dev/null and b/docs/docs/concepts/img/persistence/re_play.png differ diff --git a/docs/docs/concepts/persistence.md b/docs/docs/concepts/persistence.md index f3a014157..629a85897 100644 --- a/docs/docs/concepts/persistence.md +++ b/docs/docs/concepts/persistence.md @@ -147,24 +147,21 @@ In our example, the output of `get_state_history` will look like this: ### Replay -It's also possible to play-back a prior graph execution. If we `invoking` a graph with a `thread_id` and a `checkpoint_id`, then we will *re-play* the graph from a checkpoint that corresponds to the `checkpoint_id`. +It's also possible to play-back a prior graph execution. If we `invoke` a graph with a `thread_id` and a `checkpoint_id`, then we will *re-play* the previously executed steps _before_ a checkpoint that corresponds to the `checkpoint_id`, and only execute the steps _after_ the checkpoint. -* `thread_id` is simply the ID of a thread. This is always required. -* `checkpoint_id` This identifier refers to a specific checkpoint within a thread. +* `thread_id` is the ID of a thread. +* `checkpoint_id` is an identifier that refers to a specific checkpoint within a thread. You must pass these when invoking the graph as part of the `configurable` portion of the config: ```python -# {"configurable": {"thread_id": "1"}} # valid config -# {"configurable": {"thread_id": "1", "checkpoint_id": "0c62ca34-ac19-445d-bbb0-5b4984975b2a"}} # also valid config - -config = {"configurable": {"thread_id": "1"}} +config = {"configurable": {"thread_id": "1", "checkpoint_id": "0c62ca34-ac19-445d-bbb0-5b4984975b2a"}} graph.invoke(None, config=config) ``` -Importantly, LangGraph knows whether a particular checkpoint has been executed previously. If it has, LangGraph simply *re-plays* that particular step in the graph and does not re-execute the step. See this [how to guide on time-travel to learn more about replaying](../how-tos/human_in_the_loop/time-travel.ipynb). +Importantly, LangGraph knows whether a particular step has been executed previously. If it has, LangGraph simply *re-plays* that particular step in the graph and does not re-execute the step, but only for the steps _before_ the provided `checkpoint_id`. All of the steps _after_ `checkpoint_id` will be executed (i.e., a new fork), even if they have been executed previously. See this [how to guide on time-travel to learn more about replaying](../how-tos/human_in_the_loop/time-travel.ipynb). -![Replay](img/persistence/re_play.jpg) +![Replay](img/persistence/re_play.png) ### Update state diff --git a/docs/docs/concepts/time-travel.md b/docs/docs/concepts/time-travel.md index bb7fd334b..bf5e0925f 100644 --- a/docs/docs/concepts/time-travel.md +++ b/docs/docs/concepts/time-travel.md @@ -17,17 +17,9 @@ We call these debugging techniques **Time Travel**, composed of two key actions: ![](./img/human_in_the_loop/replay.png) -Replaying allows us to revisit and reproduce an agent's past actions. This can be done either from the current state (or checkpoint) of the graph or from a specific checkpoint. +Replaying allows us to revisit and reproduce an agent's past actions, up to and including a specific step (checkpoint). -To replay from the current state, simply pass `None` as the input along with a `thread`: - -```python -thread = {"configurable": {"thread_id": "1"}} -for event in graph.stream(None, thread, stream_mode="values"): - print(event) -``` - -To replay actions from a specific checkpoint, start by retrieving all checkpoints for the thread: +To replay actions before a specific checkpoint, start by retrieving all checkpoints for the thread: ```python all_checkpoints = [] @@ -43,7 +35,7 @@ for event in graph.stream(None, config, stream_mode="values"): print(event) ``` -The graph efficiently replays previously executed nodes instead of re-executing them, leveraging its awareness of prior checkpoint executions. +The graph replays previously executed steps _before_ the provided `checkpoint_id` and executes the steps _after_ `checkpoint_id` (i.e., a new fork), even if they have been executed previously. ## Forking