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
| Agent | Task | |
|---|---|---|
| Answers | who does it, with what tools | what must be produced, and when it is done |
| Lifetime | the whole run, reused across tasks | one execution |
| Key fields | role, goal, backstory, tools, llm | description, expected_output, agent, context, output_pydantic, guardrails |
| Output | none of its own | a TaskOutput |
A task in code
1from pydantic import BaseModel2from crewai import Task34class LeadScore(BaseModel):5 company: str6 score: int # 0-1007 reasons: list[str]89score_task = Task(10 description="Score {company} against our ideal customer profile: "11 "50-500 employees, India or SEA, uses a modern HR stack.",12 expected_output="A score from 0 to 100 and one reason per criterion.",13 agent=fit_scorer,14 context=[research_task],15 output_pydantic=LeadScore,16)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_outputwithout 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:
| Task | Agent | Output |
|---|---|---|
research_task | Account Researcher | company facts with URLs |
tech_stack_task | Account Researcher | tools the company uses |
score_task | Fit Scorer | LeadScore |
email_task | Outreach Writer | a 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.