You don't need a PhD to build an AI agent that actually works. CrewAI makes it possible in under 50 lines of Python. Here's the fastest way from zero to running.
What You'll Build
By the end of this guide, you'll have a working research agent that searches the web, summarizes findings, and writes a short report. No external APIs beyond an LLM key.
Prerequisites
- 15 minutes
Step 1: Install CrewAI
``bash
pip install crewai crewai-tools
`
That's it. CrewAI handles the agent orchestration, task delegation, and inter-agent communication.
Common mistake: Installing crewai without crewai-tools leaves you without web search, file reading, and other essential tools. Always install both.
Step 2: Define Your First Agent
Create research_crew.py:
`python
from crewai import Agent, Task, Crew
from crewai_tools import SerperDevTool
Tool: web search
search_tool = SerperDevTool()
Agent 1: The Researcher
researcher = Agent(
role="Research Analyst",
goal="Find accurate, up-to-date information on any topic",
backstory="You are a meticulous analyst who verifies facts before reporting.",
tools=[search_tool],
verbose=True
)
Agent 2: The Writer
writer = Agent(
role="Technical Writer",
goal="Summarize research into clear, actionable reports",
backstory="You write for busy professionals who need the gist fast.",
verbose=True
)
`
The backstory isn't fluff. CrewAI uses it to shape how the agent approaches tasks. A researcher with a "meticulous" backstory will double-check sources. A "speed-first" researcher will cut corners.
Step 3: Create Tasks
`python
research_task = Task(
description="Research the current state of AI agent frameworks in 2026. Find the top 5 by GitHub stars and active contributors.",
expected_output="A bullet list of 5 frameworks with star counts, last commit dates, and 1-line summaries.",
agent=researcher
)
write_task = Task(
description="Write a 300-word summary of the research findings. Include a recommendation for beginners.",
expected_output="A markdown report with an H2 heading and 3-4 paragraphs.",
agent=writer,
context=[research_task] # Writer sees researcher's output
)
`
The context parameter is the secret sauce. It passes the first task's output to the second agent automatically.
Step 4: Assemble the Crew
`python
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, write_task],
process="sequential", # "parallel" for independent tasks
verbose=2
)
result = crew.kickoff()
print(result)
`
Run it:
`bash
export OPENAI_API_KEY="sk-..."
python research_crew.py
`
You'll see the researcher search, find results, and hand off to the writer. The writer then produces the final report.
Step 5: Add a Third Agent (Editor)
Adding an editor ensures quality before the output reaches you:
`python
editor = Agent(
role="Editor",
goal="Ensure the report is accurate, clear, and concise",
backstory="You catch errors others miss. You flag unclear sentences and verify facts.",
verbose=True
)
edit_task = Task(
description="Review the writer's report. Check for accuracy, clarity, and completeness. Return a polished version.",
expected_output="A polished markdown report with no errors.",
agent=editor,
context=[write_task]
)
crew = Crew(
agents=[researcher, writer, editor],
tasks=[research_task, write_task, edit_task],
process="sequential",
verbose=2
)
`
The editor sees both the research and the draft. It can spot when the writer misinterpreted a finding or when a source doesn't support a claim.
What to Do Next
- Deploy it — wrap the crew in a FastAPI endpoint or run it on a schedule
What's Still Hard
Tool failures cascade. If the search API hits a rate limit, the researcher can't complete its task, and the writer gets garbage input. CrewAI doesn't auto-retry by default. You need to wrap tools in error handling.
Prompt injection is real. An agent with web access can be tricked by malicious pages. Don't give agents write access to production systems without sandboxing.
Debugging is painful. When a crew of 4 agents fails, figuring out which agent broke and why requires reading verbose logs. There's no step-through debugger.
Related Reading
The Bottom Line
CrewAI abstracts away the hardest part of multi-agent systems: orchestration. You define who does what, and it handles the handoffs. Start with two agents and one tool. Scale once you understand where it breaks.
Start building. The best way to learn agent frameworks is to ship something that breaks.
Daily AI Intelligence, Free
Get AI news and analysis delivered to your inbox. No spam. Unsubscribe anytime.
One-click unsubscribe · We never share your data