mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
When retrying a previously attempted run, resume from previous checkpoint
- Ignore input if being passed in when a checkpoint already exists for that run_id
This commit is contained in:
@@ -55,6 +55,7 @@ from langgraph.constants import (
|
||||
ERROR,
|
||||
INPUT,
|
||||
INTERRUPT,
|
||||
MISSING,
|
||||
NS_SEP,
|
||||
NULL_TASK_ID,
|
||||
PUSH,
|
||||
@@ -566,7 +567,10 @@ class PregelLoop(LoopProtocol):
|
||||
is_resuming = bool(self.checkpoint["channel_versions"]) and bool(
|
||||
configurable.get(
|
||||
CONFIG_KEY_RESUMING,
|
||||
self.input is None or isinstance(self.input, Command),
|
||||
self.input is None
|
||||
or isinstance(self.input, Command)
|
||||
or self.config.get("metadata", {}).get("run_id")
|
||||
== self.checkpoint_metadata.get("run_id", MISSING),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -939,6 +943,8 @@ class SyncPregelLoop(PregelLoop, ContextManager):
|
||||
self.prev_checkpoint_config = saved.parent_config
|
||||
self.checkpoint = saved.checkpoint
|
||||
self.checkpoint_metadata = saved.metadata
|
||||
if self.config.get("metadata").get("run_id") == saved.metadata.get("run_id"):
|
||||
self.resuming = True
|
||||
self.checkpoint_pending_writes = (
|
||||
[(str(tid), k, v) for tid, k, v in saved.pending_writes]
|
||||
if saved.pending_writes is not None
|
||||
|
||||
Reference in New Issue
Block a user