CrewAI Multi-Agents

Course Content

CrewAI Multi-Agents

9 sections · 53 lessons

What is a Task in CrewAI, and how does it differ from an agent?


What you need to know

Agent vs task in one table

AgentTask
Answerswho does it, with what toolswhat must be produced, and when it is done
Lifetimethe whole run, reused across tasksone execution
Key fieldsrole, goal, backstory, tools, llmdescription, expected_output, agent, context, output_pydantic, guardrails
Outputnone of its owna TaskOutput

A task in code

Python
from pydantic import BaseModelfrom crewai import Taskclass LeadScore(BaseModel):    company: str    score: int          # 0-100    reasons: list[str]score_task = Task(    description="Score {company} against our ideal customer profile: "                "50-500 employees, India or SEA, uses a modern HR stack.",    expected_output="A score from 0 to 100 and one reason per criterion.",    agent=fit_scorer,    context=[research_task],    output_pydantic=LeadScore,)

Other useful fields: tools (overrides the agent's tools for this task), async_execution (run in parallel), output_file (save the result), human_input (ask a person to review before finishing), markdown (ask for Markdown formatting), and guardrails.

Where the output goes

After crew.kickoff(), result.tasks_output lists every TaskOutput in order. result.raw and result.pydantic are the last task's output. Your code can read score_task.output.pydantic.score directly.

Why the split matters

  • Reuse. One researcher agent can serve a company-research task and a competitor-research task.
  • Testing. You can check a task's output against its expected_output without caring how the agent reached it.
  • Retries. A guardrail failure re-runs one task, not the whole crew.

A real-life example

A B2B SaaS lead-qualification crew has three agents and four tasks:

TaskAgentOutput
research_taskAccount Researchercompany facts with URLs
tech_stack_taskAccount Researchertools the company uses
score_taskFit ScorerLeadScore
email_taskOutreach Writera first email draft

The researcher agent runs two tasks with different deliverables. The CRM integration reads score_task.output.pydantic.score; leads above 70 go to a sales rep with the draft email attached. When a scoring rule changes, only score_task's description changes — no agent is touched.

Follow-up questions to expect

  • "Can a task run without a crew?" — Tasks normally run inside a crew; for a single job without a crew, call agent.kickoff(...) directly.
  • "Can a task have no agent?" — Only in a hierarchical crew, where the manager decides who does it.
  • "Where do I read one task's output after the run?" — result.tasks_output[i], or the task object's .output.