CrewAI
An Agentic Framework
CrewAI is one of those tools that made me sit up straight when I first played with it. The idea is simple: instead of prompting a single AI model to do everything, you assemble a team of specialized AI agents that divide up the work. Each agent has a role, a goal, and a backstory — and together, they tackle tasks in sequence or in parallel, depending on how you set things up.
It sounds like something from a sci-fi movie, and honestly, the first time I ran a crew and watched the agents hand off work to each other, it kind of felt like one.
Core concepts
Here’s the 101 on CrewAI:
-
Agents: Think of these as the individuals in your team. Each agent has:
- A role (e.g., researcher, writer, analyst).
- A goal (what they’re supposed to achieve).
- A backstory (a little personality never hurts).
- Tools (optional, for special powers like searching the web and RAG).
-
Tasks: These are the jobs your agents need to complete. Tasks come with:
- A detailed description so there’s no room for confusion.
- An expected output to set clear expectations.
-
Tools: Sometimes, agents need a bit of help. CrewAI supports built-in tools and third-party integrations (like APIs) to give your agents superpowers.
-
Processes: Define how your team works—whether tasks are done one at a time, all at once, or in a hierarchy of steps.
Example:
Let’s say you want to create a crew that researches the latest “economic news” and writes a summary. Here’s how you’d do it:
from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool
# Add a search tool for research
search_tool = SerperDevTool()
# Define your agents
researcher = Agent(
role="Researcher",
goal="Find the latest trends in {topic}",
backstory="An expert at digging up fresh insights",
tools=[search_tool]
)
writer = Agent(
role="Writer",
goal="Turn research into an engaging article",
backstory="A storyteller at heart, great at simplifying complex ideas"
)
# Define the tasks
research_task = Task(
description="Research {topic} and summarize findings.",
expected_output="A summary of the research on {topic}.",
agent=researcher
)
write_task = Task(
description="Write an article based on the research on {topic}.",
expected_output="A polished, engaging article on {topic}.",
agent=writer
)
# Assemble your crew
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, write_task],
process=Process.sequential # Tasks are completed one after another
)
# Kick it off
inputs = {"topic": "economic news"}
results = crew.kickoff(inputs=inputs)
print(results)
What I like most about this pattern is that it forces you to think clearly about what each step in a workflow actually needs — what goes in, what should come out, and who’s responsible. Those are design questions, not just engineering questions. And once you start thinking in agents and tasks, you start seeing automation opportunities everywhere.
Check out this project to see how it all comes together.