From e00284b386964e15e24c76fbfa7c98c182854552 Mon Sep 17 00:00:00 2001 From: Abhishek Shirgaokar Date: Tue, 7 Jan 2025 20:34:50 +0530 Subject: [PATCH] Clarifying the docstring for the add_edge function (#2782) Revised docstring for StateGraph's add_edge method to clarify recurring confusion #2775 #1462 --------- Co-authored-by: ashirgaokar Co-authored-by: vbarda --- libs/langgraph/langgraph/graph/state.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/langgraph/langgraph/graph/state.py b/libs/langgraph/langgraph/graph/state.py index e412db2d5..d5e4a5480 100644 --- a/libs/langgraph/langgraph/graph/state.py +++ b/libs/langgraph/langgraph/graph/state.py @@ -398,9 +398,11 @@ def add_node( return self def add_edge(self, start_key: Union[str, list[str]], end_key: str) -> Self: - """Adds a directed edge from the start node to the end node. + """Adds a directed edge from the start node (or list of start nodes) to the end node. - If the graph transitions to the start_key node, it will always transition to the end_key node next. + When a single start node is provided, the graph will wait for that node to complete + before executing the end node. When multiple start nodes are provided, + the graph will wait for ALL of the start nodes to complete before executing the end node. Args: start_key (Union[str, list[str]]): The key(s) of the start node(s) of the edge.