# Multi-Agent Framework Deep Research Report
## Comprehensive Analysis of Leading Open-Source Multi-Agent Frameworks (2026)

**Report Date**: 2026-02-15
**Frameworks Analyzed**: CrewAI, AutoGen, MetaGPT, Claude Agent SDK, LangGraph, OpenAI Swarm
**Research Depth**: Architecture, Abstractions, Communication Patterns, Cost Optimization, Lessons Learned

---

## Executive Summary

As of February 2026, the multi-agent AI landscape has matured into production-critical infrastructure, with **86% of copilot spending ($7.2B) going to agent-based systems** and over **70% of new AI projects using orchestration frameworks**. This report analyzes the six dominant frameworks to extract practical patterns for Claude Code implementation.

**Key Finding**: LangGraph achieved the **lowest latency and token usage** across benchmarks, while CrewAI leads in **enterprise adoption** and role-based orchestration. Claude Agent SDK emphasizes **context isolation** and **token efficiency** through subagent architecture.

---

## 1. CrewAI — Role-Based Collaborative Intelligence

### Architecture Overview

CrewAI implements a **dual-pattern architecture** combining autonomous agents (Crews) with deterministic workflows (Flows):

```
┌─────────────────────────────────────────┐
│          CrewAI Architecture            │
├─────────────────────────────────────────┤
│                                         │
│  ┌─────────┐      ┌─────────┐         │
│  │  Flows  │◄────►│  Crews  │         │
│  └─────────┘      └─────────┘         │
│       │                 │               │
│       │                 ▼               │
│       │           ┌──────────┐         │
│       │           │  Agents  │         │
│       │           └──────────┘         │
│       │                 │               │
│       ▼                 ▼               │
│  ┌─────────────────────────┐           │
│  │   Structured State      │           │
│  │   (Pydantic Models)     │           │
│  └─────────────────────────┘           │
│       │                 │               │
│       ▼                 ▼               │
│  ┌─────────┐      ┌─────────┐         │
│  │  Tasks  │      │  Tools  │         │
│  └─────────┘      └─────────┘         │
└─────────────────────────────────────────┘
```

**Crews** = Autonomous teams with true agency
**Flows** = Event-driven workflows with precise control

### Core Abstractions

1. **Agent**: Defined by `role`, `goal`, `backstory`
   - Specialized expertise and capabilities
   - Tool access scoped to role requirements
   - Can delegate tasks to other agents

2. **Task**: Work unit with `description` and `expected_output`
   - Assigned to specific agents
   - Outputs feed into subsequent tasks
   - Supports dependencies and conditional execution

3. **Process**: Execution pattern (Sequential, Hierarchical)
   - Sequential: Linear task progression
   - Hierarchical: Manager agent delegates to workers

4. **Memory**: Multi-layered memory system
   - **Short-term**: Current session context
   - **Long-term**: Cross-session persistent memory
   - **Entity**: Facts about specific entities
   - **Contextual**: Situational awareness

### Communication Patterns

**Hub-and-Spoke Model**: Strict centralized coordination, avoiding peer-to-peer agent chatter.

```python
# CrewAI Communication Flow
Manager Agent (Hub)
    ├──► Worker Agent 1 (Spoke)
    ├──► Worker Agent 2 (Spoke)
    └──► Worker Agent 3 (Spoke)
```

**Event-Driven Routing**: Flows use decorators for conditional message passing:
- `@start`: Workflow entry points
- `@listen(Event)`: Reactive triggers
- `@router`: Conditional branching
- `or_` / `and_`: Complex trigger combinations

**Task-Based Delegation**: Tasks carry outputs between agents, enabling natural handoffs without explicit messaging.

### Cost Optimization Approaches

1. **Memory Integration with Mem0**: Reduces token costs by **up to 90%** through persistent context
2. **Selective Memory**: Can disable memory for tasks where it degrades performance
3. **Hub-and-Spoke Communication**: Reduces redundant context sharing vs. peer-to-peer
4. **Lightweight State Structures**: Data pruning and compact state representations

### Lessons Learned / Pitfalls

**Strengths**:
- Intuitive role-based model mirrors real organizations
- Flows provide production-grade deterministic control
- Memory system enables context persistence
- Strong enterprise adoption and documentation

**Pitfalls**:
- Memory can sometimes **degrade results** (reported by practitioners)
- Hub-and-spoke limits emergent agent collaboration
- Heavy framework dependency vs. lightweight alternatives
- Hierarchical scaling introduces communication overhead

**Production Insight**: "When using just a crew without a flow, the result was sometimes better without memory, not in terms of operations but in terms of results." — Real-world deployment

---

## 2. Microsoft AutoGen — Conversational Multi-Agent Framework

### Architecture Overview

AutoGen treats workflows as **multi-agent conversations**, with support for group chats, nested conversations, and teachable agents.

```
┌─────────────────────────────────────────┐
│        AutoGen Architecture             │
├─────────────────────────────────────────┤
│                                         │
│        ┌──────────────────┐            │
│        │ GroupChatManager │            │
│        └────────┬─────────┘            │
│                 │                       │
│        ┌────────┴────────┐             │
│        │                 │              │
│    ┌───▼───┐       ┌────▼────┐        │
│    │Agent 1│◄─────►│ Agent 2 │        │
│    └───┬───┘       └────┬────┘        │
│        │                │              │
│        │  Conversation  │              │
│        │    History     │              │
│        └────────┬───────┘              │
│                 │                       │
│          ┌──────▼──────┐               │
│          │   Tools &   │               │
│          │   LLMs      │               │
│          └─────────────┘               │
└─────────────────────────────────────────┘
```

### Core Abstractions

1. **ConversableAgent**: Base agent with conversation capabilities
   - Registers auto-reply functions
   - Handles incoming messages
   - Spawns nested conversations conditionally

2. **GroupChat**: Multi-agent conversation coordination
   - **GroupChatManager**: Central orchestrator
   - Agents share conversation history
   - Dynamic speaker selection

3. **Nested Conversations**: Hierarchical sub-dialogues
   - Agents spawn sub-agents for specialized tasks
   - Sub-conversations maintain separate context
   - Results summarized back to parent

