From ac1407b23c50a899db4a7de78d5192b43c36febd Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Wed, 22 Jan 2025 09:44:52 -0800 Subject: [PATCH 1/3] Remove write to RETURN channel for entrypoint func --- libs/langgraph/langgraph/pregel/call.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/call.py b/libs/langgraph/langgraph/pregel/call.py index 9a74eb0c3..063df89a8 100644 --- a/libs/langgraph/langgraph/pregel/call.py +++ b/libs/langgraph/langgraph/pregel/call.py @@ -158,14 +158,9 @@ def get_runnable_for_entrypoint(func: Callable[..., Any]) -> RunnableSeq: trace=False, recurse=False, ) - seq = RunnableSeq( - run, - ChannelWrite([ChannelWriteEntry(RETURN)], tags=[TAG_HIDDEN]), - name=func.__name__, - ) if not _lookup_module_and_qualname(func): - return seq - return CACHE.setdefault(key, seq) + return run + return CACHE.setdefault(key, run) def get_runnable_for_task(func: Callable[..., Any]) -> RunnableSeq: From 3915b44180a7be1b855e7722b4db1f3d64284fc4 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Wed, 22 Jan 2025 11:32:09 -0800 Subject: [PATCH 2/3] Format --- libs/langgraph/tests/test_large_cases.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/langgraph/tests/test_large_cases.py b/libs/langgraph/tests/test_large_cases.py index 6980b7b68..f562720b8 100644 --- a/libs/langgraph/tests/test_large_cases.py +++ b/libs/langgraph/tests/test_large_cases.py @@ -2829,9 +2829,9 @@ def test_state_graph_packets( # Define decision-making logic def should_continue(data: AgentState) -> str: assert isinstance(data["session"], httpx.Client) - assert data["something_extra"] == "hi there", ( - "nodes can pass extra data to their cond edges, which isn't saved in state" - ) + assert ( + data["something_extra"] == "hi there" + ), "nodes can pass extra data to their cond edges, which isn't saved in state" # Logic to decide whether to continue in the loop or exit if tool_calls := data["messages"][-1].tool_calls: return [Send("tools", tool_call) for tool_call in tool_calls] From b704cf30cc04c5d59696307a84a8774e8665a7ee Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Wed, 22 Jan 2025 11:34:30 -0800 Subject: [PATCH 3/3] Lint --- libs/langgraph/langgraph/pregel/call.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/langgraph/langgraph/pregel/call.py b/libs/langgraph/langgraph/pregel/call.py index 063df89a8..a4bba63fe 100644 --- a/libs/langgraph/langgraph/pregel/call.py +++ b/libs/langgraph/langgraph/pregel/call.py @@ -8,6 +8,7 @@ import sys import types from typing import Any, Callable, Optional, TypeVar, Union +from langchain_core.runnables import Runnable from typing_extensions import ParamSpec from langgraph.constants import CONF, CONFIG_KEY_CALL, RETURN, TAG_HIDDEN @@ -199,7 +200,7 @@ def get_runnable_for_task(func: Callable[..., Any]) -> RunnableSeq: return CACHE.setdefault(key, seq) -CACHE: dict[tuple[Callable[..., Any], bool], RunnableSeq] = {} +CACHE: dict[tuple[Callable[..., Any], bool], Runnable] = {} P = ParamSpec("P")