Skip to content

CrewAI Architecture and Workflow Diagrams


  1. Architecture Overview
  2. Agent Lifecycle
  3. Process Flows
  4. Task Execution Patterns
  5. Collaboration Patterns
  6. Memory Systems
  7. Tool Integration

┌─────────────────────────────────────────────────────────────┐
│ CREWAI SYSTEM │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ CREW │ │
│ │ ┌──────────────────────────────────────────────┐ │ │
│ │ │ Process (Sequential/Hierarchical) │ │ │
│ │ └──────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ │ │
│ │ │ Agent 1 │ │ Agent 2 │ │ Agent N │ │ │
│ │ └────────────┘ └────────────┘ └────────────┘ │ │
│ │ │ │
│ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ │ │
│ │ │ Task 1 │ │ Task 2 │ │ Task N │ │ │
│ │ └────────────┘ └────────────┘ └────────────┘ │ │
│ │ │ │
│ │ ┌──────────────────────────────────────────────┐ │ │
│ │ │ Memory (Short & Long-term) │ │ │
│ │ └──────────────────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────┐
│ AGENT │
├──────────────────────────────────────────────────────┤
│ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Role, Goal, Backstory │ │
│ │ (Define Agent Identity & Specialisation) │ │
│ └───────────────────────────────────────────────┘ │
│ ↓ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Language Model Instance (LLM) │ │
│ │ (Provides reasoning capability) │ │
│ └───────────────────────────────────────────────┘ │
│ ↓ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Tools Array │ │
│ │ (Enables external actions) │ │
│ └───────────────────────────────────────────────┘ │
│ ↓ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Memory System │ │
│ │ (Stores context & learning) │ │
│ └───────────────────────────────────────────────┘ │
│ ↓ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Decision Engine │ │
│ │ (Determines actions based on context) │ │
│ └───────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────┘

START
┌─────────────────────────────┐
│ 1. Define Agent │
│ - role │
│ - goal │
│ - backstory │
│ - llm (model) │
│ - tools │
└─────────────────────────────┘
┌─────────────────────────────┐
│ 2. Define Tasks │
│ - description │
│ - expected_output │
│ - agent assignment │
└─────────────────────────────┘
┌─────────────────────────────┐
│ 3. Create Crew │
│ - agents │
│ - tasks │
│ - process (seq/hier) │
│ - settings │
└─────────────────────────────┘
┌─────────────────────────────┐
│ 4. Kickoff Execution │
│ crew.kickoff() │
└─────────────────────────────┘
┌─────────────────────────────┐
│ 5. Task Processing │
│ ├─ Agent receives task │
│ ├─ Reviews context │
│ ├─ Makes decisions │
│ └─ Uses tools if needed │
└─────────────────────────────┘
┌─────────────────────────────┐
│ 6. Output Generation │
│ ├─ Format output │
│ ├─ Validate result │
│ └─ Store in memory │
└─────────────────────────────┘
END (Return Result)

Task 1 (Agent A)
└─→ Output 1
├─→ Task 2 (Agent B)
│ ↓
│ └─→ Output 2
│ ↓
│ ├─→ Task 3 (Agent C)
│ │ ↓
│ │ └─→ Output 3
│ │ ↓
│ │ END
Memory (Shared Context)

Characteristics:

  • Linear execution
  • Each task uses previous output
  • Suitable for dependent tasks
  • Context naturally flows between agents
┌──────────────┐
│ MANAGER │
│ (LLM) │
└──────────────┘
┌─────────┼─────────┐
↓ ↓ ↓
┌────────────┐ ┌──────────┐ ┌────────────┐
│ Agent 1 │ │ Agent 2 │ │ Agent 3 │
│ Task 1 │ │ Task 2 │ │ Task 3 │
└────────────┘ └──────────┘ └────────────┘
↓ ↓ ↓
└─────────┼─────────┘
┌─────────────────────────┐
│ Manager Reviews Results │
│ & Coordinates Response │
└─────────────────────────┘
END

