mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-13 13:17:52 +02:00
docs: update replay in the concept docs (#3017)
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 214 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 397 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 214 KiB |
@@ -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).
|
||||
|
||||

|
||||

|
||||
|
||||
### Update state
|
||||
|
||||
|
||||
@@ -17,17 +17,9 @@ We call these debugging techniques **Time Travel**, composed of two key actions:
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user