From c183f4f16a7f3f9568f4a8d1787c5ae7fadc6b5d Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Tue, 27 Aug 2024 11:22:23 -0700 Subject: [PATCH] Emit output for skipped tasks --- libs/langgraph/langgraph/pregel/loop.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/langgraph/langgraph/pregel/loop.py b/libs/langgraph/langgraph/pregel/loop.py index 87551b83f..f03a26e31 100644 --- a/libs/langgraph/langgraph/pregel/loop.py +++ b/libs/langgraph/langgraph/pregel/loop.py @@ -205,6 +205,9 @@ class PregelLoop: writes, task_id, ) + self._output_writes(task_id, writes) + + def _output_writes(self, task_id: str, writes: Sequence[tuple[str, Any]]) -> None: if task := next((t for t in self.tasks if t.id == task_id), None): self.stream.extend( (self.config["configurable"].get("checkpoint_ns", ""), "updates", v) @@ -320,6 +323,10 @@ class PregelLoop: continue if task := next((t for t in self.tasks if t.id == tid), None): task.writes.append((k, v)) + # print output for any tasks we applied previous writes to + for task in self.tasks: + if task.writes: + self._output_writes(task.id, task.writes) # if all tasks have finished, re-tick if all(task.writes for task in self.tasks):