Characteristics:

  • Manager agent orchestrates
  • Parallel/flexible execution
  • Manager decides task order
  • Better for complex workflows

Pattern 1: Sequential Analysis & Synthesis

Section titled “Pattern 1: Sequential Analysis & Synthesis”
┌─────────────┐
│ Researcher │ ← Gathers information
│ Agent │
└─────────────┘
[Output: Research findings]
┌─────────────┐
│ Analyst │ ← Analyses findings
│ Agent │
└─────────────┘
[Output: Analytical insights]
┌─────────────┐
│ Writer │ ← Synthesises into report
│ Agent │
└─────────────┘
[Final Output: Comprehensive report]
Task Distribution
┌──────────────────┼──────────────────┐
↓ ↓ ↓
┌─────────┐ ┌─────────┐ ┌─────────┐
│Financial│ │ Market │ │Operational│
│ Analyst │ │ Analyst │ │ Analyst │
└─────────┘ └─────────┘ └─────────┘
↓ ↓ ↓
[Financial [Market [Operations
Analysis] Analysis] Analysis]
↓ ↓ ↓
└──────────────────┼──────────────────┘
┌─────────────┐
│ Synthesiser│
│ Agent │
└─────────────┘
[Final Report]
┌──────────────┐
│ Junior Agent │ ← Initial attempt
└──────────────┘
[Initial output]
┌──────────────────┐
│ Quality Check? │
└──────────────────┘
↙ (Pass) ↖ (Needs improvement)
↓ ↓
END ┌─────────────────┐
│ Senior Agent │
│ (Review/refine) │
└─────────────────┘
[Refined output]
┌──────────────────┐
│ Final Approval? │
└──────────────────┘
↙ (Yes) ↖ (No)
↓ ↓
END [Escalate further]

Pattern 1: Researcher → Writer → Editor Flow

Section titled “Pattern 1: Researcher → Writer → Editor Flow”
Researcher Agent
├─ Role: Research Specialist
├─ Goal: Gather comprehensive information
├─ Tools: Search, Scrape, File access
└─ Output: Research findings with citations
Writer Agent
├─ Role: Content Writer
├─ Goal: Create engaging narrative
├─ Uses: Research output as input
├─ Tools: Writing templates, formatting
└─ Output: Drafted article
Editor Agent
├─ Role: Editorial Director
├─ Goal: Ensure quality and accuracy
├─ Uses: Article + original research
├─ Tools: Grammar check, fact verification
└─ Output: Publication-ready article
Workers Report Progress
┌─────────────────────┐
│ Manager Agent │
│ │
│ Decision Logic: │
│ • Receives updates │
│ • Analyses status │
│ • Coordinates flow │
│ • Escalates issues │
└─────────────────────┘
└─ Coordinate next steps
Workers Execute Coordination

┌─────────────────────────────────────────────┐
│ MEMORY SYSTEM │
├─────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────┐ │
│ │ SHORT-TERM MEMORY │ │
│ │ (Current session context) │ │
│ │ │ │
│ │ • Current task information │ │
│ │ • Recent agent outputs │ │
│ │ • Intermediate results │ │
│ │ • Contextual data │ │
│ └──────────────────────────────────────┘ │
│ ↑ │
│ │ │
│ ┌──────────────────────────────────────┐ │
│ │ LONG-TERM MEMORY │ │
│ │ (Persistent storage) │ │
│ │ │ │
│ │ • Previous interactions │ │
│ │ • Learned patterns │ │
│ │ • Historical data │ │
│ │ • Entity relationships │ │
│ └──────────────────────────────────────┘ │
│ ↑ │
│ │ │
│ ┌──────────────────────────────────────┐ │
│ │ ENTITY MEMORY │ │
│ │ (Knowledge graph) │ │
│ │ │ │
│ │ • People entities │ │
│ │ • Place entities │ │
│ │ • Concept entities │ │
│ │ • Relationship mapping │ │
│ └──────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────┘

