From 36e49eb1903b68e846e9766ee2b30f2878bc4501 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Fri, 15 Nov 2024 17:04:40 -0800 Subject: [PATCH] Add distinct source --- libs/checkpoint/langgraph/checkpoint/base/__init__.py | 3 ++- libs/langgraph/langgraph/pregel/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/checkpoint/langgraph/checkpoint/base/__init__.py b/libs/checkpoint/langgraph/checkpoint/base/__init__.py index a3ad83b1a..6805ada0e 100644 --- a/libs/checkpoint/langgraph/checkpoint/base/__init__.py +++ b/libs/checkpoint/langgraph/checkpoint/base/__init__.py @@ -39,12 +39,13 @@ PendingWrite = Tuple[str, str, Any] class CheckpointMetadata(TypedDict, total=False): """Metadata associated with a checkpoint.""" - source: Literal["input", "loop", "update"] + source: Literal["input", "loop", "update", "fork"] """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 """The step number of the checkpoint. diff --git a/libs/langgraph/langgraph/pregel/__init__.py b/libs/langgraph/langgraph/pregel/__init__.py index f49a2207a..b6bfa895a 100644 --- a/libs/langgraph/langgraph/pregel/__init__.py +++ b/libs/langgraph/langgraph/pregel/__init__.py @@ -946,7 +946,7 @@ class Pregel(PregelProtocol): create_checkpoint(checkpoint, None, step), { **checkpoint_metadata, - "source": "update", + "source": "fork", "step": step + 1, "writes": {}, "parents": saved.metadata.get("parents", {}) if saved else {}, @@ -965,7 +965,7 @@ class Pregel(PregelProtocol): next_checkpoint, { **checkpoint_metadata, - "source": "update", + "source": "fork", "step": step + 1, "writes": {}, "parents": saved.metadata.get("parents", {}) if saved else {},