Agentic Frameworks

CrewAI

CrewAI is the most accessible framework for building multi-agent AI systems. Agents are defined with a role, a goal, and a backstory — just like hiring a team. They collaborate on tasks, pass results between each other, and produce a final output that no single agent could produce alone. It is the fastest path from idea to working multi-agent system.

Agentic Framework Free · Open Source · MIT Python

The hiring analogy — and why it works

CrewAI's central insight is that multi-agent systems map directly onto how human teams work. You hire people with specific roles. Each person has a goal they are trying to achieve in their role. Each person brings a background and perspective that shapes how they approach problems. They work on tasks, pass results to colleagues, and the team produces something none of them could produce alone.

CrewAI makes you define agents exactly this way. Before writing any logic, you define: what is this agent's role? What goal is it trying to achieve? What backstory explains how it approaches problems? These three fields are not decorative — they are fed directly to the LLM as part of the agent's system prompt, and they shape every decision the agent makes.

The four core concepts

Concept 1

Agent

An AI entity with a role, goal, and backstory. Powered by an LLM. Given a set of tools it can use. Defined in Python as a simple object. The role, goal, and backstory shape how it reasons and responds.

Concept 2

Task

A specific piece of work assigned to an agent. Has a description (what to do), an expected output (what a successful result looks like), and is assigned to one agent. Tasks can pass their output to the next task automatically.

Concept 3

Crew

The assembled team — a list of agents and a list of tasks. You define whether they work sequentially (one after another) or hierarchically (one agent manages the others). You call crew.kickoff() to start.

Concept 4

Tool

A capability an agent can use during its task — web search, file reading, code execution, API calls. CrewAI has built-in tools and integrates with LangChain tools. Tools are assigned to specific agents, not to the whole crew.

A real example — content research crew

Say you want a crew that researches a topic and writes a structured article. You define three agents:

  • Senior Research Analyst — role: researcher, goal: find accurate and recent information, backstory: experienced at identifying reliable sources
  • Content Writer — role: writer, goal: produce clear and engaging content, backstory: skilled at turning research into readable articles
  • Editor — role: editor, goal: ensure accuracy and quality, backstory: meticulous about factual claims and structure

You define two tasks: Research (assigned to the analyst, with web search tool enabled) and Write (assigned to the writer, with the research output passed in automatically). The crew runs sequentially — research first, then writing. The editor reviews the output. You call crew.kickoff(inputs={"topic": "agentic AI in 2026"}) and receive the finished article.

Why choose CrewAI: You want to build a multi-agent system and you want to be running in hours, not days. You do not need the full complexity of LangGraph. You are prototyping a workflow or your team is non-technical. CrewAI is the fastest path to a working multi-agent system.

What it costs

CrewAI is free and open source under the MIT licence. You pay only for the underlying LLM API calls (OpenAI, Anthropic, Google, or any other provider). CrewAI Enterprise — with additional features for deployment, monitoring, and team management — is available at custom pricing for organisations.

How sequential and hierarchical process modes work

CrewAI supports two process modes, set on the Crew object:

Sequential — tasks run in the order they are listed. The output of each task is automatically passed as context to the next task. Simple, predictable, easy to debug. Suitable for most use cases where work has a natural order.

Hierarchical — a manager LLM (either a specified agent or automatically created) coordinates the crew. The manager breaks the goal into tasks, assigns them to agents, evaluates outputs, and decides when the goal is achieved. More flexible, more expensive (extra model calls for the manager), suitable for open-ended goals where the task breakdown is not known in advance.

Prompts for building and working with CrewAI

Use these with Claude, ChatGPT, or any capable model when building with CrewAI.

Getting started

Design a crew for my use case
I want to build a CrewAI crew that [describe your goal — e.g. "researches a company and produces a sales brief"]. Design the agents I need — give each one a role, goal, and backstory. Define the tasks they should complete. Tell me whether sequential or hierarchical process mode is more appropriate and why.
Write the full Python code for a crew
Write complete Python code for a CrewAI crew that does the following: [describe the workflow]. Use the latest CrewAI syntax. Define all agents with role, goal, and backstory. Define all tasks with description and expected_output. Assign tools where appropriate — use SerperDevTool for web search. Run the crew with crew.kickoff() and print the result.
Write an agent with custom tools
I need a CrewAI agent that can read files from a local directory and summarise their contents. Show me how to create a custom tool that reads a file given its path, how to register it with CrewAI's @tool decorator, and how to assign it to an agent. Include error handling if the file doesn't exist.

Specific workflows

Research and report crew
Build a 3-agent CrewAI crew: a researcher (uses web search), an analyst (identifies key insights from the research), and a report writer (produces a structured markdown report). The topic is passed as input. Tasks run sequentially. Use Claude claude-sonnet-4-20250514 as the LLM for all agents. Show the full code including imports and crew.kickoff().
Sales prospecting crew
Build a CrewAI crew that takes a company name as input and produces a sales brief. It should include: a company researcher (finds recent news, funding, and size), a product fit analyst (identifies how our product could help based on what the researcher found), and a brief writer (formats everything into a 1-page sales brief). Define all agents, tasks, and the crew. Include web search for the researcher.
Code review crew
Build a CrewAI crew that reviews Python code. Agents: a security reviewer (checks for security vulnerabilities), a performance reviewer (checks for inefficiencies and suggests improvements), and a documentation reviewer (checks for missing docstrings and unclear variable names). Each agent reviews independently. A lead reviewer agent synthesises the findings into a final report. Show the full implementation.
Social media content crew
Build a CrewAI crew that takes a blog post as input and produces social media content. Agents: a content strategist (identifies the 3 most shareable insights), a LinkedIn writer (writes a professional post with the insights), a Twitter/X writer (writes 5 tweets forming a thread). Sequential process. The blog post text is passed in via kickoff inputs.

