# awslabs/multi-agent-orchestrator architecture

> Architecture diagram of the GitHub repository awslabs/multi-agent-orchestrator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/awslabs/multi-agent-orchestrator
- Repository: https://github.com/awslabs/multi-agent-orchestrator

## Overview

##### Main Components

a. Core Components:
- Orchestrator (Central Controller)
- Classifier System
- Agent Registry
- Storage System
- Retriever System

b. Agent Types:
- Built-in Agents (Bedrock, OpenAI, Anthropic, etc.)
- Custom Agents
- Lambda Agents
- Chain Agents

c. External Services Integration:
- AWS Services (Bedrock, Lex, Lambda, Comprehend)
- Third-party Services (OpenAI, Anthropic)
- Storage Solutions (DynamoDB, SQL, In-Memory)

##### User Interface Layer
- Input/Output Handlers
- API Endpoints
- Streaming Response Handlers

##### Orchestration Layer
- Multi-Agent Orchestrator (Core)
- Request Router
- Context Manager
- Classification System

##### Agent Layer
- Agent Registry
- Agent Implementation Classes
- Tool Integration
- Response Processors

##### Storage Layer
- Chat Storage Interfaces
- Implementation Options (DynamoDB, SQL, In-Memory)
- Context Management

##### External Services Layer
- Cloud Service Connections
- API Integrations
- Authentication Handlers

##### Key Relationships to Highlight

- Request flow (User → Orchestrator → Agents)
- Data flow (Storage ↔ Orchestrator)
- Service dependencies (Agents → External Services)
- Context propagation (Storage → Agents)

##### Implementation Details

Create sections for both Python and TypeScript implementations:
- Parallel structures
- Shared interfaces
- Language-specific optimizations

##### Additional Elements

Include:
- Version information
- Key configuration points
- Scaling considerations
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef core fill:#2374AB,color:white
    classDef agent fill:#7FB069,color:white
    classDef storage fill:#9B6B9E,color:white
    classDef external fill:#E09F3E,color:white
    classDef interface fill:#fff,stroke:#333,stroke-width:2px
    classDef system fill:#9E2B25,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Agent Components]:::agent
        L3[Storage Components]:::storage
        L4[External Services]:::external
        L5[System Components]:::system
    end

    %% User Interface Layer
    subgraph "User Interface Layer"
        UI[Input/Output Handler]
        API[API Endpoints]
        Stream[Streaming Handler]
    end

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        Orch[Core Orchestrator]:::core
        Router[Request Router]:::core
        Context[Context Manager]:::core
        Class[Classification System]:::system
    end

    %% Agent Layer
    subgraph "Agent Layer"
        Registry[Agent Registry]:::agent
        
        subgraph "Built-in Agents"
            Bedrock[Bedrock Agent]:::agent
            OpenAI[OpenAI Agent]:::agent
            Anthropic[Anthropic Agent]:::agent
            Lambda[Lambda Agent]:::agent
            Chain[Chain Agent]:::agent
        end
        
        Tools[Tool Integration]:::agent
        Processor[Response Processor]:::agent
    end

    %% Storage Layer
    subgraph "Storage Layer"
        StorageInterface[Storage Interface]:::storage
        DynamoDB[DynamoDB Storage]:::storage
        SQL[SQL Storage]:::storage
        InMemory[In-Memory Storage]:::storage
    end

    %% External Services Layer
    subgraph "External Services"
        AWS[AWS Services]:::external
        OpenAIAPI[OpenAI API]:::external
        AnthropicAPI[Anthropic API]:::external
    end

    %% Relationships
    UI --> Orch
    API --> Orch
    Stream --> Orch
    
    Orch --> Router
    Router --> Class
    Class --> Registry
    
    Registry --> Bedrock & OpenAI & Anthropic & Lambda & Chain
    
    Bedrock --> AWS
    OpenAI --> OpenAIAPI
    Anthropic --> AnthropicAPI
    
    Orch --> StorageInterface
    StorageInterface --> DynamoDB & SQL & InMemory
    
    Tools --> Registry
    Registry --> Processor
    Processor --> Stream

    %% Click events
    click Orch "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/orchestrator.py"
    click Registry "https://github.com/awslabs/multi-agent-orchestrator/tree/main/python/src/multi_agent_orchestrator/agents/"
    click Bedrock "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/agents/amazon_bedrock_agent.py"
    click OpenAI "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/agents/openai_agent.py"
    click Anthropic "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/agents/anthropic_agent.py"
    click Lambda "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/agents/lambda_agent.py"
    click Chain "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/agents/chain_agent.py"
    click Class "https://github.com/awslabs/multi-agent-orchestrator/tree/main/python/src/multi_agent_orchestrator/classifiers/"
    click StorageInterface "https://github.com/awslabs/multi-agent-orchestrator/tree/main/python/src/multi_agent_orchestrator/storage/"
    click DynamoDB "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/storage/dynamodb_chat_storage.py"
    click SQL "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/storage/sql_chat_storage.py"
    click InMemory "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/storage/in_memory_chat_storage.py"
    click Tools "https://github.com/awslabs/multi-agent-orchestrator/blob/main/python/src/multi_agent_orchestrator/utils/tool.py"
```
