DS DevShelfHub Projects · AI tools
Tutorials / AI Agents / Your First Crew
Build with CrewAI Beginner · 10 min read Page 4 of 29

How to Build Your First CrewAI Crew in Python

By DevShelfHub

Build a working two-agent crew end to end. By the end of this page you will have a researcher and writer producing a real brief.

Series progress4 / 29
CrewAI first crew tutorial — How to Build Your First CrewAI Crew in Python

What We'll Build

A two-agent crew that researches a topic and writes a short brief about it:

Topic Researcher Writer Brief

The Full Code

Save this as first_crew.py:

first_crew.py

PYTHON
from dotenv import load_dotenv
from crewai import Agent, Task, Crew, Process

load_dotenv()

# 1. Define agents
researcher = Agent(
    role="Senior Research Analyst",
    goal="Find 5 key facts about {topic}",
    backstory=(
        "You are an analyst known for terse, accurate summaries "
        "and zero hallucinations. You cite sources."
    ),
    verbose=True,
    allow_delegation=False,
    max_iter=5,
)

writer = Agent(
    role="Tech Writer",
    goal="Turn research notes into a 200-word brief",
    backstory=(
        "You write punchy, jargon-light explainers for busy "
        "engineering managers. You avoid filler."
    ),
    verbose=True,
    allow_delegation=False,
    max_iter=5,
)

# 2. Define tasks
research_task = Task(
    description="Research {topic}. List 5 key facts with one-line explanations.",
    expected_output="Markdown bullet list of 5 facts.",
    agent=researcher,
)

writing_task = Task(
    description=(
        "Using the research notes, write a ~200-word brief on {topic} "
        "for an engineering manager. Plain prose, no bullets."
    ),
    expected_output="A single paragraph brief, ~200 words.",
    agent=writer,
    context=[research_task],   # writer sees researcher's output
)

# 3. Wire up the crew
crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    process=Process.sequential,
    verbose=True,
)

# 4. Run it
result = crew.kickoff(inputs={"topic": "vector databases"})
print("\n=== FINAL BRIEF ===\n")
print(result)

Run It

Terminal

BASH
python3 first_crew.py

You'll see verbose logs as each agent thinks, then the final 200-word brief printed at the end. The whole run typically takes 20–60 seconds and costs a few cents on GPT-4o-mini.

What Just Happened

1

kickoff substituted {topic} into the task descriptions.

2

The researcher executed first (sequential process). Its output got cached.

3

The writer ran next with the researcher's output injected via context=[research_task].

4

The crew returned the last task's output as the final result.

Things to Try

  • Change the topic input — the same crew works on anything.
  • Set verbose=False to see what the clean output looks like.
  • Add a third "editor" agent that critiques the writer's output.

Notes

Kickoff inputs should be boringly explicit

Ambiguous dict keys propagate straight into agent prompts. Prefer stable schemas, default values, and validation before kickoff so your first crew fails fast on bad data instead of hallucinating around it.

Two-agent crews still need contracts

Sequential handoffs live or die on expected_output. If the writer cannot tell what structured facts the researcher owes, you will get elegant prose with missing numbers.

Model choice dominates first impressions

Smaller models can work for narrow tasks but may skip tool discipline early on. It is fine to prototype with a frontier model, then downgrade once prompts and guardrails are stable.

Treat the first crew as a tracing exercise

Before inviting teammates, wire basic logging or tracing so you can answer what each agent saw. That habit pays off immediately when you add tools and memory in later lessons.

CrewAI first crew FAQ

What should my first CrewAI crew do?

Start with two agents and two tasks, such as research bullets followed by a short article, so you can see handoffs without complex tools or branching.

How do I run kickoff on a CrewAI crew?

Construct a Crew with agents, tasks, and process, then call kickoff with inputs that match your task placeholders. Watch verbose logs the first few times to confirm ordering.

Why use Process.sequential first?

Sequential ordering is easiest to reason about and debug. Add hierarchical flows only after plain pipelines produce reliable outputs.

How do I pass topic variables into CrewAI tasks?

Use templated strings in task descriptions and supply values through kickoff inputs so the same crew can run multiple scenarios without rewriting code.

What breaks most first CrewAI projects?

Missing API keys, overly vague task descriptions, and agents with overlapping goals. Fix keys first, then tighten task contracts before expanding the crew.

See also: DevShelfHub's CrewAI tool review for a product-level comparison, pricing notes, and links back into this tutorial series.

Quick jump: API Reference