BaseCheckpointSaver is the abstract base class for all checkpoint savers in LangGraph. It defines the interface for persisting and retrieving agent state across multiple interactions.
Overview
Checkpointers allow LangGraph agents to:- Persist state within and across interactions
- Resume from interrupts
- Enable time-travel debugging
- Support conversational memory
Class Definition
langgraph.checkpoint.base.__init__:122
Constructor
Parameters
serde(SerializerProtocol, optional): Serializer for encoding/decoding checkpoints. Defaults toJsonPlusSerializer().
Key Concepts
Thread ID
When using a checkpointer, you must pass athread_id in the config:
thread_id is the primary key for storing and retrieving checkpoints. Without it, the checkpointer cannot save state.
Usage Patterns
- Single-shot workflows: Use a unique ID (e.g., uuid4) for each independent run
- Conversational memory: Reuse the same
thread_idto accumulate state across invocations
Core Methods
Synchronous Methods
get
config(RunnableConfig): Configuration specifying which checkpoint to retrieve
Checkpoint | None: The requested checkpoint, or None if not found
langgraph.checkpoint.base.__init__:173
get_tuple
config(RunnableConfig): Configuration specifying which checkpoint to retrieve
CheckpointTuple | None: The requested checkpoint tuple, or None if not found
langgraph.checkpoint.base.__init__:185
list
config(RunnableConfig | None): Base configuration for filtering checkpointsfilter(dict[str, Any] | None): Additional filtering criteria for metadatabefore(RunnableConfig | None): List checkpoints created before this configurationlimit(int | None): Maximum number of checkpoints to return
Iterator[CheckpointTuple]: Iterator of matching checkpoint tuples
langgraph.checkpoint.base.__init__:199
put
config(RunnableConfig): Configuration for the checkpointcheckpoint(Checkpoint): The checkpoint to storemetadata(CheckpointMetadata): Additional metadata for the checkpointnew_versions(ChannelVersions): New channel versions as of this write
RunnableConfig: Updated configuration after storing the checkpoint
langgraph.checkpoint.base.__init__:223
put_writes
config(RunnableConfig): Configuration of the related checkpointwrites(Sequence[tuple[str, Any]]): List of writes to storetask_id(str): Identifier for the task creating the writestask_path(str): Path of the task creating the writes (default: "")
langgraph.checkpoint.base.__init__:246
delete_thread
thread_id(str): The thread ID whose checkpoints should be deleted
langgraph.checkpoint.base.__init__:266
delete_for_runs
run_ids(Sequence[str]): The run IDs whose checkpoints should be deleted
langgraph.checkpoint.base.__init__:277
copy_thread
source_thread_id(str): The thread ID to copy fromtarget_thread_id(str): The thread ID to copy to
langgraph.checkpoint.base.__init__:288
prune
thread_ids(Sequence[str]): The thread IDs to prunestrategy(str): The pruning strategy. Options:"keep_latest": Retains only the most recent checkpoint per namespace"delete": Removes all checkpoints
langgraph.checkpoint.base.__init__:301
Asynchronous Methods
All synchronous methods have async equivalents with ana prefix:
aget(config)- Async version ofget()aget_tuple(config)- Async version ofget_tuple()alist(config, *, filter, before, limit)- Async version oflist()aput(config, checkpoint, metadata, new_versions)- Async version ofput()aput_writes(config, writes, task_id, task_path)- Async version ofput_writes()adelete_thread(thread_id)- Async version ofdelete_thread()adelete_for_runs(run_ids)- Async version ofdelete_for_runs()acopy_thread(source_thread_id, target_thread_id)- Async version ofcopy_thread()aprune(thread_ids, *, strategy)- Async version ofprune()
Utility Methods
get_next_version
current(V | None): The current version identifier (int, float, or str)channel(None): Deprecated argument, kept for backwards compatibility
V: The next version identifier, which must be monotonically increasing
langgraph.checkpoint.base.__init__:460
Data Types
Checkpoint
langgraph.checkpoint.base.__init__:65
CheckpointMetadata
langgraph.checkpoint.base.__init__:35
CheckpointTuple
langgraph.checkpoint.base.__init__:112
Implementation Notes
When creating a custom checkpoint saver:- Inherit from BaseCheckpointSaver: Extend this base class
- Implement required methods: At minimum, implement:
get_tuple()list()put()put_writes()
- Consider async support: Implement async versions to avoid blocking
- Handle serialization: Use the provided
serdefor encoding/decoding - Thread safety: Ensure your implementation is thread-safe if needed
See Also
- SqliteSaver - SQLite implementation
- PostgresSaver - Postgres implementation
- MemorySaver - In-memory implementation