Navigation

Introduction to AI

Machine Learning

Deep Learning

Generative AI

Tools & Frameworks

General

Multi-Agent AI with CrewAI

CrewAI is an open-source Python framework for orchestrating role-playing, autonomous AI agents that collaborate as a crew to accomplish complex, multi-step tasks. It provides a structured way to define agents, assign them tools, and manage the workflow between them.

Why Multi-Agent Systems?

A single LLM prompt can only go so far. For tasks that require:

  • Multiple specializations (e.g., a researcher, a writer, and a reviewer),
  • Sequential or parallel steps with dependencies,
  • Tool use combined with reasoning across many calls,

…a team of coordinated agents consistently outperforms a single monolithic prompt.

Core Concepts

Agents

An Agent is an autonomous unit with:

  • Role: What the agent is (e.g., "Senior Research Analyst").
  • Goal: What it is trying to achieve (e.g., "Uncover emerging AI trends").
  • Backstory: Additional context that shapes its behavior and reasoning style.
  • Tools: Python functions or integrations the agent can invoke (e.g., web search, file reader).
  • LLM: The underlying model powering the agent (defaults to GPT-4 but configurable).

Tasks

A Task represents a discrete unit of work assigned to an agent:

  • Description: A natural language description of what needs to be done.
  • Expected Output: What a completed result should look like.
  • Agent: The agent responsible for completing the task.

Crew

A Crew assembles agents and tasks and manages execution:

  • Sequential Process: Tasks execute one at a time, each feeding output to the next.
  • Hierarchical Process: A manager agent delegates tasks to worker agents dynamically.

Installing CrewAI

pip install crewai crewai-tools

A Minimal Example

from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool

search_tool = SerperDevTool()

# Define agents
researcher = Agent(
    role="AI Research Analyst",
    goal="Find the latest developments in large language models",
    backstory="You are an expert in AI research with a focus on NLP and LLMs.",
    tools=[search_tool],
    verbose=True,
)

writer = Agent(
    role="Technical Writer",
    goal="Summarize AI research into a clear, engaging article",
    backstory="You are a skilled technical writer who makes complex topics accessible.",
    verbose=True,
)

# Define tasks
research_task = Task(
    description="Search for the top 5 LLM developments in 2025 and summarize key facts.",
    expected_output="A bullet-point list of 5 developments with brief explanations.",
    agent=researcher,
)

write_task = Task(
    description="Using the research, write a 300-word article for a general tech audience.",
    expected_output="A polished article with a title, introduction, and conclusion.",
    agent=writer,
)

# Assemble and run the crew
crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    process=Process.sequential,
    verbose=True,
)

result = crew.kickoff()
print(result)

CrewAI vs. Other Frameworks

FeatureCrewAIAutoGenLangChain Agents
Agent AbstractionRole-basedConversableTool-calling
Orchestration StyleCrew / hierarchicalGroup chatChain / graph
Ease of SetupHighMediumMedium
Built-in Human-in-loopNo (configurable)YesPartial
Best ForStructured workflowsConversational agentsComplex tool chains

Key Features

Memory

Agents can maintain short-term (within a crew run), long-term (across runs via embedding store), entity, and contextual memory — enabling stateful multi-session workflows.

Hierarchical Process

In hierarchical mode, a Manager Agent (automatically created or user-defined) decomposes goals, delegates tasks to worker agents, and validates results before accepting them.

Custom Tools

Any Python function decorated with @tool becomes available to an agent:

from crewai.tools import tool

@tool("Stock Price Fetcher")
def get_stock_price(ticker: str) -> str:
    """Fetches the current stock price for a given ticker symbol."""
    # ... implementation
    return f"{ticker}: $..."

Flow (Stateful Workflows)

CrewAI Flows provide a higher-level event-driven orchestration layer using @start and @listen decorators, enabling branching logic, state persistence, and complex multi-crew pipelines.

When to Use CrewAI

CrewAI is well-suited for:

  • Content pipelines: Research → draft → review → publish.
  • Automated analysis: Data gathering, interpretation, and reporting.
  • Software development workflows: Planning, coding, testing, documentation.
  • Customer support triage: Classification, lookup, and response generation.

For quick single-agent tool use, a lightweight solution like a LangChain agent or direct function calling may be simpler.

Summary

CrewAI provides one of the most intuitive APIs for building structured multi-agent workflows. Its role-based design maps naturally to real-world team dynamics, making it easy to reason about who does what and why. As LLM capabilities grow, frameworks like CrewAI make it practical to decompose ambitious tasks into collaborative agent pipelines that deliver reliable, high-quality outputs.