CrewAI Multi-Agents

Course Content

CrewAI Multi-Agents

9 sections · 53 lessons

What are the core components of CrewAI (Agent, Task, Crew, Process)?


What you need to know

The four core pieces

  • Agent — who does the work. Key fields: role, goal, backstory, tools, llm, allow_delegation (default False), max_iter (default 25).
  • Task — what must be done. Key fields: description, expected_output, agent, context, output_pydantic, guardrails, async_execution, output_file.
  • Crew — the runtime. Key fields: agents, tasks, process, memory, cache, verbose. Runs with kickoff(inputs={...}) and returns a CrewOutput.
  • Process — Process.sequential (the default) or Process.hierarchical, which needs a manager_llm or manager_agent.

The supporting pieces

PiecePurpose
Toolsfunctions the agent can call (BaseTool, the @tool decorator, crewai_tools, MCP servers)
Memorya unified Memory store the crew can write to and recall from across runs
Knowledgereference documents (PDF, text, CSV) that agents search during tasks
Guardrailschecks on a task's output; on failure the agent retries with feedback
Flowsevent-driven orchestration of crews, agents and plain code

How they fit together in a project

Most teams keep agents and tasks in YAML and wire them in Python with the @CrewBase decorator. This is the layout crewai create crew my_crew --classic generates. (Since CrewAI 1.15, crewai create crew without the flag generates a JSON-based layout with crew.jsonc and an agents/ folder; the ideas are the same.)

YAML
# src/lead_qualifier/config/agents.yamlresearcher:  role: >    B2B Account Researcher  goal: >    Build a factual profile of {company}  backstory: >    You only report facts you can link to a source.
Python
# src/lead_qualifier/crew.pyfrom crewai import Agent, Crew, Process, Taskfrom crewai.project import CrewBase, agent, crew, task@CrewBaseclass LeadQualifier:    agents_config = "config/agents.yaml"    tasks_config = "config/tasks.yaml"    @agent    def researcher(self) -> Agent:        return Agent(config=self.agents_config["researcher"])    @task    def research_task(self) -> Task:        return Task(config=self.tasks_config["research_task"])    @crew    def crew(self) -> Crew:        return Crew(agents=self.agents, tasks=self.tasks,                    process=Process.sequential)

The @agent and @task decorators collect methods into self.agents and self.tasks, in the order they are declared. The task YAML names its agent by the key (agent: researcher). You run it with crewai run or LeadQualifier().crew().kickoff(inputs={"company": "Acme"}).

A real-life example

A Bengaluru B2B SaaS company that sells HR software receives about 400 demo requests a week. Sales reps waste hours on students and tiny firms. They build a lead-qualification crew:

  • Agents: an account researcher (web search tool), a fit scorer (no tools, knows the ideal-customer rules), and an outreach writer.
  • Tasks: research_task (company size, industry, funding, with URLs), score_task (a score from 0 to 100 with reasons, as output_pydantic=LeadScore), email_task (a first email for leads above 70).
  • Crew: sequential, because the order never changes.

The fit scorer's typed output is what the CRM integration reads, so nobody parses free text. Each piece has one clear job, which is exactly the mental model an interviewer wants to hear.

Follow-up questions to expect

  • "Where does the system prompt come from?" — CrewAI builds it from the agent's role, goal and backstory, and adds the task's description, expected_output and any context for each task.
  • "Does every task need an agent?" — In a sequential crew, yes. In a hierarchical crew a task can leave agent empty, and the manager chooses who does it.
  • "What does kickoff return?" — A CrewOutput with .raw (final text), .pydantic or .json_dict (typed final output), .tasks_output (each task's output) and .token_usage.