Module 7 · Lesson 4 · 15 min read
CrewAI: agent teams, roles and tasks
CrewAI: Crews, Roles and Tasks
Introduction
CrewAI borrows the language of work teams: agents with roles and goals, tasks with expected outputs, and a process that sets the order of execution. In this lesson we build a small team that writes a university club newsletter, and simulate passing context between tasks in plain Python.
Learning objectives
- Define a CrewAI agent with the fields role, goal and backstory
- Write a task with a description and an expected output and assign it to an agent
- Distinguish between the sequential process and the hierarchical process
- Judge the cost of adding agents and tasks to the team
The idea: a team, not a single loop
CrewAI builds its system on a metaphor from the human workplace: a team (Crew) made up of agents, each with a role, carrying out specific tasks according to a process that sets the order of work. The latest release on PyPI is 1.15.41, and it supports Python from 3.10 up to but not including 3.14 (according to the official documentation, reviewed 18 November 2026).
This metaphor makes the design easy to explain to non-programmers: "the researcher gathers, the writer drafts, the reviewer checks". But it also forces you to think clearly about each agent's responsibility and exactly what it hands over.
The three basic building blocks
An agent in CrewAI requires three descriptive fields:
role: the role, such as "university regulations researcher".goal: the goal this agent pursues.backstory: a background that gives the agent context and a working style.
A task needs a description (what must be done) and an expected_output (the shape of the expected output), and is usually assigned to an agent through agent. The framework documents additional fields such as tools, context (earlier tasks whose results are passed on) and guardrail for validating the output.
The team (Crew) brings together the agents and tasks and sets the process:
Process.sequential: tasks run in order, and each task's result becomes context for the next.Process.hierarchical: a manager takes charge of distributing tasks to the agents and reviewing their results.
Execution then starts with crew.kickoff(). Alongside teams, CrewAI offers Flows for building event-driven workflows that you control more precisely.
Practical example: a weekly newsletter for the programming club
The scenario: the university programming club wants a short weekly newsletter. We need a researcher who summarises the club's news from members' notes, and a writer who turns the summary into a friendly newsletter.
# crewai 1.15.41 — reviewed 18 November 2026 (Python >=3.10,<3.14)
# Requires: pip install crewai and an API key for the model provider the agents use
from crewai import Agent, Task, Crew, Process
researcher = Agent(
role="Club news researcher",
goal="Extract the three most important events from the members' notes",
backstory="A long-standing club member who knows what matters to new students.",
)
writer = Agent(
role="Newsletter editor",
goal="Write a short, clear newsletter in correct language",
backstory="A media student who loves simplifying technical news.",
)
summarize = Task(
description="Summarize the following notes from the week in three points: {notes}",
expected_output="A list of three points, each point a single sentence",
agent=researcher,
)
draft = Task(
description="Turn the points into a one-paragraph newsletter with a catchy title",
expected_output="A title and a paragraph of no more than 120 words",
agent=writer,
)
crew = Crew(agents=[researcher, writer], tasks=[summarize, draft],
process=Process.sequential)
result = crew.kickoff(inputs={"notes": "Git workshop on Sunday, an algorithms contest, a new member on the board"})
print(result)In the sequential process, the result of the summarising task passes to the writing task automatically. The {notes} value in the description is filled from inputs at call time.
What actually happens: a simulation without libraries
To understand "passing context" in the sequential process, here is a standard Python simulation that runs without any library, where each "agent" is a simple function:
# Educational simulation of the sequential process - standard Python
def researcher(notes):
return [n.strip() for n in notes.split(",")][:3]
def writer(points):
return "This week's club news: " + "; ".join(points) + "."
tasks = [researcher, writer]
context = "Git workshop on Sunday, an algorithms contest, a new member on the board"
for task in tasks: # each task receives the previous one's output
context = task(context)
print(context)Strengths and limits
- Strengths: fast prototyping, clear roles, and a CLI that generates a ready project skeleton:
uv tool install crewaithencrewai create crew <name>. - Limits: descriptive fields such as
backstoryaffect behaviour in ways that are hard to predict, so test the results and do not assume that "the reviewer role" means the review is accurate. And every extra agent means more model calls and higher cost.
Summary
CrewAI builds on a team of agents, each with a role, goal and backstory, and tasks with a description, expected_output and agent. The Crew gathers the agents and tasks and executes them according to Process.sequential or Process.hierarchical through kickoff. In the sequential process the result of each task becomes context for the next. The framework also offers Flows and a command-line tool for creating projects.
Terms
| Term | English | Definition |
|---|---|---|
| Crew | Crew | A group of agents and tasks executed according to a specific process |
| Role | Role | A description of the agent's function within the team |
| Expected output | expected_output | A description of the shape of the task's result and its completion criteria |
| Sequential process | Sequential Process | Executing tasks in order, passing the results along |
| Hierarchical process | Hierarchical Process | A manager that distributes tasks and reviews the results |
Review questions
- What are the three fields required to define an agent in CrewAI?
- How does a task's result pass to the next task in the sequential process?
- When does the benefit of the hierarchical process justify its extra cost?
- Why is it better for expected_output to be checkable?
References
- CrewAI Agents docs.crewai.com Reviewed on 2026-11-18
- CrewAI Tasks docs.crewai.com Reviewed on 2026-11-18
- crewai on PyPI pypi.org Reviewed on 2026-11-18
