← Back to Agentic AI map
Lesson 6.1 · CrewAI

What is CrewAI

CrewAI builds agents like a team of employees: each one gets a role, a goal and a backstory, and each task says what to deliver. See what CrewAI really sends to the model, run a researcher-and-writer crew, and compare it with the LangGraph team from Lesson 3.8.

crewai

What you will be able to do

  • Explain the difference between role-based agents (CrewAI) and graph-based agents (LangGraph)
  • Name the four main parts of CrewAI: Agent, Task, Crew, Process
  • Read the prompt CrewAI builds from role, goal, backstory and task
  • Explain how one task’s output reaches the next agent
  • Decide when CrewAI is a good fit, and when LangGraph is better

The idea, in plain English

In Module 3 you built agents as graphs: you decided every node, every edge and every field of the state. That gives full control, but you write a lot of code.

CrewAI starts from a different picture: a team of employees. You describe each person - a role, a goal, a backstory - and the tasks they must finish. CrewAI turns those descriptions into prompts and runs the tasks in order.

In this lesson we look inside: we capture every message CrewAI sends to llama3, run a two-agent crew, and compare it with the LangGraph team from Lesson 3.8. CrewAI 1.15.27, llama3 on Ollama.

Worked example: A two-agent crew (researcher -> writer) about LangGraph checkpoints, with every prompt CrewAI sent to llama3 captured - and a confident, wrong answer.

comparisonA crew of employees, or a graph?step 1 / 3

1 - The researcher works

CrewAI turns the agent’s role, goal and backstory into a system prompt, and the task into a user prompt. One model call.

system prompt
"You are Researcher. ..."
user prompt
"Current Task: List 3 key facts ..."
model calls
1
facts correct?
no - invented

The same researcher-and-writer job. Real CrewAI run, real prompts.

Words you will see in this module

CrewAI has its own small set of words. Here they are.

Small dictionary
AgentOne team member, described by role, goal and backstory, with a model (and maybe tools).
RoleThe job title: "Researcher", "Writer".
GoalWhat this agent tries to achieve.
BackstoryA few sentences of background that shape how the agent behaves.
TaskOne piece of work: a description, an expected_output, and the agent who does it.
CrewThe team: a list of agents and a list of tasks.
ProcessHow tasks are run: sequential (in order) or hierarchical (a manager decides).
kickoff()Starts the crew and returns a CrewOutput.

An everyday example: hiring a team vs drawing a flowchart

There are two ways to organise work in an office:

  • The flowchart way (LangGraph): you draw every box and arrow. "After step 3, if the amount is above 1,000, go to step 7." Every path is decided by you.
  • The team way (CrewAI): you hire people with clear job titles and give each one a task. "You are the researcher; find three facts. You are the writer; turn them into a paragraph." The people do the work in order.
  • The team way is faster to set up and easy to read. The flowchart way gives you exact control over every step and every check.

The four parts of CrewAI

Every CrewAI program uses the same four pieces:

  • Agent - who does the work: role, goal, backstory, llm.
  • Task - what must be done: description, expected_output, agent.
  • Crew - the team: agents=[...], tasks=[...].
  • Process - the order: Process.sequential (tasks one after another) or Process.hierarchical (a manager agent hands out work - Lesson 6.6).
  • You start it with crew.kickoff(), and can fill in placeholders like {topic} with kickoff(inputs={"topic": ...}).

Example 1 - a researcher and a writer

A two-agent crew. Read it in order:

  • llm: one local model for both agents (Lesson 6.2 explains the setup).
  • researcher and writer: each has a role, a goal and a backstory.
  • research and write: two tasks. {topic} is a placeholder filled in by kickoff(inputs=...).
  • Process.sequential: task 1 runs first, then task 2.
  • The script takes the Ollama address as an argument, so we could put a small "spy" in between and record every request.
crew_team.py
import sys, time from crewai import LLM, Agent, Crew, Process, Task base = sys.argv[1] if len(sys.argv) > 1 else "http://localhost:11434" llm = LLM(model="ollama/llama3", base_url=base, temperature=0) researcher = Agent( role="Researcher", goal="Collect the key facts about a topic", backstory="You find facts and write them as short bullet points. You never write articles.", llm=llm, ) writer = Agent( role="Writer", goal="Turn facts into one clear paragraph for beginners", backstory="You write short, simple paragraphs for new developers.", llm=llm, ) research = Task( description="List 3 key facts about {topic}.", expected_output="Exactly 3 bullet points.", agent=researcher, ) write = Task( description="Write one paragraph (max 60 words) about {topic} for beginners, using the research.", expected_output="One paragraph, at most 60 words.", agent=writer, ) crew = Crew(agents=[researcher, writer], tasks=[research, write], process=Process.sequential) start = time.perf_counter() result = crew.kickoff(inputs={"topic": "LangGraph checkpoints"}) print("--- task 1 output:\n" + result.tasks_output[0].raw) print("--- final output:\n" + result.raw) print(f"--- {len(result.raw.split())} words, {time.perf_counter() - start:.1f} s")
Output - a real llama3 run
--- task 1 output: Here are three key facts about LangGraph checkpoints: • LangGraph checkpoints are a type of checkpoint that is used in the LangGraph framework, which is a graph-based neural network architecture for natural language processing tasks. • LangGraph checkpoints are designed to allow for efficient and flexible training of large-scale language models, and can be used to implement various types of language models, such as transformer-based models and recurrent neural networks. • LangGraph checkpoints are typically stored in a binary format and can be loaded and used as input for training or inference, allowing for easy experimentation and comparison of different models and hyperparameters. --- final output: Here is the paragraph about LangGraph checkpoints for beginners: LangGraph checkpoints are a key component of the LangGraph framework, a graph-based neural network architecture for natural language processing tasks. These checkpoints enable efficient and flexible training of large-scale language models, allowing for the implementation of various types of models, such as transformer-based models and recurrent neural networks. They are stored in a binary format and can be easily loaded and used as input for training or inference, making it simple to experiment and compare different models and hyperparameters. --- 88 words, 13.9 s

Reading Example 1

The crew ran without any error - and the result is wrong in two ways:

  • The facts are invented. You learned in Lesson 3.6 what LangGraph checkpoints really are: saved snapshots of a graph’s state. llama3 described a "neural network architecture" instead.
  • The researcher had no tools and no notes - only the model’s memory. "Researcher" is just a word in the prompt; it does not give the agent any knowledge.
  • The writer used the wrong facts faithfully. Nobody in the crew checked them.
  • The paragraph has 88 words for a 60-word limit. expected_output is a line of text in the prompt, not a rule CrewAI enforces.
  • Both agents started with "Here is ..." - llama3 talking to us, as in Lesson 3.8.

Watch out: A job title does not make an agent an expert. Give a researcher real sources (tools - Lesson 6.7), and check the output in code or with a reviewer.

What CrewAI really sends to the model

We put a small "spy" between CrewAI and Ollama that records every request. The crew made exactly 2 requests - one per task. This is the second one, to the writer:

  • System message: "You are {role}. {backstory}" plus "Your personal goal is: {goal}".
  • User message: "Current Task:" + the description, then "This is the expected criteria for your final answer:" + expected_output.
  • In a sequential crew, the previous task’s output is pasted in under "This is the context you’re working with".
  • No magic: role, goal and backstory are just text in a prompt. A well-written backstory helps; a vague one does not.
  • Requests went to Ollama’s OpenAI-compatible endpoint, /v1/chat/completions, with temperature 0.0.
Request 2 of 2 - the writer, exactly as sent
===== system You are Writer. You write short, simple paragraphs for new developers. Your personal goal is: Turn facts into one clear paragraph for beginners ===== user Current Task: Write one paragraph (max 60 words) about LangGraph checkpoints for beginners, using the research. This is the expected criteria for your final answer: One paragraph, at most 60 words. you MUST return the actual complete content as the final answer, not a summary. This is the context you're working with: Here are three key facts about LangGraph checkpoints: • LangGraph checkpoints are a type of checkpoint that is used in the LangGraph framework, which is a graph-based neural network architecture for natural language processing tasks. • LangGraph checkpoints are designed to allow for efficient and flexible training of large-scale language models, and can be used to implement various types of language models, such as transformer-based models and recurrent neural networks. • LangGraph checkpoints are typically stored in a binary format and can be loaded and used as input for training or inference, allowing for easy experimentation and comparison of different models and hyperparameters. Provide your complete response:

CrewAI and LangGraph, side by side

Lesson 3.8 built a similar team in LangGraph. Compare:

The same kind of team
How you describe itCrewAI: people and tasks. LangGraph: nodes, edges and state.
Code for researcher + writerCrewAI: about 30 lines. LangGraph (3.8, with reviewer and supervisor): about 100 lines.
PromptsCrewAI: built for you from role, goal, backstory, task. LangGraph: you write every prompt.
HandoffCrewAI: previous output pasted as context. LangGraph: fields in a shared state.
ChecksCrewAI: expected_output is only a hint (88 words passed). LangGraph: our reviewer node rejected 62 words in code.
Loops, pauses, approvalCrewAI: limited. LangGraph: cycles, interrupt(), checkpoints (Lessons 3.4-3.7).

When to use CrewAI

  • Good fit: work that people would naturally split into roles - research, write, edit, summarise - in a clear order.
  • Good fit: quick prototypes, when you want a team working in minutes, not hours.
  • Think twice: when you need exact control - loops with limits, human approval, checkpoints, strict checks. That is LangGraph’s strength.
  • They can work together: a CrewAI crew can be one step (one node) inside a bigger LangGraph workflow.
  • Either way, the model is the same. A framework does not make a small model accurate - tools and checks do.

CrewAI at a glance

Agent

Who works.

Agent(role="Writer", goal="...", backstory="...", llm=llm)
Task

What to do, for whom.

Task(description="...", expected_output="...", agent=writer)
Crew

The team.

Crew(agents=[...], tasks=[...], process=Process.sequential)
Run

Fill placeholders.

crew.kickoff(inputs={"topic": "..."})
Final answer

Last task’s output.

result.raw
Each task

All outputs.

result.tasks_output[0].raw

Try it yourself

The code does not change. Swap the content string and the program does something else entirely.

Better facts

“Put the real facts about checkpoints (from Lesson 3.6) into the research task description. Does the writer’s paragraph improve?”

A stricter backstory

“Change the writer’s backstory to "You never write more than 60 words." Count the words again.”

Another topic

“Run the crew with inputs={"topic": "Python lists"} - a topic llama3 knows well. Are the facts better?”

Count the calls

“Add a third agent (an editor) and a third task. How many model calls do you expect?”

What usually goes wrong

Trusting the job title

role="Researcher" gives no knowledge. Without tools or sources, the agent repeats what the model remembers - or invents it.

Treating expected_output as a rule

It is a line in the prompt. Our writer wrote 88 words for a 60-word limit. Check important rules in code.

Choosing a framework by fashion

CrewAI is quick for role-based work; LangGraph gives control. Pick by what the job needs.

Key points

  • CrewAI describes a team: Agents (role, goal, backstory), Tasks (description, expected_output), a Crew and a Process.
  • Under the hood it builds plain prompts: role/backstory/goal -> system message, task -> user message.
  • In a sequential crew, each task’s output is pasted into the next task’s prompt as context.
  • Our crew ran without errors and gave invented facts and 88 words for a 60-word limit - nothing checks expected_output.
  • CrewAI: less code, quick to start. LangGraph: more control over loops, checks and pauses.

Quick check before you move on

What are the four main parts of CrewAI?
Agent, Task, Crew and Process.
Where do role, goal and backstory end up?
In the system message CrewAI sends to the model.
How did the writer get the researcher’s facts?
CrewAI pasted task 1’s output into task 2’s prompt under "This is the context you’re working with".
How many model calls did the two-agent crew make?
Two - one per task.

Quiz

  1. 1.

    Why were the researcher’s facts wrong?

  2. 2.

    The writer wrote 88 words. Why did CrewAI accept it?

  3. 3.

    Name one thing LangGraph does that this crew did not.

  4. 4.

    Can you use CrewAI and LangGraph together?

Interview questions

What is the difference between CrewAI and LangGraph?

CrewAI is role-based: you declare agents (role, goal, backstory) and tasks, and it orchestrates them sequentially or with a manager. LangGraph is graph-based: you define nodes, edges and state explicitly, which gives fine control over loops, branching, persistence and human-in-the-loop.

How does CrewAI pass information between tasks?

In a sequential process the output of earlier tasks is injected into later task prompts as context; you can also set a task’s context explicitly.

What are the risks of persona-based agents?

Personas shape style, not knowledge: without tools and validation, agents can confidently produce wrong content, and natural-language expectations are not enforced. Add tools, guardrails and checks.

Comments

Sign in to leave a comment. Your name and photo come from Google; nothing else is shared.

Loading comments...