Agent Task
┌─────────────────────────────┐
│ Tool Selection │
│ (Based on task need) │
└─────────────────────────────┘
├─ File Operations?
│ ├─→ FileReadTool
│ ├─→ FileWriteTool
│ └─→ DirectoryReadTool
├─ Web Operations?
│ ├─→ ScrapeWebsiteTool
│ └─→ SerperDevTool
├─ Custom Logic?
│ └─→ Custom BaseTool
└─ Async Operations?
└─→ AsyncTool
┌─────────────────────────────┐
│ Tool Execution │
│ (With error handling) │
└─────────────────────────────┘
┌─────────────────────────────┐
│ Result Processing │
│ (Parse & validate) │
└─────────────────────────────┘
Return to Agent
Single Agent with Multiple Tools
Agent Instance
├─ Tool 1: Research (Search)
│ └─ For: Information gathering
├─ Tool 2: Web Scraping
│ └─ For: Content extraction
├─ Tool 3: File Operations
│ └─ For: Data persistence
└─ Tool 4: Custom Analysis
└─ For: Specialised processing
Agent Decision: Which tool to use based on task requirements

Input: Topic
┌─────────────────────────┐
│ Research Phase │
│ (1-3 researchers) │
└─────────────────────────┘
[Research findings]
┌─────────────────────────┐
│ Content Creation Phase │
│ (1-2 writers) │
└─────────────────────────┘
[Draft content]
┌─────────────────────────┐
│ Review & Polish Phase │
│ (1-2 editors) │
└─────────────────────────┘
[Final content]
┌─────────────────────────┐
│ Distribution Phase │
│ (Social media manager) │
└─────────────────────────┘
Output: Published & shared
Input: Raw data
┌─────────────────────────┐
│ Data Cleaning │
│ (Data Engineer) │
└─────────────────────────┘
[Cleaned data]
┌─────────────────────────┐
│ Exploratory Analysis │
│ (Data Scientist) │
└─────────────────────────┘
[Insights & patterns]
┌─────────────────────────┐
│ Statistical Analysis │
│ (Statistician) │
└─────────────────────────┘
[Statistical findings]
┌─────────────────────────┐
│ Business Translation │
│ (Business Analyst) │
└─────────────────────────┘
Output: Business recommendations

Agent Decision Making Process
┌──────────────────────────────────────┐
│ Task Input │
│ (Description + context) │
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│ Construct Prompt │
│ • Agent role & backstory │
│ • Task description │
│ • Available tools │
│ • Previous context/memory │
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│ Call LLM │
│ (Language Model) │
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│ Parse LLM Response │
│ • Identify intent │
│ • Extract action/tool │
│ • Get parameters │
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│ Execute Action │
│ • Use tool if needed │
│ • Process result │
│ • Update memory │
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│ Iterate or Return Result │
│ • More steps needed? │
│ • Task complete? │
└──────────────────────────────────────┘

SINGLE AGENT
Simple task execution
┌────────────┐
│ Agent │
│ + │
│ Task │
└────────────┘
↓ (Scale)
MULTI-AGENT (SEQUENTIAL)
Tasks flow through agents
┌────────┐ ┌────────┐ ┌────────┐
│Agent A │→→→│Agent B │→→→│Agent C │
└────────┘ └────────┘ └────────┘
↓ (Scale)
MULTI-AGENT (HIERARCHICAL)
Manager coordinates agents
┌─────────┐
│Manager │
└─────────┘
↙ ↓ ↘
┌────┐ ┌────┐ ┌────┐
│ A │ │ B │ │ C │
└────┘ └────┘ └────┘
↓ (Scale)
ENTERPRISE SYSTEM
Multiple crews, complex workflows
┌──────────────────────────────┐
│ Crew 1 │ Crew 2 │ Crew 3 ...│
├────────────────────────────┤
│ Shared Memory & Resources │
│ Orchestration Layer │
└──────────────────────────────┘

This visual guide provides clarity on CrewAI’s architecture and communication patterns for building effective multi-agent systems.