Checkpointers¶
CheckpointMetadata
¶
Bases:
Metadata associated with a checkpoint.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
source: Literal['input', 'loop', 'update', 'fork']
instance-attribute
¶
The source of the checkpoint.
- "input": The checkpoint was created from an input to invoke/stream/batch.
- "loop": The checkpoint was created from inside the pregel loop.
- "update": The checkpoint was created from a manual state update.
- "fork": The checkpoint was created as a copy of another checkpoint.
step: int
instance-attribute
¶
The step number of the checkpoint.
-1 for the first "input" checkpoint. 0 for the first "loop" checkpoint. ... for the nth checkpoint afterwards.
writes: dict[str, Any]
instance-attribute
¶
The writes that were made between the previous checkpoint and this one.
Mapping from node name to writes emitted by that node.
parents: dict[str, str]
instance-attribute
¶
The IDs of the parent checkpoints.
Mapping from checkpoint namespace to checkpoint ID.
Checkpoint
¶
Bases:
State snapshot at a given point in time.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
v: int
instance-attribute
¶
The version of the checkpoint format. Currently 1.
id: str
instance-attribute
¶
The ID of the checkpoint. This is both unique and monotonically increasing, so can be used for sorting checkpoints from first to last.
ts: str
instance-attribute
¶
The timestamp of the checkpoint in ISO 8601 format.
channel_values: dict[str, Any]
instance-attribute
¶
The values of the channels at the time of the checkpoint. Mapping from channel name to deserialized channel snapshot value.
channel_versions: ChannelVersions
instance-attribute
¶
The versions of the channels at the time of the checkpoint. The keys are channel names and the values are monotonically increasing version strings for each channel.
versions_seen: dict[str, ChannelVersions]
instance-attribute
¶
Map from node ID to map from channel name to version seen. This keeps track of the versions of the channels that each node has seen. Used to determine which nodes to execute next.
pending_sends: List[SendProtocol]
instance-attribute
¶
List of inputs pushed to nodes but not yet processed. Cleared by the next checkpoint.
BaseCheckpointSaver
¶
Bases:
Base class for creating a graph checkpointer.
Checkpointers allow LangGraph agents to persist their state within and across multiple interactions.
Attributes:
-
(serde
) –SerializerProtocol Serializer for encoding/decoding checkpoints.
Note
When creating a custom checkpoint saver, consider implementing async versions to avoid blocking the main thread.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
config_specs: list[ConfigurableFieldSpec]
property
¶
Define the configuration options for the checkpoint saver.
Returns:
-
–list [ConfigurableFieldSpec ]list[ConfigurableFieldSpec]: List of configuration field specs.
get(config: RunnableConfig) -> Optional[Checkpoint]
¶
Fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
get_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
¶
Fetch a checkpoint tuple using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The requested checkpoint tuple, or None if not found.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
list(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> Iterator[CheckpointTuple]
¶
List checkpoints that match the given criteria.
Parameters:
-
config
(
) –Optional [RunnableConfig ]Base configuration for filtering checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria.
-
before
(
, default:Optional [RunnableConfig ]None
) –List checkpoints created before this configuration.
-
limit
(
, default:Optional [int ]None
) –Maximum number of checkpoints to return.
Returns:
-
–Iterator [CheckpointTuple ]Iterator[CheckpointTuple]: Iterator of matching checkpoint tuples.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
¶
Store a checkpoint with its configuration and metadata.
Parameters:
-
config
(
) –RunnableConfig Configuration for the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to store.
-
metadata
(
) –CheckpointMetadata Additional metadata for the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
put_writes(config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str) -> None
¶
Store intermediate writes linked to a checkpoint.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –List [Tuple [str ,Any ]]List of writes to store.
-
task_id
(
) –str Identifier for the task creating the writes.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aget(config: RunnableConfig) -> Optional[Checkpoint]
async
¶
Asynchronously fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aget_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
async
¶
Asynchronously fetch a checkpoint tuple using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The requested checkpoint tuple, or None if not found.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
alist(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> AsyncIterator[CheckpointTuple]
async
¶
Asynchronously list checkpoints that match the given criteria.
Parameters:
-
config
(
) –Optional [RunnableConfig ]Base configuration for filtering checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata.
-
before
(
, default:Optional [RunnableConfig ]None
) –List checkpoints created before this configuration.
-
limit
(
, default:Optional [int ]None
) –Maximum number of checkpoints to return.
Returns:
-
–AsyncIterator [CheckpointTuple ]AsyncIterator[CheckpointTuple]: Async iterator of matching checkpoint tuples.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aput(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
async
¶
Asynchronously store a checkpoint with its configuration and metadata.
Parameters:
-
config
(
) –RunnableConfig Configuration for the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to store.
-
metadata
(
) –CheckpointMetadata Additional metadata for the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aput_writes(config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str) -> None
async
¶
Asynchronously store intermediate writes linked to a checkpoint.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –List [Tuple [str ,Any ]]List of writes to store.
-
task_id
(
) –str Identifier for the task creating the writes.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
get_next_version(current: Optional[V], channel: ChannelProtocol) -> V
¶
Generate the next version ID for a channel.
Default is to use integer versions, incrementing by 1. If you override, you can use str/int/float versions, as long as they are monotonically increasing.
Parameters:
-
current
(
) –Optional [V ]The current version identifier (int, float, or str).
-
channel
(
) –BaseChannel The channel being versioned.
Returns:
-
V
(
) –V The next version identifier, which must be increasing.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
create_checkpoint(checkpoint: Checkpoint, channels: Optional[Mapping[str, ChannelProtocol]], step: int, *, id: Optional[str] = None) -> Checkpoint
¶
Create a checkpoint for the given channels.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
SerializerProtocol
¶
Bases:
Protocol for serialization and deserialization of objects.
dumps
: Serialize an object to bytes.dumps_typed
: Serialize an object to a tuple (type, bytes).loads
: Deserialize an object from bytes.loads_typed
: Deserialize an object from a tuple (type, bytes).
Valid implementations include the pickle
, json
and orjson
modules.
Source code in libs/checkpoint/langgraph/checkpoint/serde/base.py
JsonPlusSerializer
¶
Bases:
Source code in libs/checkpoint/langgraph/checkpoint/serde/jsonplus.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
MemorySaver
¶
Bases:
,
,
An in-memory checkpoint saver.
This checkpoint saver stores checkpoints in memory using a defaultdict.
Note
Only use MemorySaver
for debugging or testing purposes.
For production use cases we recommend installing langgraph-checkpoint-postgres and using PostgresSaver
/ AsyncPostgresSaver
.
Parameters:
-
serde
(
, default:Optional [SerializerProtocol ]None
) –The serializer to use for serializing and deserializing checkpoints. Defaults to None.
Examples:
import asyncio
from langgraph.checkpoint.memory import MemorySaver
from langgraph.graph import StateGraph
builder = StateGraph(int)
builder.add_node("add_one", lambda x: x + 1)
builder.set_entry_point("add_one")
builder.set_finish_point("add_one")
memory = MemorySaver()
graph = builder.compile(checkpointer=memory)
coro = graph.ainvoke(1, {"configurable": {"thread_id": "thread-1"}})
asyncio.run(coro) # Output: 2
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
|
config_specs: list[ConfigurableFieldSpec]
property
¶
Define the configuration options for the checkpoint saver.
Returns:
-
–list [ConfigurableFieldSpec ]list[ConfigurableFieldSpec]: List of configuration field specs.
get(config: RunnableConfig) -> Optional[Checkpoint]
¶
Fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aget(config: RunnableConfig) -> Optional[Checkpoint]
async
¶
Asynchronously fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
get_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
¶
Get a checkpoint tuple from the in-memory storage.
This method retrieves a checkpoint tuple from the in-memory storage based on the provided config. If the config contains a "checkpoint_id" key, the checkpoint with the matching thread ID and timestamp is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.
Parameters:
-
config
(
) –RunnableConfig The config to use for retrieving the checkpoint.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
list(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> Iterator[CheckpointTuple]
¶
List checkpoints from the in-memory storage.
This method retrieves a list of checkpoint tuples from the in-memory storage based on the provided criteria.
Parameters:
-
config
(
) –Optional [RunnableConfig ]Base configuration for filtering checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata.
-
before
(
, default:Optional [RunnableConfig ]None
) –List checkpoints created before this configuration.
-
limit
(
, default:Optional [int ]None
) –Maximum number of checkpoints to return.
Yields:
-
–CheckpointTuple Iterator[CheckpointTuple]: An iterator of matching checkpoint tuples.
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
¶
Save a checkpoint to the in-memory storage.
This method saves a checkpoint to the in-memory storage. The checkpoint is associated with the provided config.
Parameters:
-
config
(
) –RunnableConfig The config to associate with the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to save.
-
metadata
(
) –CheckpointMetadata Additional metadata to save with the checkpoint.
-
new_versions
(
) –dict New versions as of this write
Returns:
-
RunnableConfig
(
) –RunnableConfig The updated config containing the saved checkpoint's timestamp.
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
put_writes(config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str) -> None
¶
Save a list of writes to the in-memory storage.
This method saves a list of writes to the in-memory storage. The writes are associated with the provided config.
Parameters:
-
config
(
) –RunnableConfig The config to associate with the writes.
-
writes
(
) –list [tuple [str ,Any ]]The writes to save.
-
task_id
(
) –str Identifier for the task creating the writes.
Returns:
-
RunnableConfig
(None
) –The updated config containing the saved writes' timestamp.
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
aget_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
async
¶
Asynchronous version of get_tuple.
This method is an asynchronous wrapper around get_tuple that runs the synchronous method in a separate thread using asyncio.
Parameters:
-
config
(
) –RunnableConfig The config to use for retrieving the checkpoint.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
alist(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> AsyncIterator[CheckpointTuple]
async
¶
Asynchronous version of list.
This method is an asynchronous wrapper around list that runs the synchronous method in a separate thread using asyncio.
Parameters:
-
config
(
) –RunnableConfig The config to use for listing the checkpoints.
Yields:
-
–AsyncIterator [CheckpointTuple ]AsyncIterator[CheckpointTuple]: An asynchronous iterator of checkpoint tuples.
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
aput(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
async
¶
Asynchronous version of put.
Parameters:
-
config
(
) –RunnableConfig The config to associate with the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to save.
-
metadata
(
) –CheckpointMetadata Additional metadata to save with the checkpoint.
-
new_versions
(
) –dict New versions as of this write
Returns:
-
RunnableConfig
(
) –RunnableConfig The updated config containing the saved checkpoint's timestamp.
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
aput_writes(config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str) -> None
async
¶
Asynchronous version of put_writes.
This method is an asynchronous wrapper around put_writes that runs the synchronous method in a separate thread using asyncio.
Parameters:
-
config
(
) –RunnableConfig The config to associate with the writes.
-
writes
(
) –List [Tuple [str ,Any ]]The writes to save, each as a (channel, value) pair.
-
task_id
(
) –str Identifier for the task creating the writes.
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
PersistentDict
¶
Bases:
Persistent dictionary with an API compatible with shelve and anydbm.
The dict is kept in memory, so the dictionary operations run as fast as a regular dictionary.
Write to disk is delayed until close or sync (similar to gdbm's fast mode).
Input file format is automatically discovered. Output file format is selectable between pickle, json, and csv. All three serialization formats are backed by fast C implementations.
Adapted from https://code.activestate.com/recipes/576642-persistent-dict-with-multiple-standard-file-format/
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
sync() -> None
¶
Write dict to disk
Source code in libs/checkpoint/langgraph/checkpoint/memory/__init__.py
SqliteSaver
¶
Bases:
A checkpoint saver that stores checkpoints in a SQLite database.
Note
This class is meant for lightweight, synchronous use cases
(demos and small projects) and does not
scale to multiple threads.
For a similar sqlite saver with async
support,
consider using AsyncSqliteSaver.
Parameters:
-
conn
(
) –Connection The SQLite database connection.
-
serde
(
, default:Optional [SerializerProtocol ]None
) –The serializer to use for serializing and deserializing checkpoints. Defaults to JsonPlusSerializerCompat.
Examples:
>>> import sqlite3
>>> from langgraph.checkpoint.sqlite import SqliteSaver
>>> from langgraph.graph import StateGraph
>>>
>>> builder = StateGraph(int)
>>> builder.add_node("add_one", lambda x: x + 1)
>>> builder.set_entry_point("add_one")
>>> builder.set_finish_point("add_one")
>>> conn = sqlite3.connect("checkpoints.sqlite")
>>> memory = SqliteSaver(conn)
>>> graph = builder.compile(checkpointer=memory)
>>> config = {"configurable": {"thread_id": "1"}}
>>> graph.get_state(config)
>>> result = graph.invoke(3, config)
>>> graph.get_state(config)
StateSnapshot(values=4, next=(), config={'configurable': {'thread_id': '1', 'checkpoint_ns': '', 'checkpoint_id': '0c62ca34-ac19-445d-bbb0-5b4984975b2a'}}, parent_config=None)
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
|
config_specs: list[ConfigurableFieldSpec]
property
¶
Define the configuration options for the checkpoint saver.
Returns:
-
–list [ConfigurableFieldSpec ]list[ConfigurableFieldSpec]: List of configuration field specs.
get(config: RunnableConfig) -> Optional[Checkpoint]
¶
Fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aget(config: RunnableConfig) -> Optional[Checkpoint]
async
¶
Asynchronously fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aput_writes(config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str) -> None
async
¶
Asynchronously store intermediate writes linked to a checkpoint.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –List [Tuple [str ,Any ]]List of writes to store.
-
task_id
(
) –str Identifier for the task creating the writes.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
from_conn_string(conn_string: str) -> Iterator[SqliteSaver]
classmethod
¶
Create a new SqliteSaver instance from a connection string.
Parameters:
-
conn_string
(
) –str The SQLite connection string.
Yields:
-
SqliteSaver
(
) –SqliteSaver A new SqliteSaver instance.
Examples:
In memory:
with SqliteSaver.from_conn_string(":memory:") as memory:
...
To disk:
with SqliteSaver.from_conn_string("checkpoints.sqlite") as memory:
...
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
setup() -> None
¶
Set up the checkpoint database.
This method creates the necessary tables in the SQLite database if they don't already exist. It is called automatically when needed and should not be called directly by the user.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
cursor(transaction: bool = True) -> Iterator[sqlite3.Cursor]
¶
Get a cursor for the SQLite database.
This method returns a cursor for the SQLite database. It is used internally by the SqliteSaver and should not be called directly by the user.
Parameters:
-
transaction
(
, default:bool True
) –Whether to commit the transaction when the cursor is closed. Defaults to True.
Yields:
-
–Cursor sqlite3.Cursor: A cursor for the SQLite database.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
get_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
¶
Get a checkpoint tuple from the database.
This method retrieves a checkpoint tuple from the SQLite database based on the provided config. If the config contains a "checkpoint_id" key, the checkpoint with the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.
Parameters:
-
config
(
) –RunnableConfig The config to use for retrieving the checkpoint.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
Examples:
Basic:
>>> config = {"configurable": {"thread_id": "1"}}
>>> checkpoint_tuple = memory.get_tuple(config)
>>> print(checkpoint_tuple)
CheckpointTuple(...)
With checkpoint ID:
>>> config = {
... "configurable": {
... "thread_id": "1",
... "checkpoint_ns": "",
... "checkpoint_id": "1ef4f797-8335-6428-8001-8a1503f9b875",
... }
... }
>>> checkpoint_tuple = memory.get_tuple(config)
>>> print(checkpoint_tuple)
CheckpointTuple(...)
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
list(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> Iterator[CheckpointTuple]
¶
List checkpoints from the database.
This method retrieves a list of checkpoint tuples from the SQLite database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).
Parameters:
-
config
(
) –RunnableConfig The config to use for listing the checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata. Defaults to None.
-
before
(
, default:Optional [RunnableConfig ]None
) –If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None.
-
limit
(
, default:Optional [int ]None
) –The maximum number of checkpoints to return. Defaults to None.
Yields:
-
–CheckpointTuple Iterator[CheckpointTuple]: An iterator of checkpoint tuples.
Examples:
>>> from langgraph.checkpoint.sqlite import SqliteSaver
>>> with SqliteSaver.from_conn_string(":memory:") as memory:
... # Run a graph, then list the checkpoints
>>> config = {"configurable": {"thread_id": "1"}}
>>> checkpoints = list(memory.list(config, limit=2))
>>> print(checkpoints)
[CheckpointTuple(...), CheckpointTuple(...)]
>>> config = {"configurable": {"thread_id": "1"}}
>>> before = {"configurable": {"checkpoint_id": "1ef4f797-8335-6428-8001-8a1503f9b875"}}
>>> with SqliteSaver.from_conn_string(":memory:") as memory:
... # Run a graph, then list the checkpoints
>>> checkpoints = list(memory.list(config, before=before))
>>> print(checkpoints)
[CheckpointTuple(...), ...]
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
¶
Save a checkpoint to the database.
This method saves a checkpoint to the SQLite database. The checkpoint is associated with the provided config and its parent config (if any).
Parameters:
-
config
(
) –RunnableConfig The config to associate with the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to save.
-
metadata
(
) –CheckpointMetadata Additional metadata to save with the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Examples:
>>> from langgraph.checkpoint.sqlite import SqliteSaver
>>> with SqliteSaver.from_conn_string(":memory:") as memory:
>>> config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
>>> checkpoint = {"ts": "2024-05-04T06:32:42.235444+00:00", "id": "1ef4f797-8335-6428-8001-8a1503f9b875", "channel_values": {"key": "value"}}
>>> saved_config = memory.put(config, checkpoint, {"source": "input", "step": 1, "writes": {"key": "value"}}, {})
>>> print(saved_config)
{'configurable': {'thread_id': '1', 'checkpoint_ns': '', 'checkpoint_id': '1ef4f797-8335-6428-8001-8a1503f9b875'}}
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
put_writes(config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str) -> None
¶
Store intermediate writes linked to a checkpoint.
This method saves intermediate writes associated with a checkpoint to the SQLite database.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –Sequence [Tuple [str ,Any ]]List of writes to store, each as (channel, value) pair.
-
task_id
(
) –str Identifier for the task creating the writes.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
aget_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
async
¶
Get a checkpoint tuple from the database asynchronously.
Note
This async method is not supported by the SqliteSaver class. Use get_tuple() instead, or consider using AsyncSqliteSaver.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
alist(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> AsyncIterator[CheckpointTuple]
async
¶
List checkpoints from the database asynchronously.
Note
This async method is not supported by the SqliteSaver class. Use list() instead, or consider using AsyncSqliteSaver.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
aput(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
async
¶
Save a checkpoint to the database asynchronously.
Note
This async method is not supported by the SqliteSaver class. Use put() instead, or consider using AsyncSqliteSaver.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
get_next_version(current: Optional[str], channel: ChannelProtocol) -> str
¶
Generate the next version ID for a channel.
This method creates a new version identifier for a channel based on its current version.
Parameters:
-
current
(
) –Optional [str ]The current version identifier of the channel.
-
channel
(
) –BaseChannel The channel being versioned.
Returns:
-
str
(
) –str The next version identifier, which is guaranteed to be monotonically increasing.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py
AsyncSqliteSaver
¶
Bases:
An asynchronous checkpoint saver that stores checkpoints in a SQLite database.
This class provides an asynchronous interface for saving and retrieving checkpoints using a SQLite database. It's designed for use in asynchronous environments and offers better performance for I/O-bound operations compared to synchronous alternatives.
Attributes:
-
(conn
) –Connection The asynchronous SQLite database connection.
-
(serde
) –SerializerProtocol The serializer used for encoding/decoding checkpoints.
Tip
Requires the aiosqlite package.
Install it with pip install aiosqlite
.
Warning
While this class supports asynchronous checkpointing, it is not recommended for production workloads due to limitations in SQLite's write performance. For production use, consider a more robust database like PostgreSQL.
Tip
Remember to close the database connection after executing your code, otherwise, you may see the graph "hang" after execution (since the program will not exit until the connection is closed).
The easiest way is to use the async with
statement as shown in the examples.
Examples:
Usage within StateGraph:
>>> import asyncio
>>>
>>> from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
>>> from langgraph.graph import StateGraph
>>>
>>> builder = StateGraph(int)
>>> builder.add_node("add_one", lambda x: x + 1)
>>> builder.set_entry_point("add_one")
>>> builder.set_finish_point("add_one")
>>> async with AsyncSqliteSaver.from_conn_string("checkpoints.db") as memory:
>>> graph = builder.compile(checkpointer=memory)
>>> coro = graph.ainvoke(1, {"configurable": {"thread_id": "thread-1"}})
>>> print(asyncio.run(coro))
Output: 2
>>> import asyncio
>>> import aiosqlite
>>> from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
>>>
>>> async def main():
>>> async with aiosqlite.connect("checkpoints.db") as conn:
... saver = AsyncSqliteSaver(conn)
... config = {"configurable": {"thread_id": "1"}}
... checkpoint = {"ts": "2023-05-03T10:00:00Z", "data": {"key": "value"}}
... saved_config = await saver.aput(config, checkpoint, {}, {})
... print(saved_config)
>>> asyncio.run(main())
{"configurable": {"thread_id": "1", "checkpoint_id": "0c62ca34-ac19-445d-bbb0-5b4984975b2a"}}
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
config_specs: list[ConfigurableFieldSpec]
property
¶
Define the configuration options for the checkpoint saver.
Returns:
-
–list [ConfigurableFieldSpec ]list[ConfigurableFieldSpec]: List of configuration field specs.
get(config: RunnableConfig) -> Optional[Checkpoint]
¶
Fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aget(config: RunnableConfig) -> Optional[Checkpoint]
async
¶
Asynchronously fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
from_conn_string(conn_string: str) -> AsyncIterator[AsyncSqliteSaver]
async
classmethod
¶
Create a new AsyncSqliteSaver instance from a connection string.
Parameters:
-
conn_string
(
) –str The SQLite connection string.
Yields:
-
AsyncSqliteSaver
(
) –AsyncIterator [AsyncSqliteSaver ]A new AsyncSqliteSaver instance.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
get_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
¶
Get a checkpoint tuple from the database.
This method retrieves a checkpoint tuple from the SQLite database based on the provided config. If the config contains a "checkpoint_id" key, the checkpoint with the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.
Parameters:
-
config
(
) –RunnableConfig The config to use for retrieving the checkpoint.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
list(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> Iterator[CheckpointTuple]
¶
List checkpoints from the database asynchronously.
This method retrieves a list of checkpoint tuples from the SQLite database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).
Parameters:
-
config
(
) –Optional [RunnableConfig ]Base configuration for filtering checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata.
-
before
(
, default:Optional [RunnableConfig ]None
) –If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None.
-
limit
(
, default:Optional [int ]None
) –Maximum number of checkpoints to return.
Yields:
-
–CheckpointTuple Iterator[CheckpointTuple]: An iterator of matching checkpoint tuples.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
¶
Save a checkpoint to the database.
This method saves a checkpoint to the SQLite database. The checkpoint is associated with the provided config and its parent config (if any).
Parameters:
-
config
(
) –RunnableConfig The config to associate with the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to save.
-
metadata
(
) –CheckpointMetadata Additional metadata to save with the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
setup() -> None
async
¶
Set up the checkpoint database asynchronously.
This method creates the necessary tables in the SQLite database if they don't already exist. It is called automatically when needed and should not be called directly by the user.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
aget_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
async
¶
Get a checkpoint tuple from the database asynchronously.
This method retrieves a checkpoint tuple from the SQLite database based on the provided config. If the config contains a "checkpoint_id" key, the checkpoint with the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.
Parameters:
-
config
(
) –RunnableConfig The config to use for retrieving the checkpoint.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
|
alist(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> AsyncIterator[CheckpointTuple]
async
¶
List checkpoints from the database asynchronously.
This method retrieves a list of checkpoint tuples from the SQLite database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).
Parameters:
-
config
(
) –Optional [RunnableConfig ]Base configuration for filtering checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata.
-
before
(
, default:Optional [RunnableConfig ]None
) –If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None.
-
limit
(
, default:Optional [int ]None
) –Maximum number of checkpoints to return.
Yields:
-
–AsyncIterator [CheckpointTuple ]AsyncIterator[CheckpointTuple]: An asynchronous iterator of matching checkpoint tuples.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
aput(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
async
¶
Save a checkpoint to the database asynchronously.
This method saves a checkpoint to the SQLite database. The checkpoint is associated with the provided config and its parent config (if any).
Parameters:
-
config
(
) –RunnableConfig The config to associate with the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to save.
-
metadata
(
) –CheckpointMetadata Additional metadata to save with the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
aput_writes(config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str) -> None
async
¶
Store intermediate writes linked to a checkpoint asynchronously.
This method saves intermediate writes associated with a checkpoint to the database.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –Sequence [Tuple [str ,Any ]]List of writes to store, each as (channel, value) pair.
-
task_id
(
) –str Identifier for the task creating the writes.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
get_next_version(current: Optional[str], channel: ChannelProtocol) -> str
¶
Generate the next version ID for a channel.
This method creates a new version identifier for a channel based on its current version.
Parameters:
-
current
(
) –Optional [str ]The current version identifier of the channel.
-
channel
(
) –BaseChannel The channel being versioned.
Returns:
-
str
(
) –str The next version identifier, which is guaranteed to be monotonically increasing.
Source code in libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py
PostgresSaver
¶
Bases:
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
|
config_specs: list[ConfigurableFieldSpec]
property
¶
Define the configuration options for the checkpoint saver.
Returns:
-
–list [ConfigurableFieldSpec ]list[ConfigurableFieldSpec]: List of configuration field specs.
get(config: RunnableConfig) -> Optional[Checkpoint]
¶
Fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aget(config: RunnableConfig) -> Optional[Checkpoint]
async
¶
Asynchronously fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aget_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
async
¶
Asynchronously fetch a checkpoint tuple using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The requested checkpoint tuple, or None if not found.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
alist(config: Optional[RunnableConfig], *, filter: Optional[Dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> AsyncIterator[CheckpointTuple]
async
¶
Asynchronously list checkpoints that match the given criteria.
Parameters:
-
config
(
) –Optional [RunnableConfig ]Base configuration for filtering checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata.
-
before
(
, default:Optional [RunnableConfig ]None
) –List checkpoints created before this configuration.
-
limit
(
, default:Optional [int ]None
) –Maximum number of checkpoints to return.
Returns:
-
–AsyncIterator [CheckpointTuple ]AsyncIterator[CheckpointTuple]: Async iterator of matching checkpoint tuples.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aput(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
async
¶
Asynchronously store a checkpoint with its configuration and metadata.
Parameters:
-
config
(
) –RunnableConfig Configuration for the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to store.
-
metadata
(
) –CheckpointMetadata Additional metadata for the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aput_writes(config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str) -> None
async
¶
Asynchronously store intermediate writes linked to a checkpoint.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –List [Tuple [str ,Any ]]List of writes to store.
-
task_id
(
) –str Identifier for the task creating the writes.
Raises:
-
–NotImplementedError Implement this method in your custom checkpoint saver.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
from_conn_string(conn_string: str, *, pipeline: bool = False) -> Iterator[PostgresSaver]
classmethod
¶
Create a new PostgresSaver instance from a connection string.
Parameters:
-
conn_string
(
) –str The Postgres connection info string.
-
pipeline
(
, default:bool False
) –whether to use Pipeline
Returns:
-
PostgresSaver
(
) –Iterator [PostgresSaver ]A new PostgresSaver instance.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py
setup() -> None
¶
Set up the checkpoint database asynchronously.
This method creates the necessary tables in the Postgres database if they don't already exist and runs database migrations. It MUST be called directly by the user the first time checkpointer is used.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py
list(config: Optional[RunnableConfig], *, filter: Optional[dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> Iterator[CheckpointTuple]
¶
List checkpoints from the database.
This method retrieves a list of checkpoint tuples from the Postgres database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).
Parameters:
-
config
(
) –RunnableConfig The config to use for listing the checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata. Defaults to None.
-
before
(
, default:Optional [RunnableConfig ]None
) –If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None.
-
limit
(
, default:Optional [int ]None
) –The maximum number of checkpoints to return. Defaults to None.
Yields:
-
–CheckpointTuple Iterator[CheckpointTuple]: An iterator of checkpoint tuples.
Examples:
>>> from langgraph.checkpoint.postgres import PostgresSaver
>>> DB_URI = "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
>>> with PostgresSaver.from_conn_string(DB_URI) as memory:
... # Run a graph, then list the checkpoints
>>> config = {"configurable": {"thread_id": "1"}}
>>> checkpoints = list(memory.list(config, limit=2))
>>> print(checkpoints)
[CheckpointTuple(...), CheckpointTuple(...)]
>>> config = {"configurable": {"thread_id": "1"}}
>>> before = {"configurable": {"checkpoint_id": "1ef4f797-8335-6428-8001-8a1503f9b875"}}
>>> with PostgresSaver.from_conn_string(DB_URI) as memory:
... # Run a graph, then list the checkpoints
>>> checkpoints = list(memory.list(config, before=before))
>>> print(checkpoints)
[CheckpointTuple(...), ...]
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py
get_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
¶
Get a checkpoint tuple from the database.
This method retrieves a checkpoint tuple from the Postgres database based on the provided config. If the config contains a "checkpoint_id" key, the checkpoint with the matching thread ID and timestamp is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.
Parameters:
-
config
(
) –RunnableConfig The config to use for retrieving the checkpoint.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
Examples:
Basic:
>>> config = {"configurable": {"thread_id": "1"}}
>>> checkpoint_tuple = memory.get_tuple(config)
>>> print(checkpoint_tuple)
CheckpointTuple(...)
With timestamp:
>>> config = {
... "configurable": {
... "thread_id": "1",
... "checkpoint_ns": "",
... "checkpoint_id": "1ef4f797-8335-6428-8001-8a1503f9b875",
... }
... }
>>> checkpoint_tuple = memory.get_tuple(config)
>>> print(checkpoint_tuple)
CheckpointTuple(...)
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
¶
Save a checkpoint to the database.
This method saves a checkpoint to the Postgres database. The checkpoint is associated with the provided config and its parent config (if any).
Parameters:
-
config
(
) –RunnableConfig The config to associate with the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to save.
-
metadata
(
) –CheckpointMetadata Additional metadata to save with the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Examples:
>>> from langgraph.checkpoint.postgres import PostgresSaver
>>> DB_URI = "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
>>> with PostgresSaver.from_conn_string(DB_URI) as memory:
>>> config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
>>> checkpoint = {"ts": "2024-05-04T06:32:42.235444+00:00", "id": "1ef4f797-8335-6428-8001-8a1503f9b875", "channel_values": {"key": "value"}}
>>> saved_config = memory.put(config, checkpoint, {"source": "input", "step": 1, "writes": {"key": "value"}}, {})
>>> print(saved_config)
{'configurable': {'thread_id': '1', 'checkpoint_ns': '', 'checkpoint_id': '1ef4f797-8335-6428-8001-8a1503f9b875'}}
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py
put_writes(config: RunnableConfig, writes: Sequence[tuple[str, Any]], task_id: str) -> None
¶
Store intermediate writes linked to a checkpoint.
This method saves intermediate writes associated with a checkpoint to the Postgres database.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –List [Tuple [str ,Any ]]List of writes to store.
-
task_id
(
) –str Identifier for the task creating the writes.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py
AsyncPostgresSaver
¶
Bases:
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
config_specs: list[ConfigurableFieldSpec]
property
¶
Define the configuration options for the checkpoint saver.
Returns:
-
–list [ConfigurableFieldSpec ]list[ConfigurableFieldSpec]: List of configuration field specs.
get(config: RunnableConfig) -> Optional[Checkpoint]
¶
Fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
aget(config: RunnableConfig) -> Optional[Checkpoint]
async
¶
Asynchronously fetch a checkpoint using the given configuration.
Parameters:
-
config
(
) –RunnableConfig Configuration specifying which checkpoint to retrieve.
Returns:
-
–Optional [Checkpoint ]Optional[Checkpoint]: The requested checkpoint, or None if not found.
Source code in libs/checkpoint/langgraph/checkpoint/base/__init__.py
from_conn_string(conn_string: str, *, pipeline: bool = False, serde: Optional[SerializerProtocol] = None) -> AsyncIterator[AsyncPostgresSaver]
async
classmethod
¶
Create a new PostgresSaver instance from a connection string.
Parameters:
-
conn_string
(
) –str The Postgres connection info string.
-
pipeline
(
, default:bool False
) –whether to use AsyncPipeline
Returns:
-
AsyncPostgresSaver
(
) –AsyncIterator [AsyncPostgresSaver ]A new AsyncPostgresSaver instance.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
setup() -> None
async
¶
Set up the checkpoint database asynchronously.
This method creates the necessary tables in the Postgres database if they don't already exist and runs database migrations. It MUST be called directly by the user the first time checkpointer is used.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
alist(config: Optional[RunnableConfig], *, filter: Optional[dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> AsyncIterator[CheckpointTuple]
async
¶
List checkpoints from the database asynchronously.
This method retrieves a list of checkpoint tuples from the Postgres database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).
Parameters:
-
config
(
) –Optional [RunnableConfig ]Base configuration for filtering checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata.
-
before
(
, default:Optional [RunnableConfig ]None
) –If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None.
-
limit
(
, default:Optional [int ]None
) –Maximum number of checkpoints to return.
Yields:
-
–AsyncIterator [CheckpointTuple ]AsyncIterator[CheckpointTuple]: An asynchronous iterator of matching checkpoint tuples.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
aget_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
async
¶
Get a checkpoint tuple from the database asynchronously.
This method retrieves a checkpoint tuple from the Postgres database based on the provided config. If the config contains a "checkpoint_id" key, the checkpoint with the matching thread ID and "checkpoint_id" is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.
Parameters:
-
config
(
) –RunnableConfig The config to use for retrieving the checkpoint.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
aput(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
async
¶
Save a checkpoint to the database asynchronously.
This method saves a checkpoint to the Postgres database. The checkpoint is associated with the provided config and its parent config (if any).
Parameters:
-
config
(
) –RunnableConfig The config to associate with the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to save.
-
metadata
(
) –CheckpointMetadata Additional metadata to save with the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
aput_writes(config: RunnableConfig, writes: Sequence[tuple[str, Any]], task_id: str) -> None
async
¶
Store intermediate writes linked to a checkpoint asynchronously.
This method saves intermediate writes associated with a checkpoint to the database.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –Sequence [Tuple [str ,Any ]]List of writes to store, each as (channel, value) pair.
-
task_id
(
) –str Identifier for the task creating the writes.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
list(config: Optional[RunnableConfig], *, filter: Optional[dict[str, Any]] = None, before: Optional[RunnableConfig] = None, limit: Optional[int] = None) -> Iterator[CheckpointTuple]
¶
List checkpoints from the database.
This method retrieves a list of checkpoint tuples from the Postgres database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).
Parameters:
-
config
(
) –Optional [RunnableConfig ]Base configuration for filtering checkpoints.
-
filter
(
, default:Optional [Dict [str ,Any ]]None
) –Additional filtering criteria for metadata.
-
before
(
, default:Optional [RunnableConfig ]None
) –If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None.
-
limit
(
, default:Optional [int ]None
) –Maximum number of checkpoints to return.
Yields:
-
–CheckpointTuple Iterator[CheckpointTuple]: An iterator of matching checkpoint tuples.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
get_tuple(config: RunnableConfig) -> Optional[CheckpointTuple]
¶
Get a checkpoint tuple from the database.
This method retrieves a checkpoint tuple from the Postgres database based on the provided config. If the config contains a "checkpoint_id" key, the checkpoint with the matching thread ID and "checkpoint_id" is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.
Parameters:
-
config
(
) –RunnableConfig The config to use for retrieving the checkpoint.
Returns:
-
–Optional [CheckpointTuple ]Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, new_versions: ChannelVersions) -> RunnableConfig
¶
Save a checkpoint to the database.
This method saves a checkpoint to the Postgres database. The checkpoint is associated with the provided config and its parent config (if any).
Parameters:
-
config
(
) –RunnableConfig The config to associate with the checkpoint.
-
checkpoint
(
) –Checkpoint The checkpoint to save.
-
metadata
(
) –CheckpointMetadata Additional metadata to save with the checkpoint.
-
new_versions
(
) –ChannelVersions New channel versions as of this write.
Returns:
-
RunnableConfig
(
) –RunnableConfig Updated configuration after storing the checkpoint.
Source code in libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py
put_writes(config: RunnableConfig, writes: Sequence[tuple[str, Any]], task_id: str) -> None
¶
Store intermediate writes linked to a checkpoint.
This method saves intermediate writes associated with a checkpoint to the database.
Parameters:
-
config
(
) –RunnableConfig Configuration of the related checkpoint.
-
writes
(
) –Sequence [Tuple [str ,Any ]]List of writes to store, each as (channel, value) pair.
-
task_id
(
) –str Identifier for the task creating the writes.