# duongcoder04/hermes-agent architecture

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

- Interactive diagram: https://gitdiagram.com/duongcoder04/hermes-agent
- Repository: https://github.com/duongcoder04/hermes-agent

## Overview

Hermes Agent is a self-improving, multi-surface AI agent. A user starts a turn through the CLI/TUI or a messaging platform; the conversation loop builds context, calls a selected model, dispatches tools, and returns a response. Context compression and learning support ongoing sessions, while scheduled jobs and subagents extend work beyond a single turn. The graph combines sampled source references with README-documented capabilities; some feature wiring is documented but its implementation was not sampled, so those links cite the README.

Main entry points: [`agent/conversation_loop.py`](https://github.com/duongcoder04/hermes-agent/blob/main/agent/conversation_loop.py) (Conversation loop), [`tui_gateway/server.py`](https://github.com/duongcoder04/hermes-agent/blob/main/tui_gateway/server.py) (Messaging gateway), [`agent/tool_executor.py`](https://github.com/duongcoder04/hermes-agent/blob/main/agent/tool_executor.py) (Tool execution), [`hermes_cli/console_engine.py`](https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/console_engine.py) (Hermes CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["User surfaces"]
  node_cli["Hermes CLI<br/>[console_engine.py]"]
  node_tui["Terminal UI<br/>[turnController.ts]"]
  node_acp["ACP adapter<br/>[server.py]"]
  node_acp_cli["ACP command<br/>[acp.py]"]
end

subgraph group_runtime["Agent runtime"]
  node_loop["Conversation loop"]
  node_turnctx["Turn context<br/>[turn_context.py]"]
  node_prompt["Prompt builder<br/>[prompt_builder.py]"]
  node_delegation["Subagents"]
  node_config["Configuration<br/>[config.py]"]
  node_constants["Shared constants"]
  node_redaction["Data redaction<br/>[redact.py]"]
  node_process["Process compatibility"]
end

subgraph group_models["Models and context"]
  node_models["Model selection<br/>[model_switch.py]"]
  node_catalog["Model metadata<br/>[model_metadata.py]"]
  node_aux["Auxiliary model client"]
  node_compression["Context compression"]
  node_conversation_compression["Conversation compression"]
  node_model_list["Model catalog CLI<br/>[models.py]"]
end

subgraph group_tools["Tools and learning"]
  node_tools["Tool execution<br/>[tool_executor.py]"]
  node_environment["Terminal backends<br/>[local.py]"]
  node_spillover[("Large-result storage")]
  node_memory["Agent memory<br/>[memory_manager.py]"]
  node_skills["Skills and learning<br/>[learning_graph.py]"]
end

subgraph group_platform["Gateway and automation"]
  node_gateway["Messaging gateway<br/>[server.py]"]
  node_signal["Signal channel<br/>[signal.py]"]
  node_scheduler["Cron scheduler"]
  node_status["Gateway status<br/>[status.py]"]
end

node_user(("User"))

node_user -->|"starts a turn"| node_cli
node_user -->|"starts a turn"| node_tui
node_user -->|"sends messages"| node_gateway
node_cli -.->|"runs conversation"| node_loop
node_tui -->|"sends turn requests"| node_gateway
node_gateway -->|"runs conversation"| node_loop
node_signal -->|"carries messages"| node_gateway
node_loop -->|"builds prompt"| node_prompt
node_loop -->|"uses turn context"| node_turnctx
node_loop -->|"uses model metadata"| node_catalog
node_loop -->|"dispatches tools"| node_tools
node_loop -->|"compresses context"| node_compression
node_compression -->|"requests summaries"| node_aux
node_loop -->|"supports compression"| node_conversation_compression
node_models -.->|"selects model"| node_loop
node_model_list -.->|"lists models"| node_catalog
node_tools -->|"runs commands"| node_environment
node_tools -.->|"persists large output"| node_spillover
node_loop -->|"uses memory"| node_memory
node_loop -->|"creates and improves skills"| node_skills
node_loop -->|"spawns subagents"| node_delegation
node_scheduler -->|"delivers scheduled jobs"| node_gateway
node_config -.->|"configures runtime"| node_loop
node_constants -->|"provides shared settings"| node_config
node_redaction -.->|"sanitizes content"| node_loop
node_gateway -.->|"reports status"| node_status
node_acp_cli -.->|"starts adapter"| node_acp
node_process -->|"supports subprocesses"| node_cli

click node_cli "https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/console_engine.py"
click node_tui "https://github.com/duongcoder04/hermes-agent/blob/main/ui-tui/src/app/turnController.ts"
click node_gateway "https://github.com/duongcoder04/hermes-agent/blob/main/tui_gateway/server.py"
click node_signal "https://github.com/duongcoder04/hermes-agent/blob/main/gateway/platforms/signal.py"
click node_loop "https://github.com/duongcoder04/hermes-agent/blob/main/agent/conversation_loop.py"
click node_turnctx "https://github.com/duongcoder04/hermes-agent/blob/main/agent/turn_context.py"
click node_prompt "https://github.com/duongcoder04/hermes-agent/blob/main/agent/prompt_builder.py"
click node_models "https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/model_switch.py"
click node_catalog "https://github.com/duongcoder04/hermes-agent/blob/main/agent/model_metadata.py"
click node_aux "https://github.com/duongcoder04/hermes-agent/blob/main/agent/auxiliary_client.py"
click node_compression "https://github.com/duongcoder04/hermes-agent/blob/main/agent/context_compressor.py"
click node_conversation_compression "https://github.com/duongcoder04/hermes-agent/blob/main/agent/conversation_compression.py"
click node_tools "https://github.com/duongcoder04/hermes-agent/blob/main/agent/tool_executor.py"
click node_environment "https://github.com/duongcoder04/hermes-agent/blob/main/tools/environments/local.py"
click node_spillover "https://github.com/duongcoder04/hermes-agent/blob/main/tools/tool_result_storage.py"
click node_memory "https://github.com/duongcoder04/hermes-agent/blob/main/agent/memory_manager.py"
click node_skills "https://github.com/duongcoder04/hermes-agent/blob/main/agent/learning_graph.py"
click node_scheduler "https://github.com/duongcoder04/hermes-agent/blob/main/cron/scheduler_worker_env.py"
click node_delegation "https://github.com/duongcoder04/hermes-agent/blob/main/agent/subagent_lifecycle.py"
click node_config "https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/config.py"
click node_constants "https://github.com/duongcoder04/hermes-agent/blob/main/hermes_constants.py"
click node_redaction "https://github.com/duongcoder04/hermes-agent/blob/main/agent/redact.py"
click node_status "https://github.com/duongcoder04/hermes-agent/blob/main/gateway/status.py"
click node_acp "https://github.com/duongcoder04/hermes-agent/blob/main/acp_adapter/server.py"
click node_acp_cli "https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/subcommands/acp.py"
click node_process "https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/_subprocess_compat.py"
click node_model_list "https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/models.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_cli,node_tui,node_acp,node_acp_cli,node_user toneBlue
class node_loop,node_turnctx,node_prompt,node_delegation,node_config,node_constants,node_redaction,node_process toneAmber
class node_models,node_catalog,node_aux,node_compression,node_conversation_compression,node_model_list toneMint
class node_tools,node_environment,node_spillover,node_memory,node_skills toneRose
class node_gateway,node_signal,node_scheduler,node_status toneIndigo
```

## Components

### User surfaces

- [Hermes CLI](https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/console_engine.py): `hermes_cli/console_engine.py`
- [Terminal UI](https://github.com/duongcoder04/hermes-agent/blob/main/ui-tui/src/app/turnController.ts): `ui-tui/src/app/turnController.ts`
- [ACP adapter](https://github.com/duongcoder04/hermes-agent/blob/main/acp_adapter/server.py): `acp_adapter/server.py`
- [ACP command](https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/subcommands/acp.py): `hermes_cli/subcommands/acp.py`

### Agent runtime

- [Conversation loop](https://github.com/duongcoder04/hermes-agent/blob/main/agent/conversation_loop.py): `agent/conversation_loop.py`
- [Turn context](https://github.com/duongcoder04/hermes-agent/blob/main/agent/turn_context.py): `agent/turn_context.py`
- [Prompt builder](https://github.com/duongcoder04/hermes-agent/blob/main/agent/prompt_builder.py): `agent/prompt_builder.py`
- [Subagents](https://github.com/duongcoder04/hermes-agent/blob/main/agent/subagent_lifecycle.py): `agent/subagent_lifecycle.py`
- [Configuration](https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/config.py): `hermes_cli/config.py`
- [Shared constants](https://github.com/duongcoder04/hermes-agent/blob/main/hermes_constants.py): `hermes_constants.py`
- [Data redaction](https://github.com/duongcoder04/hermes-agent/blob/main/agent/redact.py): `agent/redact.py`
- [Process compatibility](https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/_subprocess_compat.py): `hermes_cli/_subprocess_compat.py`

### Models and context

- [Model selection](https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/model_switch.py): `hermes_cli/model_switch.py`
- [Model metadata](https://github.com/duongcoder04/hermes-agent/blob/main/agent/model_metadata.py): `agent/model_metadata.py`
- [Auxiliary model client](https://github.com/duongcoder04/hermes-agent/blob/main/agent/auxiliary_client.py): `agent/auxiliary_client.py`
- [Context compression](https://github.com/duongcoder04/hermes-agent/blob/main/agent/context_compressor.py): `agent/context_compressor.py`
- [Conversation compression](https://github.com/duongcoder04/hermes-agent/blob/main/agent/conversation_compression.py): `agent/conversation_compression.py`
- [Model catalog CLI](https://github.com/duongcoder04/hermes-agent/blob/main/hermes_cli/models.py): `hermes_cli/models.py`

### Tools and learning

- [Tool execution](https://github.com/duongcoder04/hermes-agent/blob/main/agent/tool_executor.py): `agent/tool_executor.py`
- [Terminal backends](https://github.com/duongcoder04/hermes-agent/blob/main/tools/environments/local.py): `tools/environments/local.py`
- [Large-result storage](https://github.com/duongcoder04/hermes-agent/blob/main/tools/tool_result_storage.py): `tools/tool_result_storage.py`
- [Agent memory](https://github.com/duongcoder04/hermes-agent/blob/main/agent/memory_manager.py): `agent/memory_manager.py`
- [Skills and learning](https://github.com/duongcoder04/hermes-agent/blob/main/agent/learning_graph.py): `agent/learning_graph.py`

### Gateway and automation

- [Messaging gateway](https://github.com/duongcoder04/hermes-agent/blob/main/tui_gateway/server.py): `tui_gateway/server.py`
- [Signal channel](https://github.com/duongcoder04/hermes-agent/blob/main/gateway/platforms/signal.py): `gateway/platforms/signal.py`
- [Cron scheduler](https://github.com/duongcoder04/hermes-agent/blob/main/cron/scheduler_worker_env.py): `cron/scheduler_worker_env.py`
- [Gateway status](https://github.com/duongcoder04/hermes-agent/blob/main/gateway/status.py): `gateway/status.py`

### Other components

- **User**

## Connections

- User → Hermes CLI: starts a turn
- User → Terminal UI: starts a turn
- User → Messaging gateway: sends messages
- Hermes CLI → Conversation loop: runs conversation
- Terminal UI → Messaging gateway: sends turn requests (evidence: `ui-tui/src/app/turnController.ts`)
- Messaging gateway → Conversation loop: runs conversation (evidence: `tui_gateway/server.py`)
- Signal channel → Messaging gateway: carries messages
- Conversation loop → Prompt builder: builds prompt (evidence: `agent/conversation_loop.py`)
- Conversation loop → Turn context: uses turn context (evidence: `agent/conversation_loop.py`)
- Conversation loop → Model metadata: uses model metadata (evidence: `agent/conversation_loop.py`)
- Conversation loop → Tool execution: dispatches tools
- Conversation loop → Context compression: compresses context (evidence: `agent/conversation_loop.py`)
- Context compression → Auxiliary model client: requests summaries (evidence: `agent/context_compressor.py`)
- Conversation loop → Conversation compression: supports compression (evidence: `agent/conversation_loop.py`)
- Model selection → Conversation loop: selects model
- Model catalog CLI → Model metadata: lists models
- Tool execution → Terminal backends: runs commands
- Tool execution → Large-result storage: persists large output
- Conversation loop → Agent memory: uses memory
- Conversation loop → Skills and learning: creates and improves skills
- Conversation loop → Subagents: spawns subagents
- Cron scheduler → Messaging gateway: delivers scheduled jobs
- Configuration → Conversation loop: configures runtime
- Shared constants → Configuration: provides shared settings (evidence: `hermes_constants.py`)
- Data redaction → Conversation loop: sanitizes content
- Messaging gateway → Gateway status: reports status
- ACP command → ACP adapter: starts adapter (evidence: `acp_adapter/server.py`)
- Process compatibility → Hermes CLI: supports subprocesses (evidence: `hermes_cli/_subprocess_compat.py`)
