From 5fee0d9d660d9c9a00aeea00e69a11f685b492a6 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Mon, 28 Apr 2025 11:47:51 -0400 Subject: [PATCH] skip yielding interrupt if input was a map --- libs/langgraph/langgraph/pregel/loop.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/loop.py b/libs/langgraph/langgraph/pregel/loop.py index e71972fb0..d0c7db986 100644 --- a/libs/langgraph/langgraph/pregel/loop.py +++ b/libs/langgraph/langgraph/pregel/loop.py @@ -650,19 +650,21 @@ class PregelLoop(LoopProtocol): # map command to writes if isinstance(self.input, Command): - if (resume := self.input.resume) is not None: - if isinstance(resume, dict) and all( - is_xxh3_128_hexdigest(k) for k in resume - ): - self.config[CONF][CONFIG_KEY_RESUME_MAP] = self.input.resume - if self.input.resume is not None and not self.checkpointer: + if resume_is_map := ( + (resume := self.input.resume) is not None + and isinstance(resume, dict) + and all(is_xxh3_128_hexdigest(k) for k in resume) + ): + self.config[CONF][CONFIG_KEY_RESUME_MAP] = self.input.resume + if resume is not None and not self.checkpointer: raise RuntimeError( "Cannot use Command(resume=...) without checkpointer" ) writes: defaultdict[str, list[tuple[str, Any]]] = defaultdict(list) # group writes by task ID - for tid, c, v in map_command(self.input): - writes[tid].append((c, v)) + for tid, c, v in map_command(cmd=self.input): + if not (c == RESUME and resume_is_map): + writes[tid].append((c, v)) if not writes: raise EmptyInputError("Received empty Command input") # save writes