# eteissonniere/go-autogpt architecture

> Architecture diagram of the GitHub repository eteissonniere/go-autogpt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eteissonniere/go-autogpt
- Repository: https://github.com/eteissonniere/go-autogpt

## Overview

##### Project type and purpose
- This is a Go-based CLI application and library providing “AutoGPT-style” agents.
- Its purpose is to let a user supply a natural-language task, then automatically plan and execute steps (via sub-agents) using GPT-3.5-Turbo (or another LLM) plus a set of local commands (filesystem, shell, etc.).

##### High-level architecture
- Frontend: `cli` package (commands `run`, `replay`, main entrypoint)
- Core agents:
- Mastermind (coordinates planning + execution)
- Planner sub-agent(s) (in `agents/planner` and `prompt/planners`)
- Executor sub-agent(s) (in `agents/executor` and `prompt/executors`)
- Prompt management (templates, commands, types in `prompt/…`)
- LLM integration (`llms` package, `openai.go`)
- Logging & diagnostics (`misc/logging`)
- Developer container config (`.devcontainer`)

##### Component relationships
- CLI receives user task → invokes Mastermind agent
- Mastermind calls Planner agent → uses prompt templates + LLM client → returns plan (list of steps)
- Mastermind feeds plan to Executor agent → each step triggers a prompt+LLM or concrete shell/fs call
- All components emit logs via `misc/logging`
- LLM client (in `llms`) is the sole external service (OpenAI API)

##### Architectural patterns and principles
- Hexagonal / Clean architecture:
- Ports & adapters for LLM (interface → `openai.go`)
- Dependency injection for agents
- Single responsibility: each package has a narrow focus (prompt commands vs. planner logic vs. executor logic).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        CLI["CLI Frontend\n(cli package)"]:::frontend
    end

    %% Agent Layer
    subgraph "Agent Layer"
        Mastermind["Mastermind Agent\n(agents/mastermind)"]:::core
        Planner["Planner Sub-agent\n(agents/planner)"]:::core
        Executor["Executor Sub-agent\n(agents/executor)"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        PlannerTpls["Planner Prompt Templates\n(prompt/planners)"]:::infra
        ExecutorTpls["Executor Prompt Templates\n(prompt/executors)"]:::infra
        PromptCmds["Prompt Command Definitions\n(prompt/commands)"]:::infra
        PromptUtils["Prompt Internal Utilities\n(prompt/internal)"]:::infra
        LLM["LLM Client\n(llms)"]:::infra
        Logging["Logging Infrastructure\n(misc/logging)"]:::infra
        Devcontainer["Dev Container\n(.devcontainer)"]:::infra
    end

    %% Flows
    CLI -->|"Run(taskString)"| Mastermind
    Mastermind -->|"GeneratePlan(task)"| Planner
    Planner -->|"uses templates"| PlannerTpls
    PlannerTpls -->|"call API"| LLM
    LLM -->|"returns response"| Planner
    Mastermind -->|"ExecuteSteps(plan)"| Executor
    Executor -->|"uses templates"| ExecutorTpls
    Executor -->|"exec commands"| PromptCmds
    ExecutorTpls -->|"call API"| LLM
    CLI -->|logs| Logging
    Mastermind -->|logs| Logging
    Planner -->|logs| Logging
    Executor -->|logs| Logging

    %% Click Events
    click CLI "https://github.com/eteissonniere/go-autogpt/blob/main/cli/main.go"
    click CLI "https://github.com/eteissonniere/go-autogpt/blob/main/cli/cmd_run.go"
    click CLI "https://github.com/eteissonniere/go-autogpt/blob/main/cli/cmd_replay.go"
    click Mastermind "https://github.com/eteissonniere/go-autogpt/blob/main/agents/mastermind/agent.go"
    click Planner "https://github.com/eteissonniere/go-autogpt/blob/main/agents/planner/agent.go"
    click PlannerTpls "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/planners/basic.go"
    click PlannerTpls "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/planners/types.go"
    click PlannerTpls "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/planners/doc.go"
    click Executor "https://github.com/eteissonniere/go-autogpt/blob/main/agents/executor/agent.go"
    click ExecutorTpls "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/executors/basic.go"
    click ExecutorTpls "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/executors/types.go"
    click ExecutorTpls "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/executors/doc.go"
    click PromptCmds "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/commands/command.go"
    click PromptCmds "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/commands/agent_error.go"
    click PromptCmds "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/commands/default.go"
    click PromptCmds "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/commands/files.go"
    click PromptCmds "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/commands/google.go"
    click PromptCmds "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/commands/nothing.go"
    click PromptCmds "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/commands/shell.go"
    click PromptCmds "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/commands/shutdown.go"
    click PromptUtils "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/internal/base.go"
    click PromptUtils "https://github.com/eteissonniere/go-autogpt/blob/main/prompt/prompt.go"
    click LLM "https://github.com/eteissonniere/go-autogpt/blob/main/llms/openai.go"
    click LLM "https://github.com/eteissonniere/go-autogpt/blob/main/llms/model.go"
    click Logging "https://github.com/eteissonniere/go-autogpt/blob/main/misc/logging/zerolog.go"
    click Logging "https://github.com/eteissonniere/go-autogpt/blob/main/misc/logging/export.go"
    click Devcontainer "https://github.com/eteissonniere/go-autogpt/blob/main/.devcontainer/devcontainer.json"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:1px
    classDef core fill:#bbf,stroke:#333,stroke-width:1px
    classDef infra fill:#bfb,stroke:#333,stroke-width:1px
    classDef external fill:#fbf,stroke:#333,stroke-width:1px
```
