diff --git a/libs/langgraph/langgraph/pregel/loop.py b/libs/langgraph/langgraph/pregel/loop.py index 4cfd550fc..2a9b29599 100644 --- a/libs/langgraph/langgraph/pregel/loop.py +++ b/libs/langgraph/langgraph/pregel/loop.py @@ -395,10 +395,6 @@ class PregelLoop(LoopProtocol): self.tasks[tid] = task._replace(scheduled=True) else: task.writes.append((k, v)) - # print output for any tasks we applied previous writes to - for task in self.tasks.values(): - if task.writes: - self._output_writes(task.id, task.writes, cached=True) elif not self.skip_done_tasks: # "not skip_done_tasks" only applies to first tick after resuming self.skip_done_tasks = True @@ -424,6 +420,11 @@ class PregelLoop(LoopProtocol): if self.debug: print_step_tasks(self.step, list(self.tasks.values())) + # print output for any tasks we applied previous writes to + for task in self.tasks.values(): + if task.writes: + self._output_writes(task.id, task.writes, cached=True) + return True # private diff --git a/libs/langgraph/tests/test_pregel_async.py b/libs/langgraph/tests/test_pregel_async.py index 23ba080f9..7f9c533d3 100644 --- a/libs/langgraph/tests/test_pregel_async.py +++ b/libs/langgraph/tests/test_pregel_async.py @@ -8660,14 +8660,14 @@ async def test_stream_subgraphs_during_execution(checkpointer_name: str) -> None ), (FloatBetween(0.2, 0.3), ((), {"outer_1": {"my_key": " and parallel"}})), ( - FloatBetween(0.5, 0.6), + FloatBetween(0.5, 0.7), ( (AnyStr("inner:"),), {"inner_2": {"my_key": " and there", "my_other_key": "got here"}}, ), ), - (FloatBetween(0.5, 0.6), ((), {"inner": {"my_key": "got here and there"}})), - (FloatBetween(0.5, 0.6), ((), {"outer_2": {"my_key": " and back again"}})), + (FloatBetween(0.5, 0.7), ((), {"inner": {"my_key": "got here and there"}})), + (FloatBetween(0.5, 0.7), ((), {"outer_2": {"my_key": " and back again"}})), ]