4. **Teachable Agents**: Learning from interactions
   - Store user preferences
   - Adapt behavior over time
   - Guidelines for group chat integration

### Communication Patterns

**Conversation-First**: Everything is a dialogue between agents.

```python
# AutoGen Group Chat Pattern
User → GroupChatManager
    ├──► Agent A replies
    ├──► Agent B responds to Agent A
    └──► Agent C synthesizes

# Nested Conversation Pattern
Parent Agent
    ├──► Spawn Sub-Agent (separate context)
    └──► Receive summary, continue main conversation
```

**Dynamic Patterns**: Adapt conversation flow based on message content using registered auto-reply functions.

**Multi-Model Routing**: Model-agnostic design allows:
- Different agents use different LLMs (GPT, Claude, Gemini, etc.)
- Cost optimization by pairing expensive models for orchestration with cheaper models for execution
- Single config file to swap models

### Cost Optimization Approaches

1. **OpenAIWrapper Token Tracking**:
   - `create()` initiates requests
   - `print_usage_summary()` shows costs and token usage

2. **LLMLingua Text Compression**: Optimize context size before sending to LLM

3. **Transform Message Capability**: Modify messages before LLM processing to reduce tokens

4. **Selective Model Routing**: Use cheaper models for simple agents, expensive models for complex reasoning

### Lessons Learned / Pitfalls

**Strengths**:
- Natural conversational abstraction
- Multi-model support (OpenAI, Anthropic, Google, local)
- Nested conversations for task decomposition
- Strong token tracking and cost visibility

**Pitfalls**:
- **Shared conversation history** can cause context explosion in group chats
- All agents see full history unless explicitly filtered
- Debugging non-deterministic conversations is challenging
- Unbounded group chats can loop without convergence

**Production Insight**: "AutoGen treats workflows as conversations between agents, while LangGraph represents them as a graph with nodes and edges, offering a more visual and structured approach to workflow management."

---

## 3. MetaGPT — Software Development Team Simulation

### Architecture Overview

MetaGPT models a complete **software company** with specialized roles following standard operating procedures (SOPs).

```
┌─────────────────────────────────────────────────┐
│          MetaGPT Architecture                   │
├─────────────────────────────────────────────────┤
│                                                 │
│  User Requirement (One Line)                   │
│         │                                       │
│         ▼                                       │
│  ┌──────────────┐                              │
│  │   Product    │  PRD, User Stories,          │
│  │   Manager    ├──► Competitive Analysis      │
│  └──────┬───────┘                              │
│         │                                       │
│         ▼                                       │
│  ┌──────────────┐                              │
│  │  Architect   │  System Design,              │
│  │              ├──► Architecture Diagrams,    │
│  └──────┬───────┘  Interface Definitions       │
│         │                                       │
│         ▼                                       │
│  ┌──────────────┐                              │
│  │   Project    │  Task List,                  │
│  │   Manager    ├──► Task Allocation           │
│  └──────┬───────┘                              │
│         │                                       │
│         ▼                                       │
│  ┌──────────────┐                              │
│  │   Engineer   │  Code Implementation         │
│  │              ├──►                            │
│  └──────┬───────┘                              │
│         │                                       │
│         ▼                                       │
│  ┌──────────────┐                              │
│  │  QA Engineer │  Unit Tests,                 │
│  │              ├──► Bug Detection & Fixes     │
│  └──────────────┘                              │
│                                                 │
│  ┌─────────────────────────────┐               │
│  │      Message Pool           │               │
│  │  (Shared Environment)       │               │
│  └─────────────────────────────┘               │
└─────────────────────────────────────────────────┘
```

### Core Abstractions

1. **Role**: Five specialized agent types
   - **Product Manager**: Requirements → PRD
   - **Architect**: PRD → System Design
   - **Project Manager**: Design → Task Breakdown
   - **Engineer**: Tasks → Code
   - **QA Engineer**: Code → Tests & Bug Fixes

2. **SOP (Standard Operating Procedure)**: Hardcoded workflows
   - Assembly-line paradigm
   - Each role has defined inputs and outputs
   - Sequential handoffs between roles

3. **Message Pool**: Shared environment for agent coordination
   - Agents monitor pool for relevant messages
   - Publish task status and artifacts
   - Pull-based communication model

4. **Documents**: Structured outputs between agents
   - PRDs, architecture diagrams, task lists, code files
   - Each agent consumes previous agent's documents

### Communication Patterns

**Assembly-Line Workflow**: Strict sequential progression with structured handoffs.

```python
# MetaGPT Communication Flow
Message Pool (Shared Environment)
    ↑
    │ (monitor)
    │
Product Manager ──document──► Architect ──document──► Project Manager
                                                            │
                                                            ▼
                                          Engineer ◄──tasks──┘
                                             │
                                             ▼
                                          QA Engineer
```

**Message Pool Monitoring**:
1. Agents scan environment for important observations
2. Messages trigger actions or assist in task completion
3. Agents publish updates via `_publish_message()`
4. Other agents subscribe to relevant message types

### Cost Optimization Approaches

*Note: Specific cost optimization documentation is limited in public sources.*

**Inferred Strategies**:
1. **Structured Document Handoffs**: Avoid redundant context by passing only necessary artifacts
2. **Sequential (Not Parallel) Execution**: Reduces concurrent token consumption
3. **Scoped Agent Context**: Each agent only sees relevant documents, not full history

### Lessons Learned / Pitfalls

**Strengths**:
- **Highly structured** workflow mirrors real software teams
- Clear role specialization reduces agent confusion
- Predefined SOPs provide consistency
- Good for prototyping software projects

**Pitfalls**:
- **Rigid assembly-line** limits adaptability
- Sequential execution is slower than parallel
- Limited public documentation on internals (message pool mechanics)
- "Steep learning curve" reported by community
- Best for **code generation**, less flexible for other domains

**Production Insight**: "MetaGPT comes with predefined agents following standard software development workflows and for companies looking to boost their dev capacity, it's an interesting experiment that can generate decent prototypes."

