From df7ee682109bb28592845a16fee7356e8e9f3892 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 29 Nov 2024 17:30:02 -0300 Subject: [PATCH] fix: update sort logic to handle cycles when running component (#4957) fix: handle cycle scenario by adjusting stop component logic in graph sorting Co-authored-by: anovazzi1 --- src/backend/base/langflow/graph/graph/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index 8a6a8910d..62cb443d6 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -2009,6 +2009,11 @@ class Graph: ) -> list[str]: """Sorts the vertices in the graph.""" self.mark_all_vertices("ACTIVE") + if stop_component_id in self.cycle_vertices: + # Make the stop into a start because we are in a cycle and + # we cannot know where is the input or output + start_component_id = stop_component_id + stop_component_id = None if stop_component_id is not None: self.stop_vertex = stop_component_id vertices = self.__filter_vertices(stop_component_id)