CrewAI Guide: Role-Based Agent Teams from Prototype to Production
CrewAI organises AI agents the way a manager organises people: each agent gets a job title, an objective and some background, and the team works through a list of assignments. For the general pattern behind this, see the guide to multi-agent systems. That mental model makes it quick to get a multi-agent prototype running. Getting the same system into production is a different exercise, and that is what most of this guide is about. Everything below reflects CrewAI 1.15.41, checked in November 2026.
What is CrewAI?
CrewAI is an open-source Python framework for coordinating several AI agents. You define agents by role, goal and backstory, give them tasks with an expected output, and group them into a crew. Flows wrap crews and control the application with events and shared state. Typical uses are research, analysis and document work.
The GitHub repository describes CrewAI as a standalone Python framework with its own primitives for agents, tasks, crews, flows, tools and orchestration. PyPI lists it under the MIT License, with 1.15.41 released on 12 November 2026 as the current stable version and support for Python 3.10 to 3.13.
Common first projects:
- Research briefs: one agent gathers material, another turns it into a short report for a decision-maker.
- Request triage: one agent extracts requirements from an incoming enquiry, a second checks for gaps and contradictions.
- Document review: inspection reports, delivery notes or support tickets are read and turned into structured data.
- Drafting with review: a writer agent produces a draft and a reviewer agent checks it against a checklist.
If you are still choosing between CrewAI, LangGraph, AutoGen and the agent SDKs from model vendors, start with our comparison of AI agent frameworks. That article helps you pick a framework; this one explains how CrewAI works once you are considering it seriously.
How does CrewAI work?
CrewAI has five building blocks: agents, tasks, crews, processes and Flows. An agent is a role with a goal; a task is a unit of work with a defined expected output; a crew combines both; the process decides execution order; and a Flow controls the wider application with events, routing and persistent state.
Agents
The agents documentation makes three fields mandatory. role defines the agent's function and expertise, goal guides its decisions, and backstory adds context and personality. The optional fields you will touch most often:
llmselects the model for this agent.toolslists the capabilities it may use; empty by default.allow_delegationlets it hand work to other agents; off by default.max_itercaps the number of iterations before it must return its best answer; 20 by default.reasoningmakes it plan before acting; off by default.
The built-in allow_code_execution option is now marked as deprecated. The documentation points to sandbox services such as E2B or Modal instead.
Tasks
A task needs a description and an expected_output, according to the tasks documentation. For anything beyond a demo, four further fields matter:
contextfeeds the outputs of earlier tasks into this one.output_pydanticoroutput_jsonforces structured output against a Pydantic model.guardrailis a function that validates the output before the crew moves on.human_inputasks a person to review the agent's final answer; off by default.
Most quality problems trace back to a vague expected_output; for safeguards beyond CrewAI itself, see guardrails for AI agents. Write it like a work instruction for a new colleague: format, fields, what counts as done.
Crews and processes
The processes documentation describes two options. A sequential process runs tasks in the listed order, with each output available as context for the next. A hierarchical process puts a manager agent in charge of planning, delegating and validating; tasks are not pre-assigned, and you must supply either a manager_llm or a manager_agent.
A minimal sequential crew:
from crewai import Agent, Task, Crew, Process, LLM
# Always include the provider prefix in the model name
llm = LLM(model="anthropic/claude-sonnet-4-6")
extractor = Agent(
role="Enquiry analyst",
goal="Capture every requirement in a customer enquiry",
backstory="You have handled inbound enquiries for years and know where they are usually incomplete.",
llm=llm,
)
reviewer = Agent(
role="Quality reviewer",
goal="Find missing information and contradictions",
backstory="You check paperwork before it goes to sales.",
llm=llm,
)
extract = Task(
description="Enquiry: {enquiry}. List all requirements.",
expected_output="Bullet list of requirements with quantities and dates",
agent=extractor,
)
review = Task(
description="Check the requirement list for gaps.",
expected_output="List of open questions for the customer",
agent=reviewer,
context=[extract],
)
crew = Crew(agents=[extractor, reviewer], tasks=[extract, review], process=Process.sequential)
print(crew.kickoff(inputs={"enquiry": "200 enclosures, powder-coated, delivery in week 10"}))
Flows
The introduction calls Flows the backbone of an application: structured, event-driven workflows that manage state and control execution. Crews are the units of work inside them. The Flows documentation lists the controls:
@start()marks entry points.@listen()runs a method when another one finishes.or_()andand_()trigger on any or all of several methods.@router()branches on a method's output.@persistsaves state automatically, with SQLite as the default backend, so runs can be resumed.@human_feedback, available from version 1.8.0, pauses the flow for a person's decision.
State can be a free-form dictionary or a typed Pydantic model. For production, use the typed model; mistakes show up at the boundary instead of three steps later.
from pydantic import BaseModel
from crewai.flow.flow import Flow, start, listen, router
class EnquiryState(BaseModel):
text: str = ""
class EnquiryFlow(Flow[EnquiryState]):
@start()
def load(self):
self.state.text = "200 enclosures, delivery in week 10"
@router(load)
def check(self):
# a crew or a plain rule could decide here
return "complete" if "week" in self.state.text else "clarify"
@listen("complete")
def hand_over(self):
return "pass to quotation"
@listen("clarify")
def ask(self):
return "draft a question to the customer"
EnquiryFlow().kickoff()
What makes CrewAI different?
CrewAI's distinguishing idea is the role-and-task metaphor. Instead of modelling a state graph node by node, you describe colleagues and assignments in plain language. That lowers the barrier for domain experts and makes the first working prototype quick. Flows then add the deterministic control that an autonomous crew lacks on its own.
The metaphor pays off in two ways. Existing team workflows map almost directly onto agents and tasks: whoever checks an enquiry today becomes one agent, whoever double-checks becomes another. And because roles and goals are written in natural language, people outside engineering can read them, comment on them and suggest changes.
Graph-based frameworks such as LangGraph take the opposite route: explicit nodes, edges and state, more upfront work, finer control over every transition. Flows have narrowed that gap for CrewAI. For a structured side-by-side look, see the framework comparison.
Configuration in files
According to the quickstart, new projects describe crews in JSONC: one file per agent under agents/ and a crew.jsonc listing agents, tasks and the process. The classic layout with config/agents.yaml, config/tasks.yaml and a @CrewBase class is still supported and can be generated with crewai create crew <name> --classic. Either way, prompts live outside the Python code, which makes them easier to review and version.
Where CrewAI fits: three patterns
There are three practical ways to use CrewAI: a standalone crew for a contained knowledge task, a Flow with embedded crews for a business process with fixed stages, and a Flow calling single agents for lightweight steps. Pick by how much predictability the process demands, not by how many agents you can imagine.
Standalone crew. Two to four agents handle a bounded job such as a market scan, a summary of a technical standard or the analysis of an inspection report. A person uses the output. This is the right shape for prototypes and for work that does not change any system of record.
Flow with embedded crews. The Flow models the process, for example enquiry received, checked, quotation drafted, approved, and only some steps call a crew. This is the pattern the documentation recommends for applications, and the one we would use for agents in quoting, technical service or sales. Typical examples are described on our page about AI agents for business processes, for instance quotation agents.
Flow with single agents. Not every step needs a team. The Flows documentation notes that individual agents can run directly inside a Flow. That means fewer model calls and more predictable behaviour.
A hands-on tutorial for a first crew and a direct LangGraph-versus-CrewAI comparison are planned for this topic and will appear in the article list below once published.
What do you need before you start?
Technically: Python 3.10 to 3.13, the uv package manager and access to a language model. Organisationally: one well-described process with an output someone can check, access to the data the agents need, and a named person who signs off results. Without the second half, the first half produces impressive demos and little else.
Tooling. The repository recommends installing the CLI with uv tool install crewai. Create a project with crewai create crew <name>, install dependencies with crewai install, and run it with crewai run.
Models. The LLM documentation lists native SDK integrations for OpenAI, Anthropic, Google Gemini, Vertex AI, Azure, AWS Bedrock and Snowflake Cortex. Everything else, including Ollama, Mistral and NVIDIA NIM, goes through LiteLLM and needs the crewai[litellm] extra. Model names always carry a provider prefix, such as anthropic/claude-sonnet-4-6. Local models make it possible to keep data on your own hardware; our page on sovereign AI covers the wider architecture.
Memory. Setting memory=True on a crew makes it extract facts after each task and recall them before the next, according to the memory documentation. Storage defaults to LanceDB under ./.crewai/memory. The default embedder is OpenAI's text-embedding-3-large, so memory sends text to OpenAI unless you configure a local embedder, for example one served by Ollama.
Telemetry. CrewAI collects telemetry. The repository states that you can switch it off by setting OTEL_SDK_DISABLED to true. Make that a deliberate, documented decision in any company deployment.
Process clarity. Before writing code, answer four questions in one sentence each: what triggers the process, what it produces, how you recognise a good result, and who approves it.
A step-by-step path to production
Move from idea to production in five steps: pick and document one process, sketch it as a Flow, use agents or crews only where judgement is needed, add guardrails and approvals, then measure against real cases. Expand only after a step has run reliably on real data, not after it worked once in a demo.
- Pick a process. Choose something text-heavy with a clear acceptance test, such as pre-checking enquiries or summarising support tickets. Collect 20 to 30 real examples together with what a person produced from them.
- Sketch the Flow. Map the stages to
@start,@listenand@router. Mark which stages are fixed rules and which need judgement. - Use crews sparingly. Fixed rules stay as ordinary Python. Stages that need judgement get one agent, or a small crew if separate perspectives genuinely help. Write
expected_outputas precisely as a work instruction. - Add safeguards. Use
output_pydanticfor structure,guardrailfor checks, andhuman_inputor@human_feedbackwherever a mistake would be costly. Use@persistso runs are traceable and resumable. - Measure. Run your collected examples and compare them with the human results. Record the types of error, not just a pass rate. Only then add tools or more agents.
In our own operations, the pattern that held up was to start with a single agent inside a Flow and add a second one only when a clearly distinct role was missing, typically an independent reviewer. Each extra agent adds model calls and another place where behaviour can drift.
Limits and risks
CrewAI's speed comes from autonomy, and autonomy is hard to predict. Pure crews can loop, read tasks differently from run to run and drive up cost. Default settings send data to cloud services, and the framework changes quickly. Regulated or audit-heavy processes need Flows, guardrails and human approval, not a free-running crew.
Predictability. Role and backstory are prompt text. Small edits, or a model change, can shift behaviour noticeably. The hierarchical process adds a further layer of variation because the manager agent decides who does what. Where a process must run the same way every time, use the sequential process or a Flow with fixed stages.
Cost and latency. Every agent, every delegation and every iteration up to max_iter means model calls. A four-agent crew with delegation enabled can make many times the calls of a single agent. Cap iterations and log calls from the first day.
Data flows. Out of the box, memory uses OpenAI embeddings and telemetry is on. Review both before confidential data enters the system. With local models and a local embedder, CrewAI can run without external services; whether a given set-up can be operated in line with the GDPR or your sector's rules depends on the whole architecture and is not legal advice.
Release pace. Recommendations and interfaces change between versions: built-in code execution is now deprecated, and new projects use JSONC rather than YAML. Pin the version in pyproject.toml and schedule upgrades rather than taking them implicitly.
Tool permissions. An agent with write access to your ERP or mailbox can do real damage. Grant tools per task (the task-level tools parameter limits the agent to those tools) and put an approval step in front of anything that leaves the building.
When not to use it. If your use case is essentially one model call with a tool or two, a multi-agent framework is overhead. If you need to model and audit every state transition explicitly, a graph-based framework may fit the requirement more closely.
How to get started
Start with one well-described process, scaffold a project with crewai create flow, and build a Flow with a single agent first. Add roles only once that step runs reliably on real examples. Decide early on the model provider, the memory embedder and telemetry, because those choices determine where your data goes.
A realistic first fortnight:
- Install with
uv tool install crewaiand scaffold a Flow project as shown in the quickstart. - Choose a model: a hosted model for the prototype, or a local one through Ollama if your data requires it.
- Write one agent with a precise role and one task with a concrete
expected_output. - Run 20 real cases and record where results differ from what a person would have done.
- Then add a second agent, guardrails, an approval step and persistence.
If you have not settled on a framework yet, read the AI agent framework comparison first. Once CrewAI is the choice, the harder questions are about the business side: which process, which data, which approvals. Examples of such processes are collected on the page about AI agents for sales, service and quoting.
Frequently asked questions
Is CrewAI free to use?
The framework is released under the MIT License according to PyPI. You pay for the language models you call and, optionally, for the commercial AMP Suite for managed deployment and governance.
Can CrewAI run fully offline?
Yes, if you point both the LLM and the memory embedder at local models, for example through Ollama. The default memory embedder is an OpenAI model, so this needs explicit configuration.
Which Python versions does CrewAI support?
PyPI lists Python 3.10 up to, but not including, 3.14 for version 1.15.41 (checked November 2026).
Should I start with a crew or a Flow?
The CrewAI documentation recommends starting with a Flow as the backbone and adding a crew only for steps that genuinely need several agents collaborating.
Sources
- CrewAI Documentation: Introduction docs.crewai.com
- CrewAI Documentation: Agents docs.crewai.com
- CrewAI Documentation: Tasks docs.crewai.com
- CrewAI Documentation: Processes docs.crewai.com
- CrewAI Documentation: Flows docs.crewai.com
- CrewAI Documentation: LLMs docs.crewai.com
- CrewAI Documentation: Memory docs.crewai.com
- CrewAI Documentation: Quickstart docs.crewai.com
- crewai on PyPI pypi.org
- crewAIInc/crewAI on GitHub github.com