---

## 4. Claude Agent SDK (Anthropic) — Context Isolation & Subagent Architecture

### Architecture Overview

Claude Agent SDK emphasizes **orchestrator-worker** pattern with **isolated context windows** for subagents.

```
┌─────────────────────────────────────────────────┐
│       Claude Agent SDK Architecture             │
├─────────────────────────────────────────────────┤
│                                                 │
│  ┌────────────────────────────────┐            │
│  │   Lead Agent (Orchestrator)    │            │
│  │   - Global Planning            │            │
│  │   - Task Decomposition         │            │
│  │   - Result Synthesis           │            │
│  │   - Compact State              │            │
│  └─────────┬──────────────────────┘            │
│            │                                    │
│            ├─────────────────┬─────────────┐   │
│            │                 │             │   │
│     ┌──────▼─────┐    ┌─────▼────┐  ┌────▼──┐│
│     │ Subagent 1 │    │Subagent 2│  │Subag 3││
│     │ (Isolated) │    │(Isolated)│  │(Isol.)││
│     └──────┬─────┘    └─────┬────┘  └────┬──┘│
│            │                 │             │   │
│            └────────┬────────┴─────────────┘   │
│                     │                          │
│              ┌──────▼───────┐                  │
│              │   Summary    │                  │
│              │   (Signal)   │                  │
│              └──────────────┘                  │
│                     │                          │
│                     ▼                          │
│            Lead Agent (Synthesis)              │
└─────────────────────────────────────────────────┘
```

**Key Principle**: Subagents maintain **separate context windows** from the lead agent.

### Core Abstractions

1. **Lead Agent (Orchestrator)**:
   - Coordinates the process
   - Spawns specialized subagents
   - Maintains global plan and compact state
   - Synthesizes subagent results

2. **Subagent (Worker)**:
   - Operates in isolated context window
   - Receives **one job** with clear objective
   - Returns **concise summary** (signal, not noise)
   - Prevents parent context pollution

3. **Context Isolation**:
   - Each subagent has separate 200K context window
   - Parent context does NOT leak to subagents
   - Subagent verbose output stays isolated
   - Only summaries return to orchestrator

4. **Handoff Protocol**:
   - Lead provides: objective, output format, tool guidance, task boundaries
   - Subagent returns: summary, key findings, artifacts
   - No shared conversation history between subagents

### Communication Patterns

**Orchestrator-Worker with Context Isolation**:

```python
# Claude SDK Pattern
Lead Agent (Compact Context)
    │
    ├──► spawn(Subagent 1, task="Research topic A")
    │         └──► Separate 200K context window
    │         └──► Returns: 500-word summary
    │
    ├──► spawn(Subagent 2, task="Research topic B")
    │         └──► Separate 200K context window
    │         └──► Returns: 500-word summary
    │
    └──► Synthesizes summaries → Final result
```

**Interleaved Thinking**: Subagents evaluate tool results and refine queries dynamically within their context.

**Parallel Exploration**: Multiple subagents investigate different aspects simultaneously without cross-contamination.

### Cost Optimization Approaches

1. **Context Isolation for Large Operations**:
   - Verbose outputs (tests, logs, docs) stay in subagent context
   - Lead agent sees only summaries
   - Prevents context explosion in orchestrator

2. **Scoped Context Handoffs**:
   - "Explicitly scope what the callee sees—maybe just the latest user query and one artifact"
   - Suppress ancestral history when spawning subagents

3. **File Identifiers Over Content**:
   - "Pass file identifiers or URLs instead of the full content"
   - Multiple agents read same source without duplicating in messages

4. **Aggressive State Compression**:
   - Lead stores: plan, key decisions, latest artifacts
   - NOT: full subagent conversation history

5. **Model Mixing**:
   - "Claude Opus 4 as lead agent, Claude Sonnet 4 subagents"
   - Multi-agent with mixed models **outperformed single-agent Opus by 90.2%**

### Lessons Learned / Pitfalls

**Strengths**:
- **Context isolation** prevents bloat
- Token efficiency through scoped handoffs
- Proven 90%+ improvement with multi-agent
- Prompt engineering > rigid rules

**Pitfalls**:
- "**Multi-agent systems use about 15× more tokens** than chats"
- Requires careful evaluation of task value vs. cost
- Non-deterministic behavior demands production-level tracing
- Debugging is harder than single-agent systems

**Production Insights from Anthropic**:

1. **"Prompt Engineering Over Rigid Rules"**: Encode human heuristics in prompts rather than hardcoding workflows.

2. **"Token Economics Matter"**: 15× token multiplier means tasks must justify the cost through quality gains.

3. **"One Job Per Subagent"**: "Give each subagent one job, and let an orchestrator coordinate."

4. **"Stateful Resilience"**: Agents need graceful error handling and resumption, not restart-from-scratch.

5. **"Periodically Reset Context"**: Long sessions require pruning or subagent handoffs to prevent degradation.

---

## 5. LangGraph — State Machine Multi-Agent Orchestration

### Architecture Overview

LangGraph models agent workflows as **stateful directed graphs** with nodes (agents) and edges (transitions).

```
┌─────────────────────────────────────────────────┐
│         LangGraph Architecture                  │
├─────────────────────────────────────────────────┤
│                                                 │
│  ┌────────────────────────────────┐            │
│  │    Centralized State           │            │
│  │    (TypedDict + Reducers)      │            │
│  └────────────┬───────────────────┘            │
│               │                                 │
│       ┌───────┴────────┐                       │
│       │                │                        │
│  ┌────▼────┐      ┌───▼─────┐                 │
│  │ Node 1  │      │ Node 2  │                  │
│  │(Agent A)│      │(Agent B)│                  │
│  └────┬────┘      └───┬─────┘                 │
│       │               │                         │
│       │   ┌───────────┴─────┐                  │
│       │   │                 │                   │
│  ┌────▼───▼─┐         ┌────▼────┐             │
│  │  Node 3  │         │ Node 4  │              │
│  │(Supervisor)        │(Worker) │              │
│  └──────────┘         └─────────┘              │
│       │                                         │
│       ▼                                         │
│  ┌────────────────┐                            │
│  │  Checkpoint    │                            │
│  │  (Persistence) │                            │
│  └────────────────┘                            │
└─────────────────────────────────────────────────┘
```

