From d1a8b53aecb64e00a37427792cac779886e2b1e4 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Thu, 14 Nov 2024 17:52:17 -0800 Subject: [PATCH] Comments --- libs/langgraph/langgraph/pregel/runner.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/runner.py b/libs/langgraph/langgraph/pregel/runner.py index 1311525da..b34978ad9 100644 --- a/libs/langgraph/langgraph/pregel/runner.py +++ b/libs/langgraph/langgraph/pregel/runner.py @@ -86,8 +86,6 @@ def writer( if next_task := self.schedule_task( task, idx, calls[idx - prev_length] if calls else None ): - # if the parent task was retried, - # the next task might already be running if fut := next( ( f @@ -96,8 +94,12 @@ def writer( ), None, ): + # if the parent task was retried, + # the next task might already be running rtn[idx - prev_length] = fut elif next_task.writes: + # if it already ran, return the result + # TODO we could also set the result for non-RETURN writes fut = concurrent.futures.Future() if val := next(v for c, v in next_task.writes if c == RETURN): fut.set_result(val)