Skip to content

Commit ce7d71c

Browse files
committed
docs: add clarity to use of thread_id
1 parent 630bd9a commit ce7d71c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

libs/checkpoint/langgraph/checkpoint/base/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,25 @@ class BaseCheckpointSaver(Generic[V]):
119119
Checkpointers allow LangGraph agents to persist their state
120120
within and across multiple interactions.
121121
122+
When a checkpointer is configured, you **must** pass a `thread_id` in the
123+
config when invoking the graph:
124+
125+
```python
126+
config = {"configurable": {"thread_id": "my-thread"}}
127+
graph.invoke(inputs, config)
128+
```
129+
130+
The `thread_id` is the primary key used to store and retrieve checkpoints.
131+
Without it, the checkpointer cannot save state, resume from interrupts, or
132+
enable time-travel debugging.
133+
134+
How you choose ``thread_id`` depends on your use case:
135+
136+
- **Single-shot workflows**: Use a unique ID (e.g., `uuid.uuid4()`) for each
137+
run when executions are independent.
138+
- **Conversational memory**: Reuse the same `thread_id` across invocations
139+
to accumulate state (e.g., chat history) within a conversation.
140+
122141
Attributes:
123142
serde (SerializerProtocol): Serializer for encoding/decoding checkpoints.
124143

libs/langgraph/langgraph/graph/state.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,19 @@ def compile(
845845
If `None`, it may inherit the parent graph's checkpointer when used as a subgraph.
846846
847847
If `False`, it will not use or inherit any checkpointer.
848+
849+
**Important**: When a checkpointer is enabled, you must pass a `thread_id`
850+
in the config when invoking the graph:
851+
852+
```python
853+
config = {"configurable": {"thread_id": "my-thread"}}
854+
graph.invoke(inputs, config)
855+
```
856+
857+
The `thread_id` is the key used to store and retrieve checkpoints. Use a
858+
unique ID for independent runs, or reuse the same ID to accumulate state
859+
across invocations (e.g., for conversation memory).
860+
848861
interrupt_before: An optional list of node names to interrupt before.
849862
interrupt_after: An optional list of node names to interrupt after.
850863
debug: A flag indicating whether to enable debug mode.

0 commit comments

Comments
 (0)