v0.30.0
Commit c1a2e3b
Verified: 2026-07-29·crewAIInc/crewAI
Chapters:
100%
1. Crew.kic...2. Decompos...3. Assign T...Crew KickoffactorUser TaskRequestkernelHierarchicalCrew ManagerprocessTask DAGDecomposerboundaryWorker AgentAssigner
Step Execution TraceStep 1 of 4

#1Step 1.1 — Crew Instantiation & Process Mode Configuration

Developer instantiates Crew object with explicit agents, tasks, process mode (Process.hierarchical), and manager LLM config.

Live State Inspector4 variables
PROCESS_MODE
Process.hierarchical
AGENTS_COUNT
2
TASKS_COUNT
2
MANAGER_LLM
gpt-4o
crewai/crew.py(L45-L95)
pythonGitHub
# crewai/crew.py - Crew Instantiation
from crewai import Agent, Crew, Process, Task

researcher = Agent(role="Senior Researcher", goal="Uncover AI breakthroughs", backstory="World-class AI analyst")
writer = Agent(role="Tech Writer", goal="Synthesize technical reports", backstory="Veteran tech journalist")

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    process=Process.hierarchical,
    manager_llm=ChatOpenAI(model="gpt-4o")
)
result = crew.kickoff(inputs={"topic": "Agentic AI Architecture"})
Inspector
Click any component node in the diagram to inspect its source location, evidence classification, and implementation metrics.
Verified System Claims
#crewai-hierarchical-manager
verified

CrewAI Manager Agent orchestrates multi-agent task DAGs, dynamically delegating sub-tasks to specialized worker agents based on role capabilities.

#crewai-memory-rag-search
verified

3-tier memory engine integrates Short-Term Memory, Long-Term Memory (ChromaDB vectors), and Entity Memory (SQLite) for cross-task context retrieval.

#crewai-react-tool-sandbox
verified

Worker agents execute ReAct loops with Pydantic tool schema validation, isolating tool calls within structured execution sandboxes.

#crewai-task-output-pipeline
verified

TaskOutput pipeline validates agent outputs against Pydantic models/JSON schemas, chaining immutable output records into downstream tasks.

System breakdown

Inside CrewAI Multi-Agent Task Execution & Memory Orchestration Engine

An evidence-audited, 4-chapter interactive system breakdown deconstructing CrewAI's Hierarchical Manager planning pipeline, 3-tier RAG memory architecture (ChromaDB vector embeddings + SQLite entity knowledge graphs), ReAct worker agent execution loops with Pydantic tool sandboxing, and structured TaskOutput validation pipelines.

32 min read Verified 2026-07-29 1 primary sources

Inside CrewAI: Architecture Teardown of the Multi-Agent Orchestration Engine

CrewAI is an open-source framework designed to orchestrate teams of autonomous AI agents working collaboratively to solve complex engineering goals. Rather than treating agents as isolated chat bots, CrewAI models them as specialized roles with distinct goals, backstories, tools, 3-tier RAG memory, and structured task output pipelines.

This 4-chapter interactive system breakdown deconstructs CrewAI's internal execution architecture: Kickoff & Hierarchical Planning, 3-Tier RAG Memory Retrieval, ReAct Tool Sandboxing, and TaskOutput Pipelining.


Chapter 1: Crew Kickoff & Hierarchical Manager Planning

At the core of CrewAI is the Crew object. Developers define a team of Agent objects and a list of Task objects, configuring the execution strategy (Process.sequential vs Process.hierarchical).

from crewai import Agent, Crew, Process, Task

researcher = Agent(role="Senior Researcher", goal="Uncover AI breakthroughs", backstory="World-class AI analyst")
writer = Agent(role="Tech Writer", goal="Synthesize technical reports", backstory="Veteran tech journalist")

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    process=Process.hierarchical,
    manager_llm=ChatOpenAI(model="gpt-4o")
)
result = crew.kickoff(inputs={"topic": "Agentic AI Architecture"})

Hierarchical Task Decomposition & Delegation