Debugging and improving

Debug a crew that's not producing good output
My CrewAI crew keeps producing [describe the problem — e.g. "generic answers that don't use the web search results"]. Here is my crew definition: [paste code]. Diagnose what is going wrong. Is it the agent's goal definition? The task description? The tool assignment? The expected_output field? Give me specific fixes to try.
Improve agent role definitions
My CrewAI agents are not performing as expected. Here are their current role, goal, and backstory definitions: [paste]. Rewrite these to be more specific and directive. The agents should produce [describe desired output]. Make the goal fields measurable and specific. Make the backstories explain exactly how the agent should approach its work.
Add verbose logging to a crew
Show me how to enable verbose logging in CrewAI so I can see what each agent is thinking, what tools it is calling, and what outputs it produces at each step. I want to see the full trace in the terminal. Also show me how to capture this output to a file for later analysis.
Pass structured output between tasks
I want my first CrewAI task to produce a structured JSON output (a list of objects with specific fields) and my second task to consume that structured output reliably. Show me how to use Pydantic output models in CrewAI tasks to enforce the output format, and how the second agent receives and uses the parsed output.
Compare CrewAI vs LangGraph for my use case
I want to build [describe your workflow]. Help me decide between CrewAI and LangGraph. For my specific use case, what are the concrete advantages and disadvantages of each? Which would you recommend and why? If I start with CrewAI, what would be the migration path to LangGraph if I need more control later?

How CrewAI constructs agent system prompts

Understanding CrewAI at the code level requires understanding that role, goal, and backstory are not metadata — they are injected directly into the agent's system prompt. CrewAI constructs each agent's system prompt as a formatted string that includes these fields, the list of available tools with their descriptions, and the current task description.

This means the quality of role/goal/backstory definitions directly affects agent performance. Vague role definitions produce vague reasoning. Specific, directive definitions produce focused, high-quality outputs. Writing effective agent definitions is the primary skill in CrewAI development — more impactful than any code change.

Task context and output chaining

In sequential process mode, each task's output is stored in a TaskOutput object. By default, subsequent tasks receive the previous task's raw output as context. This can be explicitly controlled using the context parameter on a Task, which specifies exactly which prior tasks' outputs are passed as context — useful when a downstream task needs output from task 1 but not task 2.

Structured output can be enforced using Pydantic models via the output_pydantic parameter on a Task. CrewAI instructs the LLM to produce JSON matching the schema and parses the response into the specified Pydantic model. This enables reliable structured data passing between tasks — the receiving agent gets a typed object, not raw text.

Hierarchical process and the manager LLM

In hierarchical mode, CrewAI creates a manager agent whose system prompt includes the full list of available agents and their capabilities. The manager LLM receives the goal, decides which agent to call first, calls it, receives the result, decides on the next step, and continues until the goal is achieved or the maximum iterations limit is reached. The manager is backed by the same LLM as the other agents by default, but can be configured separately — using a more capable (and more expensive) model for the manager while using cheaper models for workers is a common production pattern.

Memory types in CrewAI

CrewAI supports four memory types, all optional:

  • Short-term memory — conversation history within the current crew run. Stored in a RAG system; relevant chunks retrieved at each step rather than the full history.
  • Long-term memory — persists across crew runs. Stored in a local SQLite database by default. Agents can recall relevant context from previous runs.
  • Entity memory — tracks entities (people, organisations, concepts) mentioned across the crew run. Enables consistent reference to entities across many steps.
  • Contextual memory — combines all memory types to produce a unified context for each agent step.

Memory is enabled at the Crew level with memory=True. It requires an embedding model (OpenAI's text-embedding-3-small by default).

Tool integration — built-in and custom

CrewAI ships with a built-in tools library including web search (Serper, Tavily), file operations, web scraping, and code execution. Tools are assigned to agents via the tools parameter. Custom tools are created by subclassing BaseTool or using the @tool decorator. LangChain tools are also directly compatible — any LangChain tool object can be passed in the tools list.

CrewAI vs LangGraph — the technical tradeoffs

CrewAI abstracts the agent loop entirely — developers define agents and tasks, and CrewAI handles the planning, tool calling, and output chaining. This makes development faster but control less granular. LangGraph exposes the graph structure directly — developers define every node and edge, enabling precise control over flow but requiring more code.

CrewAI is the better choice for: rapidly prototyping multi-agent workflows, teams with limited Python experience, workflows with clear sequential task structures. LangGraph is the better choice for: complex conditional workflows, workflows requiring checkpointing and resumption, and production systems requiring full observability and fine-grained control.

The two are not mutually exclusive — CrewAI can be integrated into a LangGraph graph as a node, enabling hybrid architectures where the orchestration layer uses LangGraph and specialist multi-agent sub-tasks use CrewAI.

Official documentation and resources

Source note: All technical specifications are drawn from the official CrewAI documentation at docs.crewai.com and the CrewAI GitHub repository. Verified April 2026.