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 <bilibio@vaidebolsa.com.br>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
William Bilibio 2025-01-08 14:28:59 -03:00 committed by GitHub
commit 5381ee1d90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: