From 5381ee1d9099532deeb1eea2c4984935ad4ac78e Mon Sep 17 00:00:00 2001 From: William Bilibio Date: Wed, 8 Jan 2025 14:28:59 -0300 Subject: [PATCH] Fix: Fixed agent not found in SequentialCrewComponent. (#5449) * fix: agents not found in SequentialCrewComponent #4959 * translate texts * [autofix.ci] apply automated fixes * Update sequential_crew.py Removed Agent import --------- Co-authored-by: William Bilibio Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../langflow/components/crewai/sequential_crew.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/backend/base/langflow/components/crewai/sequential_crew.py b/src/backend/base/langflow/components/crewai/sequential_crew.py index 99d739ad2..f6d09f9dc 100644 --- a/src/backend/base/langflow/components/crewai/sequential_crew.py +++ b/src/backend/base/langflow/components/crewai/sequential_crew.py @@ -16,11 +16,17 @@ class SequentialCrewComponent(BaseCrewComponent): HandleInput(name="tasks", display_name="Tasks", input_types=["SequentialTask"], is_list=True), ] - def get_tasks_and_agents(self, agents_list=None) -> tuple[list[Task], list[Agent]]: - if not agents_list: - agents_list = [task.agent for task in self.tasks] or [] + @property + def agents(self: "SequentialCrewComponent") -> list[Agent]: + # Derive agents directly from linked tasks + return [task.agent for task in self.tasks if hasattr(task, "agent")] + + def get_tasks_and_agents(self, agents_list=None) -> tuple[list[Task], list[Agent]]: + # Use the agents property to derive agents + if not agents_list: + existing_agents = self.agents + agents_list = existing_agents + (agents_list or []) - # Use the superclass implementation, passing the customized agents_list return super().get_tasks_and_agents(agents_list=agents_list) def build_crew(self) -> Message: