docs: add clarity to use of thread_id (#6515)

This commit is contained in:
Mason Daugherty
2026-01-26 12:09:01 -08:00
committed by GitHub
parent 0a6145fd72
commit 3ff6340379
2 changed files with 32 additions and 0 deletions
@@ -119,6 +119,25 @@ class BaseCheckpointSaver(Generic[V]):
Checkpointers allow LangGraph agents to persist their state
within and across multiple interactions.
When a checkpointer is configured, you should pass a `thread_id` in the config when
invoking the graph:
```python
config = {"configurable": {"thread_id": "my-thread"}}
graph.invoke(inputs, config)
```
The `thread_id` is the primary key used to store and retrieve checkpoints. Without
it, the checkpointer cannot save state, resume from interrupts, or enable
time-travel debugging.
How you choose ``thread_id`` depends on your use case:
- **Single-shot workflows**: Use a unique ID (e.g., uuid4) for each run when
executions are independent.
- **Conversational memory**: Reuse the same `thread_id` across invocations
to accumulate state (e.g., chat history) within a conversation.
Attributes:
serde (SerializerProtocol): Serializer for encoding/decoding checkpoints.
+13
View File
@@ -1057,6 +1057,19 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]):
If `None`, it may inherit the parent graph's checkpointer when used as a subgraph.
If `False`, it will not use or inherit any checkpointer.
**Important**: When a checkpointer is enabled, you should pass a `thread_id`
in the config when invoking the graph:
```python
config = {"configurable": {"thread_id": "my-thread"}}
graph.invoke(inputs, config)
```
The `thread_id` is the key used to store and retrieve checkpoints. Use a
unique ID for independent runs, or reuse the same ID to accumulate state
across invocations (e.g., for conversation memory).
interrupt_before: An optional list of node names to interrupt before.
interrupt_after: An optional list of node names to interrupt after.
debug: A flag indicating whether to enable debug mode.