Avoid saving checkpoints for subgraphs when checkpoint_during=False

- We can avoid saving checkpoints for successful subgraphs which do not request multi-turn memory
This commit is contained in:
Nuno Campos
2025-06-10 17:25:05 -07:00
parent 470b9a4b97
commit a4a8934bd3
+9 -1
View File
@@ -60,6 +60,7 @@ from langgraph.constants import (
INPUT,
INTERRUPT,
MISSING,
NS_END,
NS_SEP,
NULL_TASK_ID,
PUSH,
@@ -868,7 +869,14 @@ class PregelLoop:
traceback: TracebackType | None,
) -> bool | None:
# persist current checkpoint and writes
if not self.checkpoint_during:
if not self.checkpoint_during and (
# if it's a top graph
not self.is_nested
# or a nested graph with error or interrupt
or exc_value is not None
# or a nested graph with checkpointer=True
or all(NS_END not in part for part in self.checkpoint_ns)
):
self._put_checkpoint(self.checkpoint_metadata)
self._put_pending_writes()
# suppress interrupt