When process=Process.hierarchical is enabled, a specialized ManagerAgent takes control of the execution pipeline:

  1. Goal Decomposition: The Manager analyzes the input goal and breaks it down into a structured task dependency graph (DAG).
  2. Role Matching: The Manager evaluates each worker agent's role, goal, and backstory to match tasks with the most qualified agent.
  3. Prerequisite Validation: The system ensures all required upstream task outputs are bound into the downstream task's execution context string before triggering worker execution.

Chapter 2: 3-Tier Agent Memory Retrieval Engine (ChromaDB & SQLite)

To prevent agents from repeating past mistakes and to enable cross-task knowledge retrieval, CrewAI implements a 3-tier RAG memory architecture:

                          ┌──> [ Short-Term Memory ] (Sliding Window Thread Buffer)
                          │
 [ Agent Memory Query ] ──┼──> [ Long-Term Memory  ] (ChromaDB Vector Embeddings)
                          │
                          └──> [ Entity Memory     ] (SQLite Knowledge Graph)

The 3 Memory Tiers

  1. Short-Term Memory: In-memory sliding window buffer holding immediate task outputs and conversation context from the active Crew run.
  2. Long-Term Memory: Vector database backed by ChromaDB. Stores historical task execution insights and embeddings, allowing agents to perform semantic RAG searches across past Crew runs.
  3. Entity Memory: Relational SQLite database tracking subject-predicate-object relationships (e.g. (vLLM) --[implements]--> (PagedAttention)), allowing agents to perform structured knowledge graph lookups.

Chapter 3: ReAct Task Execution Loop & Pydantic Tool Sandboxing

Worker agents execute assigned tasks via an iterative ReAct (Reasoning + Acting) loop:

 [ Thought ] ──> [ Action: Tool Selection ] ──> [ Pydantic Schema Validation ] ──> [ Tool Sandbox ] ──> [ Observation ]

Pydantic Tool Sandboxing & Validation

Before executing custom Python tools (e.g., Web Search, Database Query, Code Execution), CrewAI validates the LLM's Action Input string against a Pydantic args_schema model:

# crewai/tools/tool_calling.py - Pydantic Tool Validation
class SearchWebSchema(BaseModel):
    query: str = Field(..., description="Search query string")
    max_results: int = Field(default=5, description="Max result count")

class ToolCalling:
    def run(self, tool: Tool, action_input: Dict[str, Any]) -> str:
        validated_args = tool.args_schema(**action_input)
        return tool._run(**validated_args.dict())

If argument validation fails, the sandbox catches the exception and returns a structured error message to the agent's observation buffer, prompting the agent to self-correct its tool arguments.


Chapter 4: Task Output Pipelining & Crew Aggregation

When an agent completes a task, raw text is transformed into an immutable TaskOutput record:

# crewai/tasks/task_output.py
class TaskOutput(BaseModel):
    description: str
    name: Optional[str] = None
    expected_output: Optional[str] = None
    raw: str = ""
    pydantic: Optional[BaseModel] = None
    json_dict: Optional[Dict[str, Any]] = None
    agent: str

Structured Output Enforcement & Chaining

  • Pydantic Validation: If a task specifies output_pydantic=ReportModel, the output pipeline parses raw text into a validated Pydantic model instance.
  • Context Chaining: The completed TaskOutput object is automatically appended to the context list of downstream tasks in the execution DAG.
  • Final CrewOutput Delivery: At the conclusion of all tasks, Crew returns a unified CrewOutput object containing raw text, Pydantic models, JSON dicts, and token usage metrics across all LLM calls.

Summary Architecture Comparison

| Dimension | LangGraph (Pregel) | AutoGen (Conversational) | CrewAI (Role-Based) | |---|---|---|---| | Orchestration Model | StateGraph Superstep Loop | Conversational Agent Mesh | Hierarchical / Sequential Role DAG | | Memory System | Thread Checkpointers | Conversation History | 3-Tier RAG (ChromaDB + SQLite) | | Tool Execution | Async ToolNode | Function Calling | Pydantic Schema Sandboxing | | Output Pipeline | Channel Reducers | Message Stream | Structured TaskOutput Pipelining |