### Core Abstractions

1. **State**: Centralized shared data structure
   - **TypedDict**: Schema for state shape
   - **Annotated Types**: Define reducer functions
   - **Persistent**: Survives across workflow steps
   - **Accessible to all nodes**: Shared memory

2. **Nodes**: Python functions encoding agent logic
   - Read from state
   - Execute agent actions
   - Write updates to state
   - Can spawn other nodes

3. **Edges**: Transitions between nodes
   - Conditional: Route based on state
   - Direct: Fixed transitions
   - Define workflow topology

4. **Checkpoint**: State persistence mechanism
   - Save workflow progress
   - Resume from last checkpoint after failures
   - SQLite or PostgreSQL backends
   - Enables long-running workflows

5. **Reducers**: State update functions
   - Merge concurrent updates from parallel agents
   - Prevent data loss in multi-agent systems
   - Deterministic conflict resolution

### Communication Patterns

**Shared State Model**: All agents read/write to centralized state.

```python
# LangGraph Communication Pattern
State = {
    "messages": [...],
    "task_results": {...},
    "current_agent": "researcher"
}

Agent A (Node 1)
    ├──► Reads State
    ├──► Executes Task
    └──► Writes to State

Agent B (Node 2)
    ├──► Reads Updated State (sees Agent A's work)
    ├──► Executes Task
    └──► Writes to State
```

**Supervisor Pattern**: Central coordinator delegates to workers.

```python
Supervisor Node
    ├──► Analyzes task
    ├──► Routes to Agent A or Agent B (conditional edge)
    └──► Synthesizes results from state
```

**Handoff Pattern**: Agents can transfer control via tool calls.
- Agent A completes task → Updates state → Returns control
- State guides next agent selection
- Natural conversation flow between AI team members

### Cost Optimization Approaches

1. **Lowest Latency & Token Usage**:
   - "LangGraph achieved the **lowest latency and token usage** across benchmarks"
   - Graph-based approach **reduces redundant context passing**

2. **Stateful Patterns**:
   - "Handoffs and Skills save **40-50% of calls on repeat requests**"
   - Checkpoint persistence prevents re-computation

3. **Reducer-Driven Updates**:
   - Deterministic state merges prevent redundant agent calls
   - Batched concurrent execution (super-steps)

4. **Conditional Routing**:
   - Only invoke agents when state conditions trigger
   - Avoid unnecessary LLM calls

### Lessons Learned / Pitfalls

**Strengths**:
- **Best performance**: Lowest latency, lowest token usage (benchmarked)
- **Stateful persistence**: Resume workflows after failures
- **Deterministic control**: Graph structure is transparent
- **Mature ecosystem**: Strong LangChain/LangSmith integration

**Pitfalls**:
- **Learning curve**: Graph abstraction more complex than conversations
- **Shared state overhead**: All agents see full state (can be noise)
- **Reducer complexity**: Correct merge logic requires careful design
- **Framework dependency**: Tied to LangChain ecosystem

**Production Insights**:

1. **"Graph-Based Reduces Redundant Context"**: Explicit edges prevent re-explaining context between agents.

2. **"Checkpointing Enables Long Workflows"**: Production systems need resumption, not restart.

3. **"Reducers Prevent Data Loss"**: Critical for concurrent multi-agent execution.

4. **"Super-Steps for Determinism"**: Batched concurrent execution → checkpoint → next batch.

---

## 6. OpenAI Swarm — Lightweight Handoff-Based Orchestration

### Architecture Overview

OpenAI Swarm (now evolved into **OpenAI Agents SDK**) focuses on **lightweight coordination** through explicit handoffs and routines.

```
┌─────────────────────────────────────────────────┐
│         OpenAI Swarm Architecture               │
├─────────────────────────────────────────────────┤
│                                                 │
│  ┌────────────────────────────────┐            │
│  │   Shared Conversation History  │            │
│  └────────────┬───────────────────┘            │
│               │                                 │
│       ┌───────┴────────┐                       │
│       │                │                        │
│  ┌────▼────┐      ┌───▼─────┐                 │
│  │ Agent 1 │      │ Agent 2 │                  │
│  │ (Active)│──────►│(Waiting)│                 │
│  └─────────┘ handoff└────────┘                 │
│       │                │                        │
│       │   Handoff      │                        │
│       │   Function     │                        │
│       └────────┬───────┘                        │
│                │                                 │
│           ┌────▼────┐                           │
│           │ Agent 3 │                           │
│           │ (Active)│                           │
│           └─────────┘                           │
│                                                 │
│  ┌────────────────────────────────┐            │
│  │   System Prompt Changes        │            │
│  │   (Active Agent Instructions)  │            │
│  └────────────────────────────────┘            │
└─────────────────────────────────────────────────┘
```

**Note**: Swarm has been superseded by **OpenAI Agents SDK** for production use.

### Core Abstractions

1. **Agent**: Specialized unit with unique capabilities
   - **System Prompt**: Defines role and expertise
   - **Tools**: Scoped to agent's specialty
   - **Handoff Functions**: Transfer control to other agents

2. **Handoff**: Explicit delegation mechanism
   - Function call transfers control
   - Active agent changes
   - System prompt swaps
   - Conversation history persists

3. **Routines**: Predefined agent workflows
   - Multi-step processes
   - Conditional handoffs
   - Chained tool executions

4. **Shared History**: Conversation continuity
   - All agents see full conversation
   - Only active agent's instructions apply
   - Handoffs preserve context

### Communication Patterns

**Handoff-Based Sequential Execution**:

```python
# Swarm Handoff Pattern
Agent A (Active)
    ├──► Executes task with tools
    ├──► Determines next agent needed
    └──► Calls handoff(Agent B)

Agent B (Now Active)
    ├──► Receives full conversation history
    ├──► New system prompt applies
    ├──► Continues from where Agent A left off
    └──► Can handoff to Agent C or finish
```

