# aiplanethub/openagi architecture

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

- Interactive diagram: https://gitdiagram.com/aiplanethub/openagi
- Repository: https://github.com/aiplanethub/openagi

## Overview

#### Purpose and entry points
OpenAGI is a Python 3.9–3.11 framework for building autonomous or worker-based LLM agents. The main programmatic entry point is the `Admin` orchestrator, used with a planner, LLM adapter, optional memory, and action classes. Packaging and a CLI are rooted at `pyproject.toml`, `src/openagi/__init__.py`, and `src/openagi/cli.py`.

#### Admin orchestration
`Admin` is the top-level control boundary: callers configure it, optionally register specialized workers, then invoke `run(query, description)`. It coordinates planning, execution, memory use, and result delivery for both manual multi-agent and autonomous modes.
- `src/openagi/agent.py`
- `src/openagi/worker.py`
- `src/openagi/tasks/task.py`

#### Planning and task lifecycle
A planner converts the requested outcome into executable tasks. The default task decomposer supports autonomous operation and human-intervention settings; alternative planning strategies include LATS and Reflexion. Task models and list management form the shared handoff between planning and workers.
- `src/openagi/planner/task_decomposer.py`
- `src/openagi/planner/LATS.py`
- `src/openagi/tasks/lists.py`

#### Worker execution boundary
Workers encapsulate a role, instructions, permitted actions, and iteration limits. In assigned-worker mode, Admin delegates planned tasks to these role-specific agents. In autonomous mode, the system can execute without predeclared workers, selecting available capabilities through the orchestration/planning path.
- `src/openagi/worker.py`
- `src/openagi/agent.py`
- `src/openagi/prompts/worker_task_execution.py`

#### LLM abstraction and providers
A provider-neutral LLM layer isolates orchestration and planners from model APIs. `base.py` defines the common contract; concrete adapters cover OpenAI, Gemini, Claude, Groq, Ollama, Azure, Cohere, Mistral, Hugging Face, xAI, Cerebras, and SambaNova. Runtime credentials and model settings are supplied through environment configuration.
- `src/openagi/llms/base.py`
- `src/openagi/llms/openai.py`
- `src/openagi/llms/gemini.py`

#### Actions and external integrations
Actions are the agent’s side-effect boundary. Common capabilities include console/file/human-input operations, output compression/formatting, and retrieval. Tool adapters integrate external search, content, document, and media services such as DuckDuckGo, Tavily, Google, GitHub, arXiv, PubMed, Reddit, DALL·E, and YouTube.
- `src/openagi/actions/base.py`
- `src/openagi/actions/tools/ddg_search.py`
- `src/openagi/actions/tools/tavilyqasearch.py`

#### Context, memory, and storage
Memory provides session and optional long-term context across runs. Long-term/vector storage is abstracted behind storage interfaces, with Chroma as the supplied backend; prompts include long-term-memory and summarization stages to manage context passed to LLMs.
- `src/openagi/memory/memory.py`
- `src/openagi/memory/sessiondict.py`
- `src/openagi/storage/chroma.py`

#### Primary flow
Application code constructs an LLM, planner, actions, optional memory, and optionally workers; it then calls `Admin.run`. Admin/planner clarifies and decomposes the request, tasks flow to workers or autonomous execution, workers invoke approved actions and LLMs, and outputs are summarized/formatted into the returned response. Human input is an explicit action/planner control point rather than an implicit UI dependency.

