diff --git a/libs/langgraph/langgraph/graph/graph.py b/libs/langgraph/langgraph/graph/graph.py index 12f9cf943..2a1e8c8ad 100644 --- a/libs/langgraph/langgraph/graph/graph.py +++ b/libs/langgraph/langgraph/graph/graph.py @@ -194,7 +194,7 @@ class Graph: "Node name must be provided if action is not a function" ) if action is None: - raise RuntimeError + raise RuntimeError(f"Expected a function or Runnable action in add_node. Received None.") if node in self.nodes: raise ValueError(f"Node `{node}` already present.") if node == END or node == START: diff --git a/libs/langgraph/langgraph/graph/state.py b/libs/langgraph/langgraph/graph/state.py index ace4d2553..b759ff4ca 100644 --- a/libs/langgraph/langgraph/graph/state.py +++ b/libs/langgraph/langgraph/graph/state.py @@ -320,7 +320,7 @@ class StateGraph(Graph): ) if not isinstance(node, str): action = node - node = getattr(action, "name", getattr(action, "__name__")) + node = getattr(action, "name", getattr(action, "__name__", None)) if node is None: raise ValueError( "Node name must be provided if action is not a function"