**Explicit Routing**: "Delegation and specialization are modeled within Swarm, making agent-to-agent routing **transparent and easy to extend**."

**Specialization-First**: Each agent focuses on what they do best, enabling:
- Clear boundaries of expertise
- Individual agent testing
- Scalable addition of new specialists

### Cost Optimization Approaches

1. **Lightweight Design**: Minimal framework overhead
2. **Shared History**: No redundant context reconstruction
3. **Targeted Handoffs**: Only invoke agents when needed
4. **Ergonomic Simplicity**: Less complexity = fewer wasted tokens

**Note**: Specific cost optimization metrics are limited due to framework's experimental/educational status.

### Lessons Learned / Pitfalls

**Strengths**:
- **Simplicity**: Easiest to understand and implement
- **Explicit control**: Handoffs are transparent
- **Specialization**: Clear agent boundaries
- **Educational**: Great for learning multi-agent concepts

**Pitfalls**:
- **Deprecated**: Swarm is now **OpenAI Agents SDK** (production-ready evolution)
- **Shared history overhead**: All agents see full context (can bloat)
- **Sequential execution**: Less parallel than other frameworks
- **Limited production features**: Was experimental/educational

**Production Insight**: "Swarm has been **replaced by the OpenAI Agents SDK**, which is a production-ready evolution of Swarm with key improvements and will be actively maintained by the OpenAI team, with **migration to the Agents SDK recommended for all production use cases**."

---

## Comparative Analysis

### Framework Comparison Matrix

| Dimension | CrewAI | AutoGen | MetaGPT | Claude SDK | LangGraph | OpenAI Swarm |
|-----------|--------|---------|---------|------------|-----------|--------------|
| **Primary Pattern** | Hub-and-Spoke | Group Chat | Assembly Line | Orchestrator-Worker | State Machine | Handoff Chain |
| **Communication** | Task Delegation | Conversations | Message Pool | Context Isolation | Shared State | Handoff Functions |
| **Parallelization** | Limited | Yes (group chat) | Sequential | Yes (subagents) | Yes (super-steps) | Sequential |
| **Context Model** | Shared (Hub) | Shared History | Message Pool | Isolated per Agent | Centralized State | Shared History |
| **Latency** | Medium | Medium-High | High | Low-Medium | **Lowest** | Medium |
| **Token Efficiency** | Medium-High | Low-Medium | Medium | **High** | **Highest** | Medium |
| **Learning Curve** | Low | Medium | **High** | Medium | Medium-High | **Low** |
| **Production Maturity** | **High** | High | Medium | High | **High** | Low (deprecated) |
| **Use Case Fit** | Enterprise Workflows | Conversational AI | Code Generation | Research/Analysis | Complex State | Simple Delegation |
| **Cost at Scale** | Medium | High | Medium | Low (with isolation) | **Low** | Medium |

### Token Usage Benchmarks (2026 Data)

Based on reported production metrics:

1. **LangGraph**: Lowest token usage (graph reduces redundant context)
2. **Claude SDK**: High efficiency with context isolation (90% improvement vs. single-agent)
3. **CrewAI**: 90% reduction possible with Mem0 integration
4. **AutoGen**: Higher usage due to shared conversation history
5. **MetaGPT**: Medium (sequential handoffs, scoped documents)
6. **OpenAI Swarm**: Medium (shared history overhead)

**Critical Finding**: "Multi-agent systems use about **15× more tokens** than chats" — cost must be justified by quality gains.

### When to Use Each Framework

**CrewAI**:
- Role-based organizational workflows
- Enterprise applications requiring deterministic flows
- Tasks with clear hierarchies and delegation
- When memory persistence is valuable

**AutoGen**:
- Conversational multi-agent systems
- Multi-model routing (mix GPT, Claude, Gemini)
- Dynamic conversation patterns
- Strong token tracking requirements

**MetaGPT**:
- Software development projects
- Code generation and prototyping
- Tasks fitting PM → Architect → Engineer → QA workflow
- When rigid structure is beneficial

**Claude Agent SDK**:
- Research and analysis tasks
- Large output operations (tests, logs, docs)
- Token efficiency is critical
- Complex decomposition with parallel exploration

**LangGraph**:
- **Complex stateful workflows**
- Branching, error recovery, conditional logic
- Long-running processes requiring checkpoints
- **Best performance/cost ratio**

**OpenAI Swarm** (Now Agents SDK):
- Simple handoff patterns
- Learning multi-agent concepts
- Migrate to OpenAI Agents SDK for production

---

## Critical Pitfalls to Avoid (All Frameworks)

### 1. Context Explosion (Token Bloat)

**Problem**: "Single-agent systems struggle with context bloat, but multi-agent systems **amplify it**."

**Manifestations**:
- Full conversation history passed to every agent
- Verbose tool outputs not summarized
- Redundant context across subagents
- Token count skyrockets exponentially

**Solutions**:
- **Scoped Handoffs**: Pass only relevant context to agents
- **Summarization**: Compress completed work before handoffs
- **Context Isolation**: Separate context windows per agent (Claude SDK)
- **File Identifiers**: Reference data instead of duplicating content

### 2. Communication Complexity

**Problem**: "Ten agents need forty-five relationships" — communication scales O(n²).

**Manifestations**:
- Increased latency
- Higher token consumption
- More failure points
- Debugging nightmare

**Solutions**:
- **Hub-and-Spoke**: Centralized coordination (CrewAI)
- **Orchestrator-Worker**: Single coordinator (Claude SDK, LangGraph)
- **Explicit Routing**: Clear handoff paths (Swarm)
- **Minimize Peer-to-Peer**: Avoid agent-to-agent chatter

### 3. Unbounded Looping

**Problem**: "Agents repeatedly reason, retry, or debate without convergence."

**Manifestations**:
- Infinite conversation loops
- Redundant agent calls
- Exponential cost growth
- No termination condition

**Solutions**:
- **Max Iterations**: Hard limits on loops
- **Convergence Checks**: Detect when progress stalls
- **Timeout Mechanisms**: Circuit breakers
- **Supervisor Intervention**: Orchestrator forces decision

