Structured Course
Crewai
From first install to production patterns. Every lesson is standalone — jump to what you need, or work through from beginner to advanced.
147 lessons 3 levels Beginner → Advanced
Beginner
What CrewAI Is and Why It Exists 7
Installation and Setup 7
Agents 7
+4 more chapters
Intermediate
Memory Systems 7
Hierarchical Process 7
CrewAI Flows 7
+4 more chapters
Advanced
Async Execution 7
Crew Pipelines 7
Enterprise Patterns 7
+4 more chapters
Full Course Contents
Beginner
49 lessons 1 What CrewAI Is and Why It Exists 7
1
The single-agent limitation: one LLM can't do everything A single agent with one LLM can't effectively handle multiple unrelated tasks: you need specialized agents for different roles.
2 What CrewAI provides: role-based agent collaboration CrewAI lets you define multiple AI agents with specific roles that collaborate together to solve problems by passing work between them.
3 CrewAI vs LangGraph: declarative vs graph-based CrewAI uses declarative agent roles and tasks; LangGraph uses explicit state graphs: choose based on whether you want roles or control flow.
4 CrewAI vs AutoGen: the key differences CrewAI emphasizes role-based agent workflows with built-in tools and structured task execution, while AutoGen focuses on multi-agent conversation patterns with maximum flexibility.
5 When CrewAI is the right choice CrewAI is the right choice when you need multiple AI agents collaborating on a task, each with specialized roles and responsibilities.
6 CrewAI version landscape: 0.x to 1.x changes CrewAI 0.x and 1.x have different APIs: learn which version you're using and what breaks when you upgrade.
7 CrewAI ecosystem: tools, flows, enterprise CrewAI's tool integrations, workflow composition, and enterprise features extend agents beyond basic prompting.
2 Installation and Setup 7
1
pip install crewai crewai-tools Install the CrewAI framework and its built-in tools package to start building multi-agent systems.
2 API key setup for the LLM Configure your LLM API credentials so CrewAI agents can call external language models.
3 Verifying with a minimal crew run Run your first crewai crew with a single agent and task to confirm the framework is working end-to-end.
4 CrewAI version compatibility Understand which CrewAI version you're running and why it matters for imports and agent configuration.
5 AgentOps integration for observability Use AgentOps to automatically track, record, and visualize what your CrewAI agents are doing without changing your agent code.
6 YAML-based crew definition: new in 1.x Define your crew's agents and tasks declaratively in YAML instead of writing Python objects.
7 Project structure with crewai CLI Use the crewai CLI to scaffold a new project with the correct folder layout and boilerplate files.
3 Agents 7
1
Agent class: the core abstraction An Agent is an autonomous entity that acts on behalf of your application, defined by its role, goal, and the LLM powering its decisions.
2 role: the agent's function The <code>role</code> parameter defines what job or expertise your agent has, shaping how it approaches tasks.
3 goal: what the agent tries to achieve A goal is the high-level objective you assign to an agent that guides all its decisions and actions.
4 backstory: context that shapes behavior A backstory is a text prompt that defines an agent's personality, expertise, and decision-making style before it sees any tasks.
5 llm: which model the agent uses Every agent needs an LLM to think with: you specify which model it uses by passing it to the Agent constructor.
6 verbose: watching the agent think Enable <code>verbose=True</code> on your Crew to see step-by-step what your agents are doing instead of getting a black box result.
7 How role+goal+backstory shapes output An agent's role, goal, and backstory are instructions that control how it behaves: changing them changes what it produces.
4 Tasks 7
1
Task class: a unit of work A Task is a discrete unit of work that an Agent executes, with a clear description, expected output, and assigned agent.
2 description: what to do A Crew is the container that orchestrates multiple agents working together to complete a set of tasks.
3 expected_output: what the result should look like Define what you want a task to produce, and CrewAI will ensure the agent's output matches that structure.
4 agent: which agent handles this task Agents are the workers in CrewAI: each one has a role, goal, and backstory, and you assign tasks to the agent best suited for it.
5 Task output: TaskOutput object TaskOutput is the structured result object that every completed task returns, containing the raw output, description, and execution status.
6 context: tasks that must complete first Use <code>context</code> to make a task wait for other tasks to finish and use their outputs as input.
7 Task dependency chains Control the execution order of tasks by making one task depend on the output of another.
5 Crew 7
1
Crew class: the team container A Crew is the orchestrator that brings agents and tasks together, executes them in order, and returns results.
2 agents: list of agents A Crew is powered by multiple Agents working together: you define them as a list and pass them to Crew.
3 tasks: list of tasks Tasks are the units of work that agents execute: define what needs to be done, who does it, and why it matters.
4 process: sequential vs hierarchical Choose whether your agents work one-at-a-time (sequential) or in a tree with a manager agent (hierarchical).
5 crew.kickoff(): starting execution <code>crew.kickoff()</code> is the method that tells your agents to start working through their tasks in the order you defined.
6 CrewOutput: reading results CrewOutput is the object returned by crew.kickoff() that contains the final result and metadata from your agent team's execution.
7 verbose: crew-level logging Enable verbose=True on a Crew to see detailed step-by-step execution logs of your agents' reasoning and actions.
6 Tools 7
1
What tools give agents capabilities Tools are Python functions that agents can invoke to take actions in the real world beyond just thinking.
2 Built-in tools: SerperDevTool, FileReadTool Use crewAI's built-in tools to give agents the ability to search the web and read files without writing custom tool code.
3 Tool installation: crewai-tools package Install and verify the crewai-tools package to give your agents access to pre-built capabilities like web search, file operations, and API interactions.
4 Adding tools to an agent Give your agent access to functions and APIs by attaching tools that extend what it can do beyond text generation.
5 @tool decorator: custom tool from function Use @tool to convert any Python function into a tool that agents can discover and call automatically.
6 Tool description: how agents know when to use it A tool's description and parameters are the agent's instruction manual for deciding whether and how to use it.
7 Tool error handling Wrap tool execution in try-except blocks to prevent agent crashes when external APIs or functions fail.
7 Common Errors and Fixes 7
1
Agent not completing task: vague description Agents fail silently when task descriptions are too vague: specify exactly what output you expect.
2 Tool not found error Agents can't use tools you haven't imported or registered: here's why and how to fix it.
3 Context task not finished error The 'Context task not finished' error occurs when a task tries to use output from another task that hasn't completed execution yet.
4 LLM API key error API key errors happen when your Agent can't authenticate with the LLM provider: fix it by setting the correct environment variable before creating agents.
5 Max iterations exceeded Set <code>max_iter</code> on your agent to prevent infinite loops and control how many times it can think and act.
6 Agent going off-topic Agents without explicit task boundaries will generate irrelevant outputs, and you control this with clear descriptions and max_iter settings.
7 Task output not matching expected format Tasks in crewai 0.70.x return output as a TaskOutput object, not a raw string: and you need to extract the actual value correctly.
Intermediate
49 lessons 1 Memory Systems 7
1
Short-term memory: within a crew run Agents retain context of their own actions and tool outputs during a single crew execution without explicit memory management.
2 Long-term memory: across crew runs Persist agent memories across separate crew executions so agents remember past interactions and decisions.
3 Entity memory: remembering entities Entity memory allows agents to store and recall facts about people, places, and objects across tasks and conversations.
4 Contextual memory: combining memories Combine short-term task memory with long-term agent memory to give crew members persistent, contextual awareness across sequential tasks.
5 Enabling memory on the Crew Give your Crew persistent memory so agents can recall past interactions and learn from task history.
6 Memory storage configuration Configure where and how your crew agents store and retrieve conversation memory across task executions.
7 When memory helps vs adds noise Memory in CrewAI amplifies agent reasoning but can degrade decision-making when tasks require forgetting or when hallucinated context compounds across turns.
2 Hierarchical Process 7
1
Sequential vs hierarchical: the difference Sequential processes run tasks one after another in order; hierarchical processes delegate task execution through a manager agent who decides the workflow.
2 Manager agent: the orchestrator A manager agent coordinates other agents by delegating tasks and synthesizing their outputs into a final answer.
3 How the manager delegates tasks The manager agent in CrewAI orchestrates task execution and decides which agent performs each task based on their roles and capabilities.
4 manager_llm: powerful model for coordination Use a dedicated LLM instance in your Crew to intelligently coordinate agents and make decisions about task execution.
5 Worker agent design for hierarchical crews Design specialized worker agents that report to a manager agent in a hierarchical crew structure.
6 When hierarchical beats sequential Hierarchical process lets you organize agents into manager-worker structures that outperform flat sequential execution for complex multi-stage problems.
7 Debugging hierarchical execution Use verbose logging, step callbacks, and task output inspection to trace execution flow when manager agents coordinate worker agents.
3 CrewAI Flows 7
1
What Flows add: event-driven orchestration Flows let you orchestrate agents and tasks with event-driven logic instead of rigid sequential or hierarchical pipelines.
2 @start: entry point decorator The @start decorator marks which task should execute first when a Crew runs, establishing the entry point for task execution.
3 @listen: event-driven execution @listen decorators let you hook into Agent execution events and react in real-time without blocking the crew workflow.
4 @router: conditional routing between crews Use @router decorator to dynamically route tasks to different crews based on runtime conditions.
5 State management in flows Pass and persist data between tasks in a crew workflow using flow state instead of global variables.
6 Combining crews and flows Chain multiple crews together in sequence using flows to orchestrate complex multi-stage workflows.
7 When flows are better than crews alone Flows let you orchestrate multiple crews and conditional logic that a single crew can't express.
4 Custom Tools 7
1
@tool decorator: the standard pattern The @tool decorator transforms a Python function into a capability that agents can call during task execution.
2 Tool docstring as description Use a tool's docstring to automatically generate its description for the agent without writing it twice.
3 Return value from tools Tools in CrewAI must return string values that agents can read and act on: not raw objects.
4 Tools with complex parameters Define and use tools in crewai that accept structured, nested, or optional parameters beyond simple strings and numbers.
5 Tool that calls an external API Create a reusable tool in crewai that agents can invoke to fetch data from external APIs.
6 Tool that queries a database Create a reusable tool that lets agents query a database and get results back into their reasoning loop.
7 Tool error handling and fallback Implement graceful error handling and fallback strategies when agent tools fail during task execution.
5 Output Handling 7
1
Pydantic model as output schema Define structured task outputs using Pydantic models so agents return validated, type-safe data instead of raw strings.
2 output_pydantic on Task Use output_pydantic to declare that a Task's output must conform to a specific Pydantic model schema, enabling type-safe structured outputs.
3 output_json: JSON output Configure agents to return structured JSON output instead of plain text, making results machine-parseable and downstream-tool-ready.
4 output_file: writing to disk Persist task outputs to disk files instead of keeping them in memory.
5 CrewOutput structure CrewOutput is the structured container holding all results, logs, and metadata returned from a crew's execution.
6 Accessing individual task outputs Extract and work with the output from a specific task after crew execution completes.
7 Chaining outputs between tasks Pass the output of one task as input to the next task to create dependent workflows.
6 LLM Configuration 7
1
ChatOpenAI configuration in CrewAI Configure OpenAI's ChatGPT models as the LLM backend for CrewAI agents with proper API key management and model selection.
2 Per-agent model selection Configure different LLM models for different agents in the same crew to optimize cost and performance.
3 Temperature per agent Control how creative or deterministic each agent's LLM responses are by setting temperature independently per agent.
4 Local models: Ollama integration Run crewAI agents with local LLMs via Ollama instead of cloud APIs, keeping data private and eliminating API costs.
5 Azure OpenAI integration Connect crewai agents to Azure OpenAI instead of OpenAI's direct API for enterprise deployments.
6 Model for manager vs workers Design crews where one agent orchestrates tasks while others execute specialized work, scaling complexity without multiplying agents.
7 Fallback configuration Configure what an agent does when its primary action fails, ensuring graceful degradation instead of task collapse.
7 Testing Crews 7
1
Unit testing individual agents Test individual agent behavior in isolation using pytest and mocked LLM responses to validate task execution without API calls.
2 Mocking tool calls in tests Replace real tool execution with mock objects in unit tests so you can test agent logic without calling external APIs or databases.
3 Task output assertion Validate that a task's output matches expected format or content before passing it to dependent tasks.
4 Crew execution in test mode Run your crew with simulated responses instead of calling LLMs to validate task flow without API costs.
5 Deterministic tests with seed Use seed values to make LLM-powered agent behavior reproducible in tests so assertions don't randomly fail.
6 Performance benchmarking Measure and compare crew execution time, token usage, and cost to identify bottlenecks before they hit production.
7 Regression testing for crew quality Establish repeatable test cases that verify your crew's task outputs remain consistent and correct across code changes.
Advanced
49 lessons 1 Async Execution 7
1
crew.kickoff_async(): non-blocking execution Execute a crew's workflow asynchronously without blocking your application, enabling concurrent task processing and responsive systems.
2 asyncio Integration with Crew Run multiple CrewAI crews concurrently using asyncio to parallelize agent work across independent tasks.
3 Parallel crew execution Execute multiple crews concurrently using Python's async/await and threading to process independent tasks in parallel instead of sequentially.
4 Async Tools Define and use tools with async functions in CrewAI to execute non-blocking operations like API calls or database queries without freezing agent execution.
5 Result handling from async Capture and process crew results when running asynchronous tasks without blocking your application.
6 Timeout for async crews Set execution timeouts on async crews to prevent hanging tasks from blocking indefinitely.
7 Error handling in async context Catch and recover from task failures in async crew execution without losing state or crashing the entire workflow.
2 Crew Pipelines 7
1
What pipelines add: crew chaining Chain multiple crews together so the output of one crew feeds as input to the next, enabling multi-stage hierarchical workflows.
2 Pipeline class Pipeline class orchestrates sequential execution of crews with shared state and error handling between workflow stages.
3 Stage definition Stages partition a crew's execution into sequential phases, allowing you to control task flow, intermediate outputs, and conditional routing with structured orchestration.
4 Data flow between stages Control how task outputs become inputs for downstream tasks using callbacks and shared context in crewai crews.
5 Parallel stages Execute independent task groups simultaneously within a single crew workflow instead of sequentially.
6 Pipeline error handling Implement robust error recovery in multi-agent pipelines so a single task failure doesn't cascade and halt your entire crew.
7 When pipelines beat single crews A single crew handles one sequential workflow, but pipelines chain multiple crews to pass outputs between independent task groups: choose pipelines when crews have distinct scopes, error handling needs, or must run conditionally.
3 Enterprise Patterns 7
1
Multi-tenant crew isolation Isolate crew state, memory, and execution contexts to safely serve multiple independent customers from a single application instance.
2 Per-request agent configuration Override agent parameters at runtime via Crew kickoff inputs instead of hardcoding them at initialization.
3 Crew factory pattern Build reusable crew configurations as parameterized factory functions that instantiate fully-configured agents and tasks on demand.
4 Shared tool registry Centralize tool definitions across multiple agents to avoid duplication and maintain a single source of truth for tool behavior.
5 Role-based agent access control Implement permission layers in multi-agent systems so only agents with specific roles can execute certain tools and tasks.
6 Cost per crew run tracking Track LLM API costs per crew execution by instrumenting agent calls and aggregating token usage across all tasks.
7 Audit logging of agent decisions Capture and persist every agent decision, tool call, and reasoning step for compliance, debugging, and decision traceability.
4 Monitoring and Observability 7
1
AgentOps Integration for Agent Observability Integrate AgentOps to monitor, debug, and audit every action your crew takes in production.
2 Token usage per agent Track and optimize token consumption across individual agents to catch cost overruns and inefficient prompt patterns before they hit production.
3 Task completion rate monitoring Track which crew tasks succeed or fail and calculate real-time completion rates to identify bottleneck agents or unstable task chains.
4 Error rate per task type Track and analyze failure patterns across different task types to identify which agent responsibilities need reliability hardening.
5 Latency per crew run Measure and optimize the total time a crew takes to execute from kickoff to completion.
6 Cost per crew run Track and calculate the actual token cost of a crew execution by capturing LLM usage across all agents and tasks.
7 Quality monitoring patterns Monitor agent task outputs in real-time and validate quality before decisions propagate through your crew.
5 Reliability Patterns 7
1
Retry on task failure Configure tasks to automatically retry with exponential backoff when they fail, with control over max attempts and error handling behavior.
2 Fallback agent configuration Configure backup agents that activate when a primary agent fails, enabling resilient multi-agent workflows that degrade gracefully under failure conditions.
3 Timeout per task Set maximum execution time limits on individual tasks to prevent long-running agents from blocking crew workflows.
4 Circuit breaker for tool calls Prevent cascading failures in multi-agent systems by stopping tool invocations when a threshold of errors is reached.
5 Partial crew success handling Implement graceful degradation when some crew tasks fail while others succeed, extracting partial results without cascading failure.
6 Idempotent crew execution Design crews to produce identical results regardless of retries or repeated execution, protecting against duplicate work and state corruption.
7 State recovery after failure Capture and restore crew execution state when tasks fail, so you can resume from the last successful point instead of restarting from scratch.
6 Production Deployment 7
1
Crew as a FastAPI endpoint Expose a CrewAI workflow as a stateless HTTP endpoint that accepts inputs, runs the crew asynchronously, and returns results.
2 Queue-based crew execution Execute crew tasks asynchronously using a queue system to decouple task submission from execution and handle long-running operations without blocking.
3 Horizontal scaling of crews Distribute crew execution across multiple processes or machines to handle high-concurrency workloads without blocking.
4 Shared LLM connection pool Reuse a single LLM instance across multiple agents to reduce memory overhead and connection churn in production crews.
5 Memory store as shared service Share a single memory store across multiple agents to enable persistent cross-agent context and reduce redundant knowledge storage.
6 Monitoring crew health Track crew execution metrics, agent performance, and task completion rates to detect bottlenecks and failures in production systems.
7 Cost optimization at scale Reduce LLM token spend by 40-70% through intelligent agent caching, batch processing, and model routing without sacrificing output quality.
7 CrewAI Enterprise and Ecosystem 7
1
CrewAI Enterprise: what it adds CrewAI Enterprise extends the open-source framework with deployment, observability, and multi-tenant governance features for production teams.
2 Cloud deployment via CrewAI platform Deploy a multi-agent CrewAI system to the CrewAI Cloud platform and manage agent execution across distributed infrastructure.
3 Dashboard for crew monitoring Build a real-time monitoring dashboard that tracks agent execution state, task progress, and callback events as a crew runs.
4 YAML-based crew definition in production Define crews declaratively in YAML files to decouple configuration from code and enable runtime agent/task management without redeployment.
5 Team management and access control Control who can view, modify, and execute agents and tasks in multi-user CrewAI deployments using role-based access control and team hierarchies.
6 MCP tool integration with crews Connect Model Context Protocol servers as tools to crewai agents for standardized, stateful tool access across crew workflows.
7 Migration from 0.x to 1.x Upgrade your crews from crewai 0.x to 1.x by updating agent instantiation, task definitions, and crew execution patterns.