# reworkd/agentgpt architecture

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

- Interactive diagram: https://gitdiagram.com/reworkd/agentgpt
- Repository: https://github.com/reworkd/agentgpt

## Overview

AgentGPT is a browser-based autonomous-agent product: users configure an agent and goal, then the agent plans tasks, executes tools, and can continue learning from results. The repository separates a Next.js interface and API client from a FastAPI platform that provides agent execution, model selection, tool integrations, authentication, and OAuth-backed credentials. The README documents the product workflow; source excerpts show selected API routing and agent-service internals. Several frontend-to-platform links and unsampled capabilities are shown only as unverified connections.

Main entry points: [`platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py`](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py) (Agent service), [`platform/reworkd_platform/web/api/router.py`](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/router.py) (API routes), [`platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py`](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py) (Service provider), [`next/src/pages/agent/index.tsx`](https://github.com/reworkd/agentgpt/blob/main/next/src/pages/agent/index.tsx) (Agent workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser application"]
  node_agentui["Agent workspace<br/>[index.tsx]"]
  node_taskui["Task sidebar<br/>[TaskSidebar.tsx]"]
  node_agentclient["Agent client"]
  node_templates["Agent templates<br/>[templates.tsx]"]
end

subgraph group_api["Platform API"]
  node_webapi["API application<br/>[application.py]"]
  node_routing["API routes<br/>[router.py]"]
  node_agentapi["Agent API"]
  node_modelsapi["Model endpoints"]
end

subgraph group_agent["Agent execution"]
  node_agentprovider["Service provider"]
  node_agentservice["Agent service"]
  node_analysis["Task analysis<br/>[analysis.py]"]
  node_prompts["Agent prompts<br/>[prompts.py]"]
  node_tools["Agent tools"]
  node_tokenizer["Token service<br/>[token_service.py]"]
  node_modelsettings["Run settings<br/>[agent.py]"]
end

subgraph group_identity["Identity and credentials"]
  node_authapi["Auth endpoints"]
  node_oauthinstall["OAuth installs"]
  node_oauthcrud["OAuth credentials<br/>[oauth.py]"]
  node_oauthmodel[("Credential records<br/>[auth.py]")]
end

subgraph group_setup["Local setup"]
  node_cli["Setup CLI<br/>[index.js]"]
  node_envgenerator["Environment setup<br/>[envGenerator.js]"]
end

node_user(("Agent user"))

node_user -->|"configures goal"| node_agentui
node_agentui -.->|"manages tasks"| node_taskui
node_agentui -.->|"starts agent"| node_agentclient
node_agentclient -.->|"requests agent work"| node_agentapi
node_webapi -->|"mounts routes"| node_routing
node_routing -->|"registers routes"| node_agentapi
node_routing -->|"registers routes"| node_authapi
node_routing -->|"registers routes"| node_modelsapi
node_agentapi -.->|"selects service"| node_agentprovider
node_agentprovider -->|"provides implementation"| node_agentservice
node_agentservice -->|"returns analysis"| node_analysis
node_agentservice -->|"formats prompts"| node_prompts
node_agentservice -->|"dispatches tool"| node_tools
node_agentservice -->|"limits tokens"| node_tokenizer
node_agentprovider -->|"uses settings"| node_modelsettings
node_agentprovider -->|"injects credentials"| node_oauthcrud
node_oauthinstall -->|"stores installations"| node_oauthcrud
node_oauthcrud -->|"queries records"| node_oauthmodel
node_user -->|"runs setup"| node_cli
node_cli -->|"generates environment"| node_envgenerator
node_user -.->|"selects templates"| node_templates

click node_agentui "https://github.com/reworkd/agentgpt/blob/main/next/src/pages/agent/index.tsx"
click node_taskui "https://github.com/reworkd/agentgpt/blob/main/next/src/components/drawer/TaskSidebar.tsx"
click node_agentclient "https://github.com/reworkd/agentgpt/tree/main/next/src/services/agent"
click node_webapi "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/application.py"
click node_routing "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/router.py"
click node_agentapi "https://github.com/reworkd/agentgpt/tree/main/platform/reworkd_platform/web/api/agent"
click node_agentprovider "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py"
click node_agentservice "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py"
click node_analysis "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/analysis.py"
click node_prompts "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/prompts.py"
click node_tools "https://github.com/reworkd/agentgpt/tree/main/platform/reworkd_platform/web/api/agent/tools"
click node_tokenizer "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/services/tokenizer/token_service.py"
click node_modelsettings "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/schemas/agent.py"
click node_modelsapi "https://github.com/reworkd/agentgpt/tree/main/platform/reworkd_platform/web/api/models"
click node_authapi "https://github.com/reworkd/agentgpt/tree/main/platform/reworkd_platform/web/api/auth"
click node_oauthinstall "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/services/oauth_installers.py"
click node_oauthcrud "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/db/crud/oauth.py"
click node_oauthmodel "https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/db/models/auth.py"
click node_templates "https://github.com/reworkd/agentgpt/blob/main/next/src/pages/templates.tsx"
click node_cli "https://github.com/reworkd/agentgpt/blob/main/cli/src/index.js"
click node_envgenerator "https://github.com/reworkd/agentgpt/blob/main/cli/src/envGenerator.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_agentui,node_taskui,node_agentclient,node_templates,node_user toneBlue
class node_webapi,node_routing,node_agentapi,node_modelsapi toneAmber
class node_agentprovider,node_agentservice,node_analysis,node_prompts,node_tools,node_tokenizer,node_modelsettings toneMint
class node_authapi,node_oauthinstall,node_oauthcrud,node_oauthmodel toneRose
class node_cli,node_envgenerator toneIndigo
```

## Components

### Browser application

- [Agent workspace](https://github.com/reworkd/agentgpt/blob/main/next/src/pages/agent/index.tsx): `next/src/pages/agent/index.tsx`
- [Task sidebar](https://github.com/reworkd/agentgpt/blob/main/next/src/components/drawer/TaskSidebar.tsx): `next/src/components/drawer/TaskSidebar.tsx`
- [Agent client](https://github.com/reworkd/agentgpt/tree/main/next/src/services/agent): `next/src/services/agent`
- [Agent templates](https://github.com/reworkd/agentgpt/blob/main/next/src/pages/templates.tsx): `next/src/pages/templates.tsx`

### Platform API

- [API application](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/application.py): `platform/reworkd_platform/web/application.py`
- [API routes](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/router.py): `platform/reworkd_platform/web/api/router.py`
- [Agent API](https://github.com/reworkd/agentgpt/tree/main/platform/reworkd_platform/web/api/agent): `platform/reworkd_platform/web/api/agent`
- [Model endpoints](https://github.com/reworkd/agentgpt/tree/main/platform/reworkd_platform/web/api/models): `platform/reworkd_platform/web/api/models`

### Agent execution

- [Service provider](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py): `platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py`
- [Agent service](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py): `platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py`
- [Task analysis](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/analysis.py): `platform/reworkd_platform/web/api/agent/analysis.py`
- [Agent prompts](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/web/api/agent/prompts.py): `platform/reworkd_platform/web/api/agent/prompts.py`
- [Agent tools](https://github.com/reworkd/agentgpt/tree/main/platform/reworkd_platform/web/api/agent/tools): `platform/reworkd_platform/web/api/agent/tools`
- [Token service](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/services/tokenizer/token_service.py): `platform/reworkd_platform/services/tokenizer/token_service.py`
- [Run settings](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/schemas/agent.py): `platform/reworkd_platform/schemas/agent.py`

### Identity and credentials

- [Auth endpoints](https://github.com/reworkd/agentgpt/tree/main/platform/reworkd_platform/web/api/auth): `platform/reworkd_platform/web/api/auth`
- [OAuth installs](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/services/oauth_installers.py): `platform/reworkd_platform/services/oauth_installers.py`
- [OAuth credentials](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/db/crud/oauth.py): `platform/reworkd_platform/db/crud/oauth.py`
- [Credential records](https://github.com/reworkd/agentgpt/blob/main/platform/reworkd_platform/db/models/auth.py): `platform/reworkd_platform/db/models/auth.py`

### Local setup

- [Setup CLI](https://github.com/reworkd/agentgpt/blob/main/cli/src/index.js): `cli/src/index.js`
- [Environment setup](https://github.com/reworkd/agentgpt/blob/main/cli/src/envGenerator.js): `cli/src/envGenerator.js`

### Other components

- **Agent user**

## Connections

- Agent user → Agent workspace: configures goal
- Agent workspace → Task sidebar: manages tasks
- Agent workspace → Agent client: starts agent
- Agent client → Agent API: requests agent work
- API application → API routes: mounts routes (evidence: `platform/reworkd_platform/web/application.py`)
- API routes → Agent API: registers routes (evidence: `platform/reworkd_platform/web/api/router.py`)
- API routes → Auth endpoints: registers routes (evidence: `platform/reworkd_platform/web/api/router.py`)
- API routes → Model endpoints: registers routes (evidence: `platform/reworkd_platform/web/api/router.py`)
- Agent API → Service provider: selects service (evidence: `platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py`)
- Service provider → Agent service: provides implementation (evidence: `platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py`)
- Agent service → Task analysis: returns analysis (evidence: `platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py`)
- Agent service → Agent prompts: formats prompts (evidence: `platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py`)
- Agent service → Agent tools: dispatches tool (evidence: `platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py`)
- Agent service → Token service: limits tokens (evidence: `platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py`)
- Service provider → Run settings: uses settings (evidence: `platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py`)
- Service provider → OAuth credentials: injects credentials (evidence: `platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py`)
- OAuth installs → OAuth credentials: stores installations (evidence: `platform/reworkd_platform/services/oauth_installers.py`)
- OAuth credentials → Credential records: queries records (evidence: `platform/reworkd_platform/db/crud/oauth.py`)
- Agent user → Setup CLI: runs setup
- Setup CLI → Environment setup: generates environment (evidence: `cli/src/index.js`)
- Agent user → Agent templates: selects templates