### 4. Signal Degradation ("Lost in the Middle")

**Problem**: "Context window flooded with irrelevant logs, stale tool outputs, or deprecated state can distract the model."

**Manifestations**:
- Model fixates on past patterns
- Ignores current instructions
- Poor decision quality
- Redundant work

**Solutions**:
- **Pruning**: Remove stale context
- **State Compression**: Keep only essential information
- **Fresh Context**: Spawn new agents for new phases
- **Reducer Functions**: Deterministically merge updates (LangGraph)

### 5. Path Dependency

**Problem**: Agents inherit biases from shared conversation history.

**Manifestations**:
- Sub-agents can't explore independently
- Groupthink in multi-agent systems
- Missed alternative solutions

**Solutions**:
- **Context Isolation**: Separate windows per agent (Claude SDK)
- **Parallel Exploration**: Independent investigations (Anthropic pattern)
- **Fresh Spawns**: Reset context for new perspectives

---

## Practical Patterns for Claude Code Implementation

### Pattern 1: Orchestrator-Worker with Context Isolation

**Based on**: Claude Agent SDK + Anthropic Research System

```python
# Lead Agent (Claude Code main session)
def orchestrate_research(query: str):
    # 1. Decompose query
    subtasks = decompose_into_parallel_tasks(query)

    # 2. Spawn workers with SCOPED context
    results = []
    for task in subtasks:
        # Each worker gets: objective, output format, tools, boundaries
        # NOT: full lead agent conversation history
        worker = spawn_subagent(
            task=task["objective"],
            context=task["minimal_context"],  # Scoped!
            expected_output="500-word summary"
        )
        results.append(worker.run())

    # 3. Synthesize summaries (lead context stays compact)
    return synthesize(results)
```

**Key Insights**:
- Lead maintains compact state (plan, decisions, artifacts)
- Workers operate in isolated contexts
- Only summaries return to lead
- Prevents context explosion

### Pattern 2: Task DAG with LangGraph-Style State

**Based on**: LangGraph + Claude Code Task tool

```python
# Task DAG Pattern
from claude_code import TaskCreate

# Centralized state (shared memory)
state = {
    "research_findings": {},
    "implementation_status": {},
    "test_results": {}
}

# Create task graph
research_task = TaskCreate(
    title="Research Phase",
    dependencies=[]
)

implementation_task = TaskCreate(
    title="Implementation Phase",
    dependencies=[research_task.id]  # Waits for research
)

test_task = TaskCreate(
    title="Testing Phase",
    dependencies=[implementation_task.id]
)

# Agents update shared state via TaskUpdate
# Next agents read state to continue work
```

**Key Insights**:
- Task dependencies create explicit workflow
- Shared state via Task descriptions/results
- Checkpointing through Task system
- Deterministic execution order

### Pattern 3: CrewAI-Style Hub-and-Spoke

**Based on**: CrewAI + Claude Code Agent Teams

```python
# Lead Agent (Hub)
def coordinate_team():
    # Spawn specialized teammates
    researcher = spawn_teammate("research-specialist", ...)
    builder = spawn_teammate("implementation-specialist", ...)
    tester = spawn_teammate("qa-specialist", ...)

    # Lead coordinates via messages
    send_message(researcher, "Investigate approach A")
    send_message(builder, "Wait for research")

    # Hub receives results
    research_result = wait_for_message(researcher)

    # Hub delegates next step
    send_message(builder, f"Implement based on: {research_result.summary}")
```

**Key Insights**:
- Central coordination (Lead agent)
- Specialists work independently
- No peer-to-peer communication
- Clear ownership boundaries

### Pattern 4: AutoGen-Style Group Conversation

**Based on**: AutoGen + Claude Code messaging

```python
# Group conversation pattern
def group_brainstorm(problem: str):
    # Spawn multiple agents
    agents = [
        spawn_teammate("analyst", ...),
        spawn_teammate("architect", ...),
        spawn_teammate("critic", ...)
    ]

    # Broadcast problem
    broadcast(agents, f"Problem: {problem}")

    # Conversational rounds
    for round in range(3):
        for agent in agents:
            response = get_message(agent)
            broadcast(agents, response)  # All agents see all responses

    # Synthesize consensus
    return synthesize_conversation()
```

**Key Insights**:
- Shared conversation history
- Dynamic speaker selection
- Emergent collaboration
- **Watch for context bloat!**

### Pattern 5: Handoff Chain (Swarm-Style)

**Based on**: OpenAI Swarm pattern

```python
# Sequential handoff pattern
def handoff_workflow(task: str):
    # Agent A starts
    result_a = agent_a.execute(task)

    # Agent A decides next agent
    if result_a.needs_specialization:
        # Handoff to Agent B with full context
        result_b = agent_b.execute(result_a.context)
        return result_b
    else:
        return result_a
```

**Key Insights**:
- Explicit control transfer
- Clear specialization boundaries
- Simple to understand and debug
- Sequential (not parallel)

---

## Cost Optimization Strategies (Cross-Framework)

### 1. Context Pruning

**What**: Remove stale, irrelevant context before agent calls.

**How**:
- Summarize completed phases
- Delete verbose tool outputs
- Keep only: plan, decisions, latest artifacts

**Savings**: 40-50% token reduction (LangGraph stateful patterns)

### 2. Model Mixing

**What**: Use expensive models for orchestrators, cheap models for workers.

**Example**:
- Lead: Claude Opus 4.6 ($15 input / $75 output per MTok)
- Workers: Claude Sonnet 4 ($3 input / $15 output per MTok)

**Results**: "Claude Opus lead + Sonnet workers **outperformed single-agent Opus by 90.2%**" while reducing cost.

### 3. File Reference Pattern

**What**: Pass file paths/IDs instead of content.

**Before**:
```python
send_message(agent, f"Analyze this: {50_000_char_content}")  # Expensive!
```

**After**:
```python
send_message(agent, f"Analyze file: /path/to/data.json")  # Agent reads separately
```

**Savings**: Avoids duplicating large content in messages.

