CrewAI
A high-level, role-based multi-agent framework where you define agents with backstories and goals, assign them tasks, and orchestrate execution through sequential or hierarchical processes -- optimized for getting multi-agent systems running fast with minimal boilerplate.
A high-level, role-based multi-agent framework where you define agents with backstories and goals, assign them tasks, and orchestrate execution through sequential or hierarchical processes – optimized for getting multi-agent systems running fast with minimal boilerplate.
What Is CrewAI?
CrewAI takes an opinionated, role-playing approach to multi-agent systems. Instead of defining graph nodes and edges, you describe agents as personas (role, goal, backstory) and tasks as work items, then let the framework handle orchestration.
Key Philosophy:
- Agents as team members: Each agent has a role, goal, and backstory that shapes its behavior
- Tasks as deliverables: Clear descriptions of what needs to be done, with expected output
- Processes as management styles: Sequential (waterfall), hierarchical (manager delegates), or consensual
- Minimal code to multi-agent: A working crew can be defined in under 30 lines
Status:
- Open-source (MIT), active development
- CrewAI Enterprise available for production deployments
- Strong community, 60k+ GitHub stars
- Python-only (no TypeScript SDK)
Core Concepts
Agents
An agent is an autonomous unit with a defined persona. The backstory and goal shape how the LLM behaves when acting as this agent.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from crewai import Agent
researcher = Agent(
role="Senior Market Research Analyst",
goal="Uncover emerging trends in enterprise AI adoption in European retail",
backstory="""You are a seasoned analyst with 15 years of experience in
technology market research. You specialize in enterprise software adoption
patterns in European markets. You are methodical and data-driven.""",
tools=[search_tool, web_scraper],
llm="anthropic/claude-sonnet-4-20250514",
verbose=True,
memory=True,
max_iter=5, # max reasoning iterations per task
allow_delegation=True # can delegate subtasks to other agents
)
writer = Agent(
role="Technical Content Strategist",
goal="Transform research findings into actionable executive briefings",
backstory="""You write for C-level executives at large retailers.
You turn complex technical findings into clear, decision-ready content.""",
llm="anthropic/claude-sonnet-4-20250514",
verbose=True
)
Tasks
A task defines a specific piece of work assigned to an agent, with context about what the output should look like.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from crewai import Task
research_task = Task(
description="""Analyze the current state of enterprise AI platform adoption
in European retail (2025-2026). Focus on:
1. Which AI frameworks retailers are choosing and why
2. Common deployment patterns (cloud, hybrid, on-prem)
3. ROI data from early adopters
Provide specific company examples where possible.""",
expected_output="A structured report with at least 5 key findings, each backed by data or examples",
agent=researcher,
output_file="research_report.md"
)
writing_task = Task(
description="""Using the research findings, create a 2-page executive briefing
for the CTO of a major European electronics retailer. Include a recommendation
section with next steps.""",
expected_output="A polished executive briefing in markdown format",
agent=writer,
context=[research_task] # this task receives output from research_task
)
Crews and Processes
A crew brings agents and tasks together with a process that governs execution order.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from crewai import Crew, Process
# Sequential: tasks run in order, each receiving context from previous
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
process=Process.sequential,
verbose=True,
memory=True, # shared memory across the crew
max_rpm=10, # rate limiting for API calls
planning=True # crew plans before executing
)
result = crew.kickoff()
print(result.raw) # final output string
print(result.token_usage) # total tokens consumed
Hierarchical Process
In hierarchical mode, a manager agent is automatically created (or you provide one). The manager reads all task descriptions, decides which agent handles what, reviews outputs, and re-delegates if quality is insufficient.
1
2
3
4
5
6
7
crew = Crew(
agents=[researcher, writer, editor],
tasks=[research_task, writing_task, editing_task],
process=Process.hierarchical,
manager_llm="anthropic/claude-sonnet-4-20250514",
verbose=True
)
The manager agent acts as a supervisor – it can reject work, ask for revisions, or reassign tasks. This is useful when task dependencies are complex or agents need dynamic coordination.
Tools
CrewAI has a built-in tool ecosystem and supports custom tools.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from crewai.tools import tool
from crewai_tools import SerperDevTool, ScrapeWebsiteTool, FileReadTool
# Built-in tools
search_tool = SerperDevTool() # Google search via Serper API
scrape_tool = ScrapeWebsiteTool() # Web scraping
file_tool = FileReadTool() # Read local files
# Custom tools
@tool("Product Database Search")
def search_products(query: str, category: str = "all") -> str:
"""Search the internal product database for matching items.
Use this when the user asks about specific products or inventory."""
# your implementation
return results
# Assign tools to agents
agent = Agent(
role="Product Specialist",
goal="Find relevant products",
backstory="...",
tools=[search_tool, search_products]
)
Tool Calling Control
1
2
3
4
5
6
7
# Force a specific tool on a task
task = Task(
description="Search for AI platform vendors",
agent=researcher,
tools=[search_tool], # limit which tools this task can use
expected_output="List of vendors"
)
Memory System
CrewAI provides three types of memory that persist across tasks within a crew run:
| Memory Type | Scope | Purpose |
|---|---|---|
| Short-term | Current crew run | Recent interactions and context |
| Long-term | Across crew runs | Learned patterns, stored in local DB |
| Entity | Across crew runs | Knowledge about specific entities (people, companies, products) |
1
2
3
4
5
6
7
8
9
crew = Crew(
agents=[...],
tasks=[...],
memory=True, # enable all memory types
embedder={ # configure embedding model for memory
"provider": "openai",
"config": {"model": "text-embedding-3-small"}
}
)
CrewAI Flows
Flows provide a more programmatic way to orchestrate crews and tasks, giving you explicit control over execution order and conditional logic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from crewai.flow.flow import Flow, listen, start
class ContentPipeline(Flow):
@start()
def research_phase(self):
result = research_crew.kickoff()
return result
@listen(research_phase)
def quality_gate(self, research_output):
# Programmatic check — not LLM-based
if len(research_output.raw) < 500:
return self.research_phase() # retry
return research_output
@listen(quality_gate)
def writing_phase(self, approved_research):
writing_crew.tasks[0].context = approved_research
return writing_crew.kickoff()
pipeline = ContentPipeline()
result = pipeline.kickoff()
CrewAI Enterprise
The commercial offering adds:
- CrewAI Studio: Visual builder for designing crews, agents, and tasks
- Deployment: One-click deploy to managed infrastructure
- Monitoring: Execution traces, cost tracking, performance metrics
- Guardrails: Content filtering, output validation, budget controls
- SSO/RBAC: Enterprise auth and access control
CrewAI vs LangGraph
| Dimension | CrewAI | LangGraph |
|---|---|---|
| Abstraction level | High (roles, goals, backstories) | Low (nodes, edges, state) |
| Setup time | Minutes | Hours |
| Flexibility | Moderate (process types) | Very high (arbitrary graphs) |
| Multi-agent model | Role-based delegation | Graph-based routing |
| State management | Built-in memory system | Typed state + checkpointing |
| Human-in-the-loop | Limited (via callbacks) | First-class (interrupt/resume) |
| Persistence | Local DB for memory | Postgres, SQLite, Redis |
| Debugging | Verbose logging | LangSmith traces + Studio |
| Production readiness | Good (Enterprise tier) | Strong (LangGraph Platform) |
| Learning curve | Gentle | Steep |
When to Use
Choose CrewAI when:
- You want multi-agent collaboration running quickly with minimal code
- The “team of specialists” mental model fits your problem (research, write, review, etc.)
- Your agents have clearly defined roles and the workflow is mostly linear or hierarchical
- You want built-in memory and delegation without plumbing it yourself
- Rapid prototyping of agent teams for internal tools
Avoid CrewAI when:
- You need fine-grained control over agent state and transitions (use LangGraph)
- Your workflow has complex cycles, parallel branches, or conditional routing
- You need durable checkpointing and crash recovery
- Human-in-the-loop approval gates are critical to your workflow
- You need TypeScript/JavaScript support
Practical Tips for Enterprise Use
- Set
max_iterconservatively. Default is 15 iterations per task – this burns tokens fast. Start with 3-5 for most tasks. - Use
max_rpmto respect rate limits. Especially important with Claude or GPT-4 APIs. - Pin your LLM versions. CrewAI supports
llm="anthropic/claude-sonnet-4-20250514"– use exact model IDs, not aliases. - Start sequential, graduate to hierarchical. The manager agent in hierarchical mode adds significant token overhead. Only use it when dynamic task routing is genuinely needed.
- Test crews with smaller models first. Use a fast model (Haiku, GPT-4o-mini) for iteration, then switch to a capable model for production.
References
- CrewAI docs: https://docs.crewai.com/
- GitHub: https://github.com/crewAIInc/crewAI
- CrewAI Tools: https://github.com/crewAIInc/crewAI-tools
- CrewAI Enterprise: https://www.crewai.com/enterprise