Skip to content

Instantly share code, notes, and snippets.

@inchoate
Created July 10, 2024 20:28
Show Gist options
  • Save inchoate/2a7348a31e4c00596eae32926e46dd3b to your computer and use it in GitHub Desktop.
Save inchoate/2a7348a31e4c00596eae32926e46dd3b to your computer and use it in GitHub Desktop.

If you've instantiated your CrewAI Crew as a class, using the convenient decorators (@agent, @task, for example) as shown in the documentation you probably ended up with something like this:

@crew
def crew(self) -> Crew:
    """Creates the crew"""
    return Crew(
        agents=self.agents,
        tasks=self.tasks,
        process=Process.sequential,
        full_output=True,
        verbose=2,
    )

The docs seem to indicate that you can just swap out Process.hierarchical for Process.sequential and be fine. But you cannot. You need to do the following:

  • Add the manager_agent as an instance of the manager agent.
  • Define the agents as the list of non-manager agents, here I just did my researcher and reporting_analyst
  • Make sure you instantiate them self.researcher() not self.researcher. Do the same for the manager_agent.
@crew
def crew(self) -> Crew:
    """Creates the crew"""
    return Crew(
        agents=[self.researcher(), self.reporting_analyst()],
        tasks=self.tasks,
        manager_agent=self.coordinator(),
        process=Process.hierarchical,
        full_output=True,
        verbose=2,
    )
@albertpinto
Copy link

This is useful information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment