Skip to main content

07. Frameworks & Libraries

CrewAI Fundamentals (Agents, Tasks, Crews, Processes)

CrewAI is a multi-agent framework built around four ideas: Agents (role personas with tools), Tasks (concrete deliverables), Crews (the team + task list), and Processes (sequential or hierarchical execution). It maps cleanly to supervisor–worker and specialty pipelines from Module 06.

What you will learn

  • Define agents, tasks, crews, and processes in CrewAI
  • Write a clear role/goal/backstory and expected_output
  • Choose sequential vs hierarchical process
  • Map CrewAI to supervisor–worker patterns
  • Answer interview questions with short, solid answers
CrewAI pillars: agents tasks crews and processes
Interview staple: CrewAI = agents + tasks assembled into a crew run by a process.

Definition

CrewAI is a Python-centric framework for orchestrating role-playing AI agents that collaborate on tasks. You define who the agents are, what each task must produce, group them into a crew, and pick a process that controls execution order and delegation.

Compared with LangGraph’s explicit graphs, CrewAI emphasizes crew metaphors (roles, tasks, kickoff). Both can implement the same MAS designs; CrewAI optimizes for fast multi-agent composition.

Introduction

This lesson (#5 in Frameworks & Libraries) follows LangGraph HITL/multi-agent. You know durable graphs; now learn a crew-first toolkit.

Next: Building Multi-Agent Apps with CrewAI — end-to-end product patterns on these primitives.

Why CrewAI

  • Natural mapping to research/writer/reviewer teams
  • Task expected_output makes deliverables explicit
  • Hierarchical process ≈ supervisor–worker out of the box
  • Good teaching bridge from MAS theory to code

Agents

An agent is a persona: role, goal, backstory, optional tools, and an LLM. Keep tools least-privilege per role — same rule as Module 05 Tool-Use.

Agent persona assigned to a task with expected output
Agent = who. Task = what done looks like.
  • role - job title style label (Research Analyst)
  • goal - what success means for this persona
  • backstory - constraints and style hints
  • tools - allowlisted capabilities only
  • verbose / allow_delegation - ops and hierarchy knobs

Tasks

  • description - instructions and inputs for the work
  • expected_output - schema-like description of the artifact
  • agent - who owns the task (or manager assigns in hierarchical)
  • context - prior tasks whose outputs feed this one
  • Write expected_output as if a validator will read it

Crews

  • agents[] - the roster
  • tasks[] - ordered or manager-driven work items
  • process - sequential or hierarchical
  • kickoff / kickoff_async - start the run with inputs
  • One crew = one product workflow unit to eval and budget

Processes

Process is how the crew executes — not a separate microservice.

Sequential task pipeline versus hierarchical manager delegation
Sequential = pipeline. Hierarchical = manager delegates like supervisor–worker.
  • Sequential - tasks run in order; outputs can feed context
  • Hierarchical - manager agent plans and delegates to workers
  • Start sequential - add hierarchy when span of control needs it
  • Always - cap iterations/timeouts at the app layer

Map to earlier modules

  • Agents ≈ specialized workers (research/coding/reviewer)
  • Tasks ≈ delegation contracts (objective + expected output)
  • Sequential crew ≈ prompt chaining / pipeline collaboration
  • Hierarchical process ≈ supervisor–worker / Orchestrator-Worker
  • LangGraph still better when you need fine-grained durable graphs/HITL

Failure modes

  • Vague expected_output - fluffy essays nobody can validate
  • God agents - every tool on every role
  • Hierarchy without a real manager goal - thrashy delegation
  • No budgets - crews loop and burn tokens
  • Skipping evals - demos that fail on real inputs

Program / implementation notes

Define agents and tasks as data (YAML/classes), keep secrets in env, and wrap kickoff behind your API with logging and cost caps.

  • Prefer structured expected_output + post-validators in app code
  • Next: Building Multi-Agent Apps with CrewAI

Advantages and limitations

  • Advantage: fast multi-agent composition with clear roles/tasks
  • Advantage: hierarchical process matches org metaphors
  • Advantage: strong fit for content/research/ops crews
  • Limitation: less explicit low-level graph control than LangGraph
  • Limitation: easy to over-crew simple jobs
  • Limitation: still need your own auth, evals, and observability

Key points

  • CrewAI = Agents + Tasks + Crew + Process.
  • Agents need role, goal, backstory, and scoped tools.
  • Tasks need description and crisp expected_output.
  • Sequential process = pipeline; hierarchical = manager delegates.
  • Maps to supervisor–worker and specialty patterns.
  • Cap cost/time; validate outputs in application code.

FAQs

CrewAI vs LangGraph?

CrewAI is crew/task-centric for quick multi-agent teams. LangGraph is graph/state-centric for durable, interruptible control flow. Pick based on topology needs.

Must every crew be hierarchical?

No. Sequential is the right default. Use hierarchical when a manager must dynamically assign work.

Where do tools live?

On agents (and sometimes tasks). Keep allowlists per role — research should not get deploy tools.

How do task context links work?

Later tasks can list earlier tasks as context so outputs flow forward in a sequential process — like pipeline handoffs.

Interview questions

  1. What are the four core CrewAI concepts?

    Answer Agents (personas/tools), Tasks (work + expected output), Crews (team + tasks), and Processes (sequential or hierarchical execution).

  2. What belongs on a CrewAI agent?

    Answer Role, goal, backstory, optional tools, and model settings — with least-privilege tool access.

  3. Why is expected_output important?

    Answer It defines the deliverable contract so the next task or validator knows what “done” means — not free-form chat.

  4. Sequential vs hierarchical process?

    Answer Sequential runs tasks in order. Hierarchical uses a manager agent to plan and delegate to worker agents.

  5. How does hierarchical CrewAI map to theory?

    Answer It implements supervisor–worker / Orchestrator-Worker: a manager assigns and integrates; workers execute specialized tasks.

  6. When prefer LangGraph instead?

    Answer When you need fine-grained durable graphs, complex branching, or first-class checkpoint/HITL control beyond crew kickoff.

Related topics

Practice task

Complete each numbered practice step in a notebook or doc before opening the next lesson.

  1. Define 3 agents for a “competitor brief” crew (role, goal, tools each).
  2. Write 3 tasks with expected_output one-liners and which agent owns each.
  3. Choose sequential or hierarchical — justify in 2 sentences.
  4. List 2 validation checks you would run after kickoff on the final artifact.
  5. Answer interview questions 1, 3, and 4 in two sentences each.