From 53a1e7c9de2ae08124d6defb5424d203c9e501f4 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Mon, 19 May 2025 11:35:51 -0700 Subject: [PATCH] Print output for cached @task functions --- libs/langgraph/langgraph/pregel/loop.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/loop.py b/libs/langgraph/langgraph/pregel/loop.py index 2f0cae569..96691cbdb 100644 --- a/libs/langgraph/langgraph/pregel/loop.py +++ b/libs/langgraph/langgraph/pregel/loop.py @@ -1083,7 +1083,8 @@ class SyncPregelLoop(PregelLoop, AbstractContextManager): self, task: PregelExecutableTask, write_idx: int, call: Optional[Call] = None ) -> Optional[PregelExecutableTask]: if pushed := super().accept_push(task, write_idx, call): - self.match_cached_writes() + for task in self.match_cached_writes(): + self.output_writes(task.id, task.writes, cached=True) return pushed def put_writes(self, task_id: str, writes: WritesT) -> None: @@ -1279,7 +1280,8 @@ class AsyncPregelLoop(PregelLoop, AbstractAsyncContextManager): self, task: PregelExecutableTask, write_idx: int, call: Optional[Call] = None ) -> Optional[PregelExecutableTask]: if pushed := super().accept_push(task, write_idx, call): - await self.amatch_cached_writes() + for task in await self.amatch_cached_writes(): + self.output_writes(task.id, task.writes, cached=True) return pushed def put_writes(self, task_id: str, writes: WritesT) -> None: