From 4a28f199221cee6aa8300a0c1fc8a05b4cea988a Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Mon, 29 Apr 2024 10:44:45 -0700 Subject: [PATCH] Remove labels if redundant --- langgraph/graph/graph.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/langgraph/graph/graph.py b/langgraph/graph/graph.py index 7580eb797..df8c59639 100644 --- a/langgraph/graph/graph.py +++ b/langgraph/graph/graph.py @@ -450,13 +450,21 @@ class CompiledGraph(Pregel): ) graph.add_edge(start_nodes[start], cond) for label, end in ends.items(): - graph.add_edge(cond, end_nodes[end], label, conditional=True) + graph.add_edge( + cond, + end_nodes[end], + label if label != end else None, + conditional=True, + ) if branch.then is not None: graph.add_edge(start_nodes[end], end_nodes[branch.then]) else: for label, end in ends.items(): graph.add_edge( - start_nodes[start], end_nodes[end], label, conditional=True + start_nodes[start], + end_nodes[end], + label if label != end else None, + conditional=True, ) if branch.then is not None: graph.add_edge(start_nodes[end], end_nodes[branch.then])