From 2458f2d2e0a2edcebd917e4c4c09480e44cb2b02 Mon Sep 17 00:00:00 2001 From: blafab-hg Date: Tue, 18 Mar 2025 11:19:09 +0100 Subject: [PATCH] libs: pregel: find_subgraph_pregel: Do not search via introspection When searching for subgraphs do not attempt to search function non locals for RunnableCallables as this captures unwanted reference to surrounding variables. --- libs/langgraph/langgraph/pregel/utils.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/utils.py b/libs/langgraph/langgraph/pregel/utils.py index f484664a0..7aa0a6f8f 100644 --- a/libs/langgraph/langgraph/pregel/utils.py +++ b/libs/langgraph/langgraph/pregel/utils.py @@ -1,7 +1,6 @@ from typing import Optional from langchain_core.runnables import RunnableLambda, RunnableSequence -from langchain_core.runnables.utils import get_function_nonlocals from langgraph.checkpoint.base import ChannelVersions from langgraph.pregel.protocol import PregelProtocol @@ -42,16 +41,5 @@ def find_subgraph_pregel(candidate: Runnable) -> Optional[PregelProtocol]: candidates.extend(c.steps) elif isinstance(c, RunnableLambda): candidates.extend(c.deps) - elif isinstance(c, RunnableCallable): - if c.func is not None: - candidates.extend( - nl.__self__ if hasattr(nl, "__self__") else nl - for nl in get_function_nonlocals(c.func) - ) - elif c.afunc is not None: - candidates.extend( - nl.__self__ if hasattr(nl, "__self__") else nl - for nl in get_function_nonlocals(c.afunc) - ) return None