# letta-ai/agent-file architecture

> Architecture diagram of the GitHub repository letta-ai/agent-file, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/letta-ai/agent-file
- Repository: https://github.com/letta-ai/agent-file

## Overview

##### Main Components
- Repository & Distribution:
– A central repository that stores the source code, sample agents, and the .af files.
– Related directories: assets, CITATION.cff, LICENSE, README.md.
- Agent Examples:
– Separate modules for each agent type (e.g., “memgpt_agent”, “deep_research_agent”, “customer_service_agent”, “workflow_agent”, “composio_github_star_agent”).
– Each module contains two main artifacts: the Python code (which implements the agent’s behavior) and its corresponding .af file which encapsulates the agent’s state.
- Import/Export Mechanisms:
– A set of SDK examples and API usage (via cURL, Node.js, and Python) demonstrating how the .af files are imported into and exported from a Letta Server.
– This represents the integration layer between the static agent files in the repository and their runtime instantiation in a Letta environment (or any framework that supports .af).

##### Relationships and Data Flow
- Agent Files (.af):
- Agent Development & Consumption:
– Developers create or edit agent definitions through the provided Python scripts accompanied by the .af files.
– These files can be imported using Letta’s ADE, REST API, Python SDK, or the TypeScript SDK.
- Communication Flow:
- External Services and Integrations:
– Label these interactions clearly to indicate that these agents might call external APIs when deployed.

##### Architectural Patterns and Design Principles
- Modularity:
– Represent each sample agent as an independent module with its own directory and associated code/af file.
- Standardization via .af:
– Highlight that the .af file is the standardized artifact capturing all details needed to re-create the agent.
- Portability and Extensibility:
– Indicate that these .af files are designed to be framework agnostic – they follow a consistent schema to allow for easy migration and versioning.
- SDK/API Driven Interaction:
– Incorporate components for API endpoints (import/export endpoints on Letta Server) and demonstration code blocks (for Node.js, Python, etc.)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Repository & Distribution Layer
    subgraph "Repository & Distribution"
        A["Repository Assets\n(assets, CITATION.cff, LICENSE, README.md)"]:::repo
        B["MemGPT Agent"]:::agent
        C["Deep Research Agent"]:::agent
        D["Customer Service Agent"]:::agent
        E["Workflow Agent"]:::agent
        F["Composio GitHub Star Agent"]:::agent
    end

    %% Common Agent File (.af) Component
    G["Agent File (.af) Schema"]:::af

    %% Letta Server Layer
    H["Letta Server (Import/Export API)"]:::server

    %% SDK / API Integration Layer
    I["SDK Examples\n(Python, Node.js, cURL)"]:::integration

    %% External Service
    J["GitHub API"]:::external

    %% Connections from Agent Modules to the standardized .af file
    B -->|"contains"| G
    C -->|"contains"| G
    D -->|"contains"| G
    E -->|"contains"| G
    F -->|"contains"| G

    %% Data flow: Import and Export processes
    G -->|"import"| H
    H -->|"export"| A

    %% Integration interactions with Letta Server
    I -->|"API_calls"| H

    %% External API call from Composio Agent
    F -->|"calls"| J

    %% Click Events for Repository & Agent Modules
    click A "https://github.com/letta-ai/agent-file/tree/main/assets"
    click B "https://github.com/letta-ai/agent-file/tree/main/memgpt_agent"
    click C "https://github.com/letta-ai/agent-file/tree/main/deep_research_agent"
    click D "https://github.com/letta-ai/agent-file/tree/main/customer_service_agent"
    click E "https://github.com/letta-ai/agent-file/tree/main/workflow_agent"
    click F "https://github.com/letta-ai/agent-file/tree/main/composio_github_star_agent"

    %% Styling
    classDef repo fill:#f4d03f,stroke:#333,stroke-width:2px;
    classDef agent fill:#85c1e9,stroke:#333,stroke-width:2px;
    classDef af fill:#58d68d,stroke:#333,stroke-width:2px;
    classDef server fill:#f1948a,stroke:#333,stroke-width:2px;
    classDef integration fill:#bb8fce,stroke:#333,stroke-width:2px;
    classDef external fill:#aed6f1,stroke:#333,stroke-width:2px;
```