Main entry points: [`src/openagi/agent.py`](https://github.com/aiplanethub/openagi/blob/main/src/openagi/agent.py) (Admin), [`src/openagi/worker.py`](https://github.com/aiplanethub/openagi/blob/main/src/openagi/worker.py) (Worker), [`src/openagi/memory/memory.py`](https://github.com/aiplanethub/openagi/blob/main/src/openagi/memory/memory.py) (Memory), [`src/openagi/planner/task_decomposer.py`](https://github.com/aiplanethub/openagi/blob/main/src/openagi/planner/task_decomposer.py) (Task Decomposer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry Points"]
  node_application["Application Code<br/>caller"]
  node_cli["CLI<br/>command entry<br/>[cli.py]"]
end

subgraph group_orchestration["Orchestration"]
  node_admin{{"Admin<br/>orchestrator<br/>[agent.py]"}}
  node_task["Task Model<br/>shared task contract<br/>[task.py]"]
  node_task_list["Task Lists<br/>task lifecycle<br/>[lists.py]"]
  node_response["Returned Response<br/>result"]
end

subgraph group_execution["Execution"]
  node_worker{{"Worker<br/>role agent<br/>[worker.py]"}}
  node_execution_prompt["Task Execution Prompt<br/>prompt template"]
end

subgraph group_intelligence["Planning &amp; Models"]
  node_task_decomposer["Task Decomposer<br/>default planner<br/>[task_decomposer.py]"]
  node_planning_strategies["LATS / Reflexion<br/>planning strategy<br/>[LATS.py]"]
  node_llm_contract["LLM Contract<br/>provider abstraction<br/>[base.py]"]
  node_llm_providers["LLM Providers<br/>model adapters<br/>[openai.py]"]
end

subgraph group_context["Context &amp; Integrations"]
  node_actions{{"Actions<br/>side-effect boundary<br/>[base.py]"}}
  node_search_tools["Search Tool Adapters<br/>external integration<br/>[ddg_search.py]"]
  node_human_input["Human Input<br/>action control point"]
  node_memory["Memory<br/>context manager<br/>[memory.py]"]
  node_session_context[("Session Context<br/>session store<br/>[sessiondict.py]")]
  node_chroma[("Chroma Storage<br/>vector backend<br/>[chroma.py]")]
end

node_application -->|"configures and runs"| node_admin
node_cli -->|"invokes"| node_admin
node_admin -->|"plans request"| node_task_decomposer
node_admin -.->|"may select"| node_planning_strategies
node_task_decomposer -->|"creates"| node_task
node_planning_strategies -->|"creates"| node_task
node_task -->|"managed in"| node_task_list
node_admin -->|"coordinates"| node_task_list
node_admin -->|"delegates tasks"| node_worker
node_task_list -->|"supplies planned work"| node_worker
node_worker -->|"uses"| node_execution_prompt
node_worker -->|"invokes approved actions"| node_actions
node_worker -->|"requests reasoning"| node_llm_contract
node_task_decomposer -->|"uses for planning"| node_llm_contract
node_llm_contract -->|"implemented by"| node_llm_providers
node_actions -->|"includes adapters"| node_search_tools
node_actions -->|"can request"| node_human_input
node_admin -->|"reads and updates"| node_memory
node_memory -->|"maintains"| node_session_context
node_memory -.->|"persists long-term context"| node_chroma
node_worker -->|"uses context"| node_memory
node_admin -->|"returns formatted result"| node_response

click node_cli "https://github.com/aiplanethub/openagi/blob/main/src/openagi/cli.py"
click node_admin "https://github.com/aiplanethub/openagi/blob/main/src/openagi/agent.py"
click node_task "https://github.com/aiplanethub/openagi/blob/main/src/openagi/tasks/task.py"
click node_task_list "https://github.com/aiplanethub/openagi/blob/main/src/openagi/tasks/lists.py"
click node_task_decomposer "https://github.com/aiplanethub/openagi/blob/main/src/openagi/planner/task_decomposer.py"
click node_planning_strategies "https://github.com/aiplanethub/openagi/blob/main/src/openagi/planner/LATS.py"
click node_worker "https://github.com/aiplanethub/openagi/blob/main/src/openagi/worker.py"
click node_execution_prompt "https://github.com/aiplanethub/openagi/blob/main/src/openagi/prompts/worker_task_execution.py"
click node_llm_contract "https://github.com/aiplanethub/openagi/blob/main/src/openagi/llms/base.py"
click node_llm_providers "https://github.com/aiplanethub/openagi/blob/main/src/openagi/llms/openai.py"
click node_actions "https://github.com/aiplanethub/openagi/blob/main/src/openagi/actions/base.py"
click node_search_tools "https://github.com/aiplanethub/openagi/blob/main/src/openagi/actions/tools/ddg_search.py"
click node_memory "https://github.com/aiplanethub/openagi/blob/main/src/openagi/memory/memory.py"
click node_session_context "https://github.com/aiplanethub/openagi/blob/main/src/openagi/memory/sessiondict.py"
click node_chroma "https://github.com/aiplanethub/openagi/blob/main/src/openagi/storage/chroma.py"

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_application,node_cli toneBlue
class node_admin,node_task,node_task_list,node_response toneAmber
class node_worker,node_execution_prompt toneMint
class node_task_decomposer,node_planning_strategies,node_llm_contract,node_llm_providers toneRose
class node_actions,node_search_tools,node_human_input,node_memory,node_session_context,node_chroma toneIndigo
```

## Components

### Entry Points

- **Application Code**: caller · Constructs framework components and calls Admin.run.
- [CLI](https://github.com/aiplanethub/openagi/blob/main/src/openagi/cli.py): command entry · `src/openagi/cli.py`

### Orchestration

- [Admin](https://github.com/aiplanethub/openagi/blob/main/src/openagi/agent.py): orchestrator · Top-level boundary for planning, execution, memory, and responses. · `src/openagi/agent.py`
- [Task Model](https://github.com/aiplanethub/openagi/blob/main/src/openagi/tasks/task.py): shared task contract · `src/openagi/tasks/task.py`
- [Task Lists](https://github.com/aiplanethub/openagi/blob/main/src/openagi/tasks/lists.py): task lifecycle · `src/openagi/tasks/lists.py`
- **Returned Response**: result · Summarized and formatted run output.

### Execution

- [Worker](https://github.com/aiplanethub/openagi/blob/main/src/openagi/worker.py): role agent · Executes assigned tasks within role, action, and iteration constraints. · `src/openagi/worker.py`
- [Task Execution Prompt](https://github.com/aiplanethub/openagi/blob/main/src/openagi/prompts/worker_task_execution.py): prompt template · `src/openagi/prompts/worker_task_execution.py`

### Planning & Models

- [Task Decomposer](https://github.com/aiplanethub/openagi/blob/main/src/openagi/planner/task_decomposer.py): default planner · Decomposes requests with autonomous and human-intervention settings. · `src/openagi/planner/task_decomposer.py`
- [LATS / Reflexion](https://github.com/aiplanethub/openagi/blob/main/src/openagi/planner/LATS.py): planning strategy · `src/openagi/planner/LATS.py`
- [LLM Contract](https://github.com/aiplanethub/openagi/blob/main/src/openagi/llms/base.py): provider abstraction · Provider-neutral interface used by orchestration and planning. · `src/openagi/llms/base.py`
- [LLM Providers](https://github.com/aiplanethub/openagi/blob/main/src/openagi/llms/openai.py): model adapters · Concrete adapters such as OpenAI and Gemini. · `src/openagi/llms/openai.py`

### Context & Integrations

- [Actions](https://github.com/aiplanethub/openagi/blob/main/src/openagi/actions/base.py): side-effect boundary · Approved capabilities for agent execution. · `src/openagi/actions/base.py`
- [Search Tool Adapters](https://github.com/aiplanethub/openagi/blob/main/src/openagi/actions/tools/ddg_search.py): external integration · Connects retrieval providers such as DuckDuckGo and Tavily. · `src/openagi/actions/tools/ddg_search.py`
- **Human Input**: action control point · Explicit intervention channel for planning or execution.
- [Memory](https://github.com/aiplanethub/openagi/blob/main/src/openagi/memory/memory.py): context manager · Maintains session and optional long-term context. · `src/openagi/memory/memory.py`
- [Session Context](https://github.com/aiplanethub/openagi/blob/main/src/openagi/memory/sessiondict.py): session store · `src/openagi/memory/sessiondict.py`
- [Chroma Storage](https://github.com/aiplanethub/openagi/blob/main/src/openagi/storage/chroma.py): vector backend · Optional long-term storage backend. · `src/openagi/storage/chroma.py`

## Connections

- Application Code → Admin: configures and runs
- CLI → Admin: invokes
- Admin → Task Decomposer: plans request
- Admin → LATS / Reflexion: may select
- Task Decomposer → Task Model: creates
- LATS / Reflexion → Task Model: creates
- Task Model → Task Lists: managed in
- Admin → Task Lists: coordinates
- Admin → Worker: delegates tasks
- Task Lists → Worker: supplies planned work
- Worker → Task Execution Prompt: uses
- Worker → Actions: invokes approved actions
- Worker → LLM Contract: requests reasoning
- Task Decomposer → LLM Contract: uses for planning
- LLM Contract → LLM Providers: implemented by
- Actions → Search Tool Adapters: includes adapters
- Actions → Human Input: can request
- Admin → Memory: reads and updates
- Memory → Session Context: maintains
- Memory → Chroma Storage: persists long-term context
- Worker → Memory: uses context
- Admin → Returned Response: returns formatted result
