← Blog

· 4 min read

CrewAI Explained: Build a Two-Agent Team in Python

Most "AI agent" demos are one model in a loop. CrewAI takes a different view: give several agents a role, a goal and a task each, and let them work as a small team. Here is when that helps, when it doesn't, and a working crew you can run today.

CrewAI is an open-source Python framework under the MIT licence, with about 61,100 stars on GitHub when I checked (GitHub, 2026). It installs from PyPI like any other package (PyPI, 2026).

1. What a crew is

In CrewAI's words, crews are teams of autonomous agents that collaborate to solve specific tasks (CrewAI, 2026). Each agent has a role, a goal and a backstory, and each task names the agent that owns it and the output you expect.

CrewAI's two ways to run a crew
ProcessHow it worksUse it when
SequentialTasks run in order; each sees the last one's outputThe steps are known: research, then write, then review
HierarchicalA manager agent delegates and checks the workThe order depends on what is found. Needs an extra manager model
FlowEvent-driven steps with saved state; a crew can be one stepAnything going to production

2. A two-agent demo

Install with uv tool install crewai (Python 3.10 to 3.13). This crew, adapted from the project's README, has an analyst and a researcher working in order:

from crewai import Crew, Agent, Task, Process

analyst = Agent(role="Senior Market Analyst",
    goal="Conduct deep market analysis with expert insight",
    backstory="You're a veteran analyst known for identifying subtle market patterns")
researcher = Agent(role="Data Researcher",
    goal="Gather and validate supporting market data",
    backstory="You excel at finding and correlating multiple data sources")
analysis = Task(description="Analyze {sector} sector data for the past {timeframe}",
    expected_output="Detailed market analysis with confidence score", agent=analyst)
research = Task(description="Find supporting data to validate the analysis",
    expected_output="Corroborating evidence and potential contradictions", agent=researcher)
crew = Crew(agents=[analyst, researcher], tasks=[analysis, research],
    process=Process.sequential, verbose=True)
print(crew.kickoff(inputs={"sector": "tech", "timeframe": "1W"}))

Set your model provider's key before running. Our CrewAI recipe covers configuration in more depth.

3. Where it fits, and where it doesn't

Good fits are research reports, content pipelines and proposal drafts: work a human team would split by role. A poor fit is anything a function can do. CrewAI's own docs say to start production apps with a Flow and use a crew inside a step only when that step needs autonomy (CrewAI, 2026). My rule: if you can draw the steps on a whiteboard, write them as code.

Should you build this as a crew?

Score each 0 (no), 1 (partly) or 2 (yes):

  • Roles: the work splits naturally into distinct jobs.
  • Judgement: some steps need reasoning, not just rules.
  • Output: every task has a clear expected output.
  • Budget: you have measured the cost of several model calls per run.
  • Review: a person checks the final result before it is used.
What your score means (my recommendation)
ScoreNext move
8–10Build a sequential crew inside a Flow.
5–7Prototype it, but compare against a single prompt.
0–4Write a plain workflow instead.

Your next step

Pick one report your team writes every week. Write its steps as two or three CrewAI tasks, run the crew on last week's inputs, and compare the draft with what your team actually sent. For ready-made agent definitions, see our free subagent templates.

Sources

  1. CrewAI (2026). Introduction and Crews. Read 20 November 2026.
  2. GitHub (2026). crewAIInc/crewAI repository. Stars read 20 November 2026.
  3. PyPI (2026). crewai. Read 20 November 2026.

NEW CODE EVERY MONTH.

Get a note when new Claude Code templates, code recipes or tools go live.

No account required

We email once to confirm. Unsubscribe anytime — it deletes your address.

New drops, every week

Free tools & Claude templates, landing regularly.

We keep shipping new free tools, code recipes and Claude Code templates. Follow @freeyantra on Instagram or join the newsletter so you never miss one.

Follow @freeyantra

or get them by email

Double opt-in. Unsubscribe any time. Privacy