mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-30 21:45:08 +02:00
checkpoint: combine metadata when writing checkpoints (#3404)
This commit is contained in:
@@ -397,7 +397,17 @@ class SqliteSaver(BaseCheckpointSaver[str]):
|
||||
thread_id = config["configurable"]["thread_id"]
|
||||
checkpoint_ns = config["configurable"]["checkpoint_ns"]
|
||||
type_, serialized_checkpoint = self.serde.dumps_typed(checkpoint)
|
||||
serialized_metadata = self.jsonplus_serde.dumps(metadata)
|
||||
serialized_metadata = self.jsonplus_serde.dumps(
|
||||
{
|
||||
**{
|
||||
k: v
|
||||
for k, v in config["configurable"].items()
|
||||
if not k.startswith("__")
|
||||
},
|
||||
**config.get("metadata", {}),
|
||||
**metadata,
|
||||
}
|
||||
)
|
||||
with self.cursor() as cur:
|
||||
cur.execute(
|
||||
"INSERT OR REPLACE INTO checkpoints (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, type, checkpoint, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
|
||||
@@ -463,7 +463,17 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
|
||||
thread_id = config["configurable"]["thread_id"]
|
||||
checkpoint_ns = config["configurable"]["checkpoint_ns"]
|
||||
type_, serialized_checkpoint = self.serde.dumps_typed(checkpoint)
|
||||
serialized_metadata = self.jsonplus_serde.dumps(metadata)
|
||||
serialized_metadata = self.jsonplus_serde.dumps(
|
||||
{
|
||||
**{
|
||||
k: v
|
||||
for k, v in config["configurable"].items()
|
||||
if not k.startswith("__")
|
||||
},
|
||||
**config.get("metadata", {}),
|
||||
**metadata,
|
||||
}
|
||||
)
|
||||
async with (
|
||||
self.lock,
|
||||
self.conn.execute(
|
||||
|
||||
Reference in New Issue
Block a user