# quasarbrains/simple-agent architecture

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

- Interactive diagram: https://gitdiagram.com/quasarbrains/simple-agent
- Repository: https://github.com/quasarbrains/simple-agent

## Overview

Simple Agent is a conversational LLM agent whose principal loop gathers environmental context, recalls memory and goals, asks a model to reason, then executes returned tool calls or presents a reply. Its runtime also supports selectable model providers, persistent vector-store memory, role-specific tool sets, and task tracking. The graph follows relationships shown in excerpts or explicitly documented in the README; some unsampled implementations are represented by their existing directories, and uncertain wiring is omitted.

Main entry points: [`agent/agent.py`](https://github.com/quasarbrains/simple-agent/blob/trunk/agent/agent.py) (Agent loop), [`simple-agent.py`](https://github.com/quasarbrains/simple-agent/blob/trunk/simple-agent.py) (CLI interaction), [`tools/index.py`](https://github.com/quasarbrains/simple-agent/blob/trunk/tools/index.py) (Tool registry and runner), [`llms`](https://github.com/quasarbrains/simple-agent/tree/trunk/llms) (Provider adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Agent runtime"]
  node_entry["CLI interaction<br/>[simple-agent.py]"]
  node_agent["Agent loop<br/>[agent.py]"]
end

subgraph group_reasoning["Reasoning and memory"]
  node_environment["Environment perception<br/>[environment.py]"]
  node_agency["Task agency<br/>[agency.py]"]
  node_memory_engine["Memory engine<br/>[memory.py]"]
  node_vector_api["Vector store interface<br/>[vector_store.py]"]
  node_vector_store[("Simple vector store")]
end

subgraph group_providers["Model providers"]
  node_llm["LLM interface<br/>[llm.py]"]
  node_provider_adapters["Provider adapters"]
end

subgraph group_capabilities["Tools and roles"]
  node_toolbox["Tool registry and runner<br/>[index.py]"]
  node_core_tools["Core tools"]
  node_roles["Role definitions"]
  node_identity["Role switching<br/>[identity.py]"]
end

subgraph group_events["Events and output"]
  node_pubsub["Event bus<br/>[pubsub.py]"]
end

node_user(("User"))
node_external_model{{"Model APIs"}}
node_external_web{{"Web and search services"}}

node_user -->|"sends input"| node_entry
node_entry -->|"starts"| node_agent
node_entry -->|"selects provider"| node_provider_adapters
node_entry -->|"selects store"| node_vector_store
node_agent -->|"reads perception"| node_environment
node_agent -->|"queries memory"| node_memory_engine
node_agent -->|"reads tasks"| node_agency
node_agent -->|"requests response"| node_llm
node_agent -->|"runs tool calls"| node_toolbox
node_agent -->|"initializes roles"| node_identity
node_memory_engine -->|"uses store"| node_vector_api
node_vector_store -->|"implements"| node_vector_api
node_llm -->|"uses tool schemas"| node_toolbox
node_provider_adapters -->|"implements interface"| node_llm
node_provider_adapters -.->|"calls APIs"| node_external_model
node_toolbox -->|"dispatches calls"| node_core_tools
node_roles -->|"selects tool sets"| node_core_tools
node_identity -->|"switches roles"| node_roles
node_core_tools -.->|"searches and fetches"| node_external_web
node_entry -->|"subscribes events"| node_pubsub
node_agent -->|"publishes events"| node_pubsub
node_toolbox -->|"logs activity"| node_pubsub

click node_entry "https://github.com/quasarbrains/simple-agent/blob/trunk/simple-agent.py"
click node_agent "https://github.com/quasarbrains/simple-agent/blob/trunk/agent/agent.py"
click node_environment "https://github.com/quasarbrains/simple-agent/blob/trunk/agent/environment.py"
click node_agency "https://github.com/quasarbrains/simple-agent/blob/trunk/agent/agency.py"
click node_memory_engine "https://github.com/quasarbrains/simple-agent/blob/trunk/agent/memory.py"
click node_vector_api "https://github.com/quasarbrains/simple-agent/blob/trunk/memory/vector_store.py"
click node_vector_store "https://github.com/quasarbrains/simple-agent/blob/trunk/memory/simple_vector_store.py"
click node_llm "https://github.com/quasarbrains/simple-agent/blob/trunk/llms/llm.py"
click node_provider_adapters "https://github.com/quasarbrains/simple-agent/tree/trunk/llms"
click node_toolbox "https://github.com/quasarbrains/simple-agent/blob/trunk/tools/index.py"
click node_core_tools "https://github.com/quasarbrains/simple-agent/tree/trunk/tools/libraries/core"
click node_roles "https://github.com/quasarbrains/simple-agent/tree/trunk/roles/core"
click node_identity "https://github.com/quasarbrains/simple-agent/blob/trunk/roles/identity.py"
click node_pubsub "https://github.com/quasarbrains/simple-agent/blob/trunk/utils/pubsub.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_entry,node_agent,node_user toneBlue
class node_environment,node_agency,node_memory_engine,node_vector_api,node_vector_store toneAmber
class node_llm,node_provider_adapters,node_external_model toneMint
class node_toolbox,node_core_tools,node_roles,node_identity toneRose
class node_pubsub,node_external_web toneIndigo
```

## Components

### Agent runtime

- [CLI interaction](https://github.com/quasarbrains/simple-agent/blob/trunk/simple-agent.py): `simple-agent.py`
- [Agent loop](https://github.com/quasarbrains/simple-agent/blob/trunk/agent/agent.py): `agent/agent.py`

### Reasoning and memory

- [Environment perception](https://github.com/quasarbrains/simple-agent/blob/trunk/agent/environment.py): `agent/environment.py`
- [Task agency](https://github.com/quasarbrains/simple-agent/blob/trunk/agent/agency.py): `agent/agency.py`
- [Memory engine](https://github.com/quasarbrains/simple-agent/blob/trunk/agent/memory.py): `agent/memory.py`
- [Vector store interface](https://github.com/quasarbrains/simple-agent/blob/trunk/memory/vector_store.py): `memory/vector_store.py`
- [Simple vector store](https://github.com/quasarbrains/simple-agent/blob/trunk/memory/simple_vector_store.py): `memory/simple_vector_store.py`

### Model providers

- [LLM interface](https://github.com/quasarbrains/simple-agent/blob/trunk/llms/llm.py): `llms/llm.py`
- [Provider adapters](https://github.com/quasarbrains/simple-agent/tree/trunk/llms): `llms`

### Tools and roles

- [Tool registry and runner](https://github.com/quasarbrains/simple-agent/blob/trunk/tools/index.py): `tools/index.py`
- [Core tools](https://github.com/quasarbrains/simple-agent/tree/trunk/tools/libraries/core): `tools/libraries/core`
- [Role definitions](https://github.com/quasarbrains/simple-agent/tree/trunk/roles/core): `roles/core`
- [Role switching](https://github.com/quasarbrains/simple-agent/blob/trunk/roles/identity.py): `roles/identity.py`

### Events and output

- [Event bus](https://github.com/quasarbrains/simple-agent/blob/trunk/utils/pubsub.py): `utils/pubsub.py`

### Other components

- **User**
- **Model APIs**
- **Web and search services**

## Connections

- User → CLI interaction: sends input (evidence: `simple-agent.py`)
- CLI interaction → Agent loop: starts (evidence: `simple-agent.py`)
- CLI interaction → Provider adapters: selects provider (evidence: `simple-agent.py`)
- CLI interaction → Simple vector store: selects store (evidence: `simple-agent.py`)
- Agent loop → Environment perception: reads perception (evidence: `agent/agent.py`)
- Agent loop → Memory engine: queries memory (evidence: `agent/agent.py`)
- Agent loop → Task agency: reads tasks (evidence: `agent/agent.py`)
- Agent loop → LLM interface: requests response (evidence: `agent/agent.py`)
- Agent loop → Tool registry and runner: runs tool calls (evidence: `agent/agent.py`)
- Agent loop → Role switching: initializes roles (evidence: `agent/agent.py`)
- Memory engine → Vector store interface: uses store (evidence: `agent/memory.py`)
- Simple vector store → Vector store interface: implements (evidence: `memory/simple_vector_store.py`)
- LLM interface → Tool registry and runner: uses tool schemas (evidence: `llms/llm.py`)
- Provider adapters → LLM interface: implements interface (evidence: `llms/anthropic.py`)
- Provider adapters → Model APIs: calls APIs
- Tool registry and runner → Core tools: dispatches calls (evidence: `tools/index.py`)
- Role definitions → Core tools: selects tool sets (evidence: `roles/core/researcher.py`)
- Role switching → Role definitions: switches roles (evidence: `roles/identity.py`)
- Core tools → Web and search services: searches and fetches
- CLI interaction → Event bus: subscribes events (evidence: `simple-agent.py`)
- Agent loop → Event bus: publishes events (evidence: `agent/agent.py`)
- Tool registry and runner → Event bus: logs activity (evidence: `tools/index.py`)
