What Is CrewAI?
CrewAI is a Python framework for building multi-agent AI systems where each agent has a defined role, goal, and backstory. Rather than writing a single monolithic prompt, you decompose complex work into a crew of specialized agents that collaborate sequentially or hierarchically.
The mental model is close to a real team: a researcher, a writer, and an editor each do distinct work, hand off results, and produce a final output that none could produce alone.
Core Concepts
Agent — defined by role (job title), goal (what it optimizes for), and backstory (context that shapes its behavior). The backstory is surprisingly powerful for steering tone and expertise level.
Task — a discrete unit of work assigned to an agent, with a description, expected output, and optional context from previous tasks.
Crew — the collection of agents and tasks, plus a process (sequential or hierarchical) that defines execution order.
from crewai import Agent, Task, Crew, Process
researcher = Agent(
role="Senior Research Analyst",
goal="Uncover cutting-edge developments in AI and data science",
backstory="You work at a leading tech think tank. Your expertise lies in "
"identifying emerging trends and synthesizing complex information.",
verbose=True,
allow_delegation=False,
)
writer = Agent(
role="Tech Content Strategist",
goal="Craft compelling content on tech advancements",
backstory="You are a renowned Content Strategist, known for your insightful "
"and engaging articles. You transform complex concepts into clear prose.",
verbose=True,
allow_delegation=True,
)
research_task = Task(
description="Conduct a comprehensive analysis of the latest advancements in AI. "
"Identify key trends, breakthrough technologies, and potential industry impacts.",
expected_output="Full analysis report with trends, technologies, and impacts",
agent=researcher,
)
write_task = Task(
description="Using the researcher's findings, develop an engaging blog post "
"that highlights the most significant AI advancements.",
expected_output="Full blog post of at least 4 paragraphs",
agent=writer,
)
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, write_task],
process=Process.sequential,
verbose=True,
)
result = crew.kickoff()
Memory System
CrewAI supports three memory types: short-term (in-context for the current run), long-term (persisted across runs via SQLite), and entity (knowledge about specific people, places, and concepts extracted from interactions). Long-term memory lets agents build up institutional knowledge over repeated use.
Tool Integration
Agents can use tools including web search (via SerperDev or Tavily), code interpreter (runs Python in a sandbox), file read/write, and custom tools you define as Python functions decorated with @tool.
CrewAI vs AutoGen vs LangGraph
CrewAI is the most approachable for role-based workflows with clear handoffs. AutoGen excels at code generation with back-and-forth agent conversation. LangGraph gives you the most control via explicit state machines but requires more code. For document research + writing pipelines, CrewAI is typically the fastest to build.