What Is CrewAI? β Definition and How It Works
Learn what CrewAI is, how agents, tasks, and crews compose, how sequential and hierarchical processes differ, and when a crew beats one agent.
CrewAI is a Python framework for multi-agent systems. Its organising metaphor is a team: agents with roles, tasks with expected outputs, and a process describing how work flows between them.
1. The Core Concepts
| Concept | What it defines |
|---|---|
| Agent | A role, a goal, a backstory, and the tools it may use |
| Task | A description, an expected output, and the agent responsible |
| Crew | The agents, the tasks, and the process joining them |
| Process | Sequential or hierarchical execution |
Example Shape
researcher = Agent(role="Researcher", goal="Find current sources",
tools=[search_tool], verbose=True)
task = Task(description="Summarise this week's changes in X",
expected_output="Five bullet points with links", agent=researcher)
crew = Crew(agents=[researcher, writer], tasks=[task, write_task])
result = crew.kickoff()
2. Sequential Versus Hierarchical
Sequential runs tasks in order, each receiving the previous output. Predictable, easy to trace, and adequate for most pipelines.
Hierarchical introduces a manager agent that delegates tasks and reviews results. More flexible, less predictable, and harder to debug because the plan itself is generated.
Start sequential. Move to hierarchical only when the ordering genuinely cannot be decided in advance.
3. Why Roles Help
Giving an agent a narrow role and a small tool set improves reliability for the same reason narrow prompts do: fewer choices, less opportunity for wrong selection.
The gain comes from scope, not from the persona. A "meticulous researcher" backstory matters less than restricting that agent to a search tool and one clear task.
4. Expected Output Is Load-Bearing
Each task declares what its output should look like. That declaration does real work: it constrains generation, gives the next task a predictable input, and provides something to validate against.
Vague expected outputs are the most common cause of crews that run successfully and produce something unusable.
5. When a Crew Beats a Single Agent
- Sub-tasks need genuinely different tools.
- Separation of concerns aids review β one agent gathers, another writes, a third checks.
- Different steps warrant different models for cost or capability reasons.
- The workflow mirrors a real division of labour.
6. When a Single Agent Is Better
- The task is one loop with one tool set.
- Latency matters, since each agent adds model calls.
- Debugging matters, since multi-agent traces are harder to follow.
- The division is cosmetic β splitting a task that has no natural seam adds coordination without benefit.
7. Practical Notes
- Cost multiplies. Each agent's calls add up, and hierarchical planning adds more.
- Trace everything. Verbose output is essential; a failure is otherwise unexplainable.
- Cap iterations. Agents can loop, and a crew can loop across agents.
- Validate outputs. Structured output plus schema checks between tasks prevent one weak step from poisoning the chain.
8. Summary
CrewAI models multi-agent work as roles, tasks, and a process, with sequential or hierarchical execution. Its strength is expressing a division of labour clearly.
Use a crew when sub-tasks differ in tools or review needs, keep the process sequential until it demonstrably cannot be, and spend the effort on precise expected outputs β that field determines whether the result is usable.