### 4. Subagent Isolation for Verbose Outputs

**What**: Delegate operations with large outputs to isolated subagents.

**Use Cases**:
- Running tests (verbose output)
- Fetching documentation (large content)
- Processing logs (noisy data)

**Pattern**:
```python
# Verbose output stays in subagent context
test_summary = subagent.run_tests()  # Returns 500-word summary, not 50K log
```

**Savings**: Prevents lead agent context pollution.

### 5. Aggressive Summarization

**What**: Compress completed work before handoffs.

**Pattern**:
```python
# After Phase 1 completion
phase1_details = agent.get_full_results()  # 10K tokens
phase1_summary = summarize(phase1_details)  # 500 tokens

# Pass summary to Phase 2
phase2_agent.execute(phase1_summary)  # Not full details!
```

**Savings**: 90%+ token reduction on handoffs.

### 6. Checkpointing and Resumption

**What**: Save state periodically, resume from checkpoint on failure.

**Frameworks**: LangGraph (built-in), Claude SDK (manual)

**Savings**: Avoid re-running entire workflows on failure.

---

## Recommendations for Genesis Implementation

### Immediate Patterns to Adopt

1. **Orchestrator-Worker with Context Isolation** (Claude SDK pattern)
   - MOST IMPORTANT for token efficiency
   - Lead maintains compact state
   - Workers isolated for verbose operations
   - **Already aligned with Genesis philosophy**

2. **Task DAG for Coordination** (LangGraph pattern)
   - Use Claude Code native Task tool
   - Explicit dependencies create workflow
   - Shared state via Task system
   - **Complements RWL loops**

3. **Hub-and-Spoke Communication** (CrewAI pattern)
   - Lead coordinates all teammates
   - No peer-to-peer agent chatter
   - Clear ownership boundaries
   - **Prevents communication explosion**

### Patterns to Avoid

1. **Shared Conversation History** (AutoGen group chat)
   - Context explosion risk
   - Harder to scale
   - Unless task explicitly requires emergent dialogue

2. **Sequential Assembly Line** (MetaGPT)
   - Too rigid for Genesis flexibility
   - Slower than parallel
   - Only if workflow is truly linear

3. **Unbounded Group Conversations**
   - Risk of looping without convergence
   - Expensive and unpredictable

### Token Optimization Checklist

- [ ] Lead agent maintains compact state (plan + decisions + artifacts only)
- [ ] Subagents spawned with scoped context (not full history)
- [ ] Verbose outputs (tests, logs, docs) delegated to isolated subagents
- [ ] File references used instead of content duplication
- [ ] Completed phases summarized before handoffs
- [ ] Model mixing: expensive lead, cheap workers (where appropriate)
- [ ] Max iterations and timeout guards on all agent loops
- [ ] State pruning after each major phase
- [ ] Checkpoint/resumption for long workflows

### Genesis-Specific Enhancements

**Leverage Existing Infrastructure**:

1. **RWL Loops for Execution**: Gemini swarm handles implementation
2. **Task DAG for Coordination**: Claude orchestrates via Task system
3. **Agent Teams for Parallel Research**: Spawn teammates for independent investigations
4. **Supermemory for Context**: Offload memory to persistent storage, not context window

**Hybrid Pattern**:

```python
# Genesis Multi-Agent Pattern
Lead Agent (Claude Opus 4.6)
    ├──► Task DAG (Coordination)
    │       ├── Research Task (Agent Team: parallel scouts)
    │       ├── Design Task (Single agent: architect)
    │       └── Implementation Task (RWL Swarm: Gemini workers)
    │
    ├──► Supermemory (Context Offload)
    │       └── Store: findings, decisions, artifacts
    │
    └──► Synthesis (Lead Agent)
            └── Pull from Supermemory, synthesize results
```

**Key Principle**: Claude orchestrates, Gemini executes, Supermemory persists.

---

## References & Sources

### CrewAI
- [CrewAI GitHub Repository](https://github.com/crewAIInc/crewAI)
- [CrewAI Official Documentation](https://docs.crewai.com/en/introduction)
- [CrewAI Memory Concepts](https://docs.crewai.com/en/concepts/memory)
- [CrewAI: The Revolutionary Multi-Agent Framework - BrightCoding](https://www.blog.brightcoding.dev/2026/02/13/crewai-the-revolutionary-multi-agent-framework)
- [CrewAI Performance Tuning Guide](https://www.wednesday.is/writing-articles/crewai-performance-tuning-optimizing-multi-agent-systems)

### Microsoft AutoGen
- [AutoGen Conversation Patterns Documentation](https://microsoft.github.io/autogen/0.2/docs/tutorial/conversation-patterns/)
- [AutoGen Multi-Agent Chat](https://microsoft.github.io/autogen/0.2/docs/Use-Cases/agent_chat/)
- [AutoGen Group Chat Guide](https://microsoft.github.io/autogen/stable//user-guide/core-user-guide/design-patterns/group-chat.html)
- [AutoGen Research Paper (arXiv:2308.08155)](https://arxiv.org/abs/2308.08155)
- [AutoGen Cost Tracking](https://docs.ag2.ai/latest/docs/use-cases/notebooks/notebooks/agentchat_cost_token_tracking/)

### MetaGPT
- [MetaGPT GitHub Repository](https://github.com/FoundationAgents/MetaGPT)
- [MetaGPT Research Paper (arXiv:2308.00352)](https://arxiv.org/html/2308.00352v6)
- [MetaGPT Overview - IBM](https://www.ibm.com/think/topics/metagpt)
- [MetaGPT Architecture Analysis - Atoms.dev](https://atoms.dev/insights/metagpt-style-software-team-agents-foundations-architecture-applications-and-performance-trends/7e48a158cab643e4b8ea7157286a92f2)

### Claude Agent SDK (Anthropic)
- [How We Built Our Multi-Agent Research System - Anthropic](https://www.anthropic.com/engineering/multi-agent-research-system)
- [Building Agents with the Claude Agent SDK](https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk)
- [Claude Agent SDK Subagents Documentation](https://platform.claude.com/docs/en/agent-sdk/subagents)
- [Create Custom Subagents - Claude Code](https://code.claude.com/docs/en/sub-agents)
- [Claude Agent SDK Best Practices (2025)](https://skywork.ai/blog/claude-agent-sdk-best-practices-ai-agents-2025/)

### LangGraph
- [LangGraph Multi-Agent Documentation](https://docs.langchain.com/oss/python/langchain/multi-agent)
- [LangGraph Supervisor Pattern](https://github.com/langchain-ai/langgraph-supervisor-py)
- [Build Multi-Agent Systems with LangGraph - AWS](https://aws.amazon.com/blogs/machine-learning/build-multi-agent-systems-with-langgraph-and-amazon-bedrock/)
- [LangGraph Multi-Agent Workflows Blog](https://blog.langchain.com/langgraph-multi-agent-workflows/)
- [Mastering LangGraph State Management 2025](https://sparkco.ai/blog/mastering-langgraph-state-management-in-2025)

### OpenAI Swarm
- [OpenAI Swarm GitHub Repository](https://github.com/openai/swarm)
- [OpenAI Cookbook: Orchestrating Agents](https://cookbook.openai.com/examples/orchestrating_agents)
- [OpenAI Swarm Framework Guide - Galileo](https://galileo.ai/blog/openai-swarm-framework-multi-agents)
- [Multi-Agent Orchestration with OpenAI Swarm](https://www.akira.ai/blog/multi-agent-orchestration-with-openai-swarm)

### Claude Code Agent Teams
- [Orchestrate Teams - Claude Code Documentation](https://code.claude.com/docs/en/agent-teams)
- [Claude Code Swarm Orchestration Skill (GitHub Gist)](https://gist.github.com/kieranklaassen/4f2aba89594a4aea4ad64d753984b2ea)
- [How to Use Claude Code Agent Teams - Medium](https://darasoba.medium.com/how-to-set-up-and-use-claude-code-agent-teams-and-actually-get-great-results-9a34f8648f6d)
- [From Tasks to Swarms - alexop.dev](https://alexop.dev/posts/from-tasks-to-swarms-agent-teams-in-claude-code/)

### Framework Comparisons
- [LangGraph vs CrewAI vs AutoGen (2026)](https://o-mega.ai/articles/langgraph-vs-crewai-vs-autogen-top-10-agent-frameworks-2026)
- [Choosing the Right Multi-Agent Framework - DataCamp](https://www.datacamp.com/tutorial/crewai-vs-langgraph-vs-autogen)
- [Top AI Agent Frameworks in 2025 - Codecademy](https://www.codecademy.com/article/top-ai-agent-frameworks-in-2025)
- [14 AI Agent Frameworks Compared - Softcery](https://softcery.com/lab/top-14-ai-agent-frameworks-of-2025-a-founders-guide-to-building-smarter-systems)

### Pitfalls & Best Practices
- [Architecting Efficient Multi-Agent Frameworks - Google](https://developers.googleblog.com/architecting-efficient-context-aware-multi-agent-framework-for-production/)
- [Why Multi-Agent LLM Systems Fail (arXiv:2503.13657)](https://arxiv.org/html/2503.13657v1)
- [Stop Wasting Tokens (arXiv:2510.26585)](https://arxiv.org/html/2510.26585v1)
- [Why Multi-Agent Systems Need Memory Engineering - MongoDB](https://medium.com/mongodb/why-multi-agent-systems-need-memory-engineering-153a81f8d5be)
- [Multi-Agent Orchestration Patterns - Azure](https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/ai-agent-design-patterns)

---

## Appendix: Quick Reference Tables

### Communication Pattern Comparison

| Pattern | Frameworks | Pros | Cons | Best For |
|---------|-----------|------|------|----------|
| **Hub-and-Spoke** | CrewAI | Clear coordination, prevents explosion | Limits emergent collaboration | Enterprise workflows |
| **Group Chat** | AutoGen | Emergent dialogue, natural | Context bloat, hard to debug | Conversational AI |
| **Message Pool** | MetaGPT | Decoupled agents, SOP-driven | Rigid, sequential | Code generation |
| **Context Isolation** | Claude SDK | Token efficient, scalable | Requires manual synthesis | Research, analysis |
| **Shared State** | LangGraph | Deterministic, resumable | Overhead, complexity | Complex workflows |
| **Handoff Chain** | OpenAI Swarm | Simple, explicit | Sequential, limited | Learning, simple tasks |

### Token Optimization Techniques

| Technique | Impact | Difficulty | Frameworks |
|-----------|--------|------------|------------|
| Context Isolation | 🟢 High (prevents bloat) | Medium | Claude SDK |
| Model Mixing | 🟢 High (90%+ improvement) | Low | All |
| File References | 🟢 High (avoids duplication) | Low | All |
| Summarization | 🟢 High (90% reduction) | Medium | All |
| State Pruning | 🟡 Medium (40-50% savings) | Medium | LangGraph, Claude SDK |
| Checkpointing | 🟡 Medium (avoids reruns) | High | LangGraph |
| Hub-and-Spoke | 🟡 Medium (reduces chatter) | Low | CrewAI |
| Mem0 Integration | 🟢 High (90% reduction) | Medium | CrewAI |

### Framework Selection Decision Tree

```
Start
│
├─ Need complex state machine with branching?
│   └─ YES → LangGraph
│
├─ Need role-based organizational workflow?
│   └─ YES → CrewAI
│
├─ Need code generation with dev team roles?
│   └─ YES → MetaGPT
│
├─ Need research/analysis with token efficiency?
│   └─ YES → Claude Agent SDK
│
├─ Need conversational multi-agent dialogue?
│   └─ YES → AutoGen
│
└─ Need simple handoff pattern for learning?
    └─ YES → OpenAI Agents SDK (Swarm successor)
```

---

**End of Report**

*This research report synthesizes publicly available documentation, research papers, and production insights from the leading multi-agent frameworks as of February 2026. All patterns and recommendations are designed to be implementable within Claude Code using the Task tool, Agent Teams, and subagent capabilities.*
