Building Your First Crew
You've learned how to define agents and create tasks. Now it's time to assemble them into a crew — the orchestration layer that coordinates how agents work together. In this lesson, you'll build a complete working crew and learn about sequential vs hierarchical processes. For the full API, see the Crew docs.
Anatomy of a Crew
A crew brings agents and tasks together with a defined process:
| Attribute | Required | Purpose |
|---|---|---|
agents | Yes | List of agents in the crew |
tasks | Yes | List of tasks to execute |
process | No | Process.sequential (default) or Process.hierarchical |
verbose | No | Print agent reasoning to console |
memory | No | Enable crew-level memory |
max_rpm | No | Rate limit API calls per minute |
Your First Complete Crew
Let's build a content creation crew with two agents — a researcher and a writer:
from crewai import Agent, Task, Crew, Process
# Define agents
researcher = Agent(
role="Senior Research Analyst",
goal="Find comprehensive, accurate information on given topics",
backstory="You are a meticulous researcher who always verifies facts "
"across multiple sources. You organize findings into clear, "
"structured summaries."
)
writer = Agent(
role="Content Writer",
goal="Write engaging, well-structured articles based on research",
backstory="You are an experienced tech writer who turns complex research "
"into accessible, engaging content. You always include practical "
"examples and clear explanations."
)
# Define tasks
research_task = Task(
description="Research the current state of AI code assistants in 2025. "
"Cover: major products (GitHub Copilot, Cursor, etc.), "
"key features, pricing, and developer adoption rates.",
expected_output="A structured research summary covering at least 4 "
"AI code assistants with features, pricing, and adoption data.",
agent=researcher
)
writing_task = Task(
description="Write a 600-word blog post titled 'AI Code Assistants in 2025: "
"A Developer's Guide' based on the research provided. "
"Use a conversational tone. Include a comparison table.",
expected_output="A 600-word blog post in Markdown format with an "
"introduction, comparison table, and conclusion.",
agent=writer,
context=[research_task]
)
# Assemble the crew
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
process=Process.sequential,
verbose=True
)
# Run the crew
result = crew.kickoff()
print(result)
When you call crew.kickoff(), CrewAI executes the tasks in order: the researcher gathers information, then the writer uses that research to produce the blog post.
Sequential vs Hierarchical Process
CrewAI supports two process types that determine how tasks flow between agents.
Sequential Process
Tasks execute one after another in the order they're listed. The output of each task is available to subsequent tasks via context.
crew = Crew(
agents=[researcher, analyst, writer],
tasks=[research_task, analysis_task, writing_task],
process=Process.sequential
)
How it works:
research_task → analysis_task → writing_task
(researcher) (analyst) (writer)
Each task runs to completion before the next one starts. This is the default and most common process type.
Best for: Linear workflows where each step builds on the previous one.
Hierarchical Process
A manager agent is automatically created to coordinate the crew. The manager decides which agent handles which task and can reassign work as needed.
crew = Crew(
agents=[researcher, analyst, writer],
tasks=[research_task, analysis_task, writing_task],
process=Process.hierarchical,
manager_llm="gpt-4o" # LLM for the auto-created manager
)
How it works:
┌─── Manager Agent ───┐
│ (coordinates) │
├──────┼──────┼───────┤
▼ ▼ ▼
researcher analyst writer
The manager reads all tasks, assigns them to agents, reviews outputs, and can request revisions or reassign work.
Best for: Complex workflows where task assignment needs to be flexible, or when you want built-in quality control.
When to Choose Which
| Scenario | Process |
|---|---|
| Simple pipeline (research → write → edit) | Sequential |
| Tasks have clear dependencies | Sequential |
| Tasks could be done in any order | Hierarchical |
| You want automatic quality review | Hierarchical |
| Debugging and learning | Sequential (easier to follow) |
Running the Crew
The kickoff() method starts execution and returns the final result:
result = crew.kickoff()
# The result contains the output of the last task
print(result.raw) # Raw text output
print(result.json_dict) # If output was JSON
print(result.pydantic) # If using a Pydantic output model
Passing Runtime Inputs
You can pass dynamic values to your crew at runtime using inputs:
crew = Crew(
agents=[researcher, writer],
tasks=[
Task(
description="Research {topic} for {audience}",
expected_output="Research summary on {topic}",
agent=researcher
),
Task(
description="Write a blog post about {topic} for {audience}",
expected_output="Blog post about {topic}",
agent=writer,
context=[research_task]
)
],
process=Process.sequential
)
# Use placeholders in task descriptions, fill them at runtime
result = crew.kickoff(inputs={
"topic": "quantum computing",
"audience": "software developers"
})
This makes your crews reusable — define the workflow once, run it with different inputs.
Verbose Mode and Debugging
Set verbose=True to watch agents think in real time:
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
verbose=True # See all agent reasoning
)
The verbose output shows:
- Which agent is working on which task
- The agent's thought process (chain of thought)
- Any tool calls the agent makes
- The final output of each task
This is invaluable when debugging or tuning your crew's behavior.
Complete Working Example
Here's a fully self-contained crew you can run:
from crewai import Agent, Task, Crew, Process
# Agents
researcher = Agent(
role="Tech Researcher",
goal="Find accurate technical information",
backstory="Senior researcher specializing in software development tools."
)
writer = Agent(
role="Technical Writer",
goal="Write clear, practical developer content",
backstory="Developer advocate who writes tutorials and guides."
)
reviewer = Agent(
role="Technical Editor",
goal="Ensure content is accurate, clear, and well-structured",
backstory="Editor with deep technical knowledge. You catch errors, "
"improve clarity, and ensure a consistent tone."
)
# Tasks
research = Task(
description="Research Python's latest features in version 3.13. "
"Focus on performance improvements and new syntax.",
expected_output="A summary of 4-5 key features with code examples.",
agent=researcher
)
draft = Task(
description="Write a tutorial on Python 3.13's new features. "
"800 words, include code examples for each feature.",
expected_output="An 800-word tutorial in Markdown format.",
agent=writer,
context=[research]
)
review = Task(
description="Review and improve the tutorial. Fix any technical errors, "
"improve clarity, and ensure code examples are correct.",
expected_output="A polished, publication-ready tutorial.",
agent=reviewer,
context=[draft]
)
# Crew
crew = Crew(
agents=[researcher, writer, reviewer],
tasks=[research, draft, review],
process=Process.sequential,
verbose=True
)
result = crew.kickoff()
print(result)
This three-agent pipeline mirrors a real editorial workflow: research → write → review.
Key Takeaways
- A Crew combines agents and tasks with a defined process
- Sequential process runs tasks in order — simple, predictable, easy to debug
- Hierarchical process uses a manager agent to coordinate work — more flexible but more complex
- Use
kickoff()to run the crew and get results - Inputs let you parameterize task descriptions for reusable crews
- Verbose mode shows agent reasoning, which is essential for debugging
- Start with sequential process and only switch to hierarchical when you need flexible task assignment

