# ryuma-1/hermes-agent architecture

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

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

## Overview

Hermes Agent is a self-improving, multi-provider AI agent used through a CLI/TUI or messaging gateway. A user submits a turn; the conversation loop builds context, calls a model, dispatches tools, and returns a response. The README also documents learning and memory, scheduled automations, subagents, multiple terminal backends, and research trajectory workflows, so these appear as distinct capability branches. Edges rely on README statements or SOURCE INDEX references; unsampled implementation details and runtime wiring are not inferred.

Main entry points: [`agent/conversation_loop.py`](https://github.com/ryuma-1/hermes-agent/blob/main/agent/conversation_loop.py) (Conversation Loop), [`gateway/platforms/signal.py`](https://github.com/ryuma-1/hermes-agent/blob/main/gateway/platforms/signal.py) (Messaging Gateway), [`cli.py`](https://github.com/ryuma-1/hermes-agent/blob/main/cli.py) (CLI), [`agent/context_compressor.py`](https://github.com/ryuma-1/hermes-agent/blob/main/agent/context_compressor.py) (Context Compression)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["CLI<br/>[cli.py]"]
  node_tui["Terminal UI<br/>[turnController.ts]"]
  node_acp["ACP Adapter<br/>[server.py]"]
  node_console["Console Commands<br/>[console_engine.py]"]
  node_acpcommand["ACP Command<br/>[acp.py]"]
end

subgraph group_agent["Agent Runtime"]
  node_conversation["Conversation Loop"]
  node_prompt["Prompt Builder<br/>[prompt_builder.py]"]
  node_turnctx["Turn Context<br/>[turn_context.py]"]
  node_helpers["Runtime Helpers"]
  node_tools["Tool Execution<br/>[tool_executor.py]"]
  node_subagents["Subagents"]
  node_trajectory["Trajectory Research<br/>[trajectory.py]"]
  node_redaction["Redaction<br/>[redact.py]"]
end

subgraph group_learning["Learning and Context"]
  node_compression["Context Compression"]
  node_contextengine["Context Engine<br/>[context_engine.py]"]
  node_conversationcompression["Conversation Compression"]
  node_memory[("Memory and Skills<br/>[memory_manager.py]")]
end

subgraph group_operations["Gateway and Operations"]
  node_gateway["Messaging Gateway<br/>[signal.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_modelswitch["Model Selection<br/>[model_switch.py]"]
  node_scheduler["Scheduled Automations"]
  node_signal["Signal Platform<br/>[signal.py]"]
  node_status["Gateway Status<br/>[status.py]"]
  node_constants["Shared Constants"]
  node_subprocess["Process Compatibility"]
end

subgraph group_integrations["Models and Tools"]
  node_model["Model Metadata<br/>[model_metadata.py]"]
  node_auxclient["Auxiliary Model Client"]
  node_backends["Terminal Backends<br/>[local.py]"]
end

node_user(("User"))

node_user -->|"starts chat"| node_cli
node_user -->|"uses terminal"| node_tui
node_user -->|"messages agent"| node_gateway
node_cli -.->|"submits turn"| node_conversation
node_tui -.->|"submits turn"| node_conversation
node_gateway -.->|"routes turns"| node_conversation
node_conversation -->|"builds prompt"| node_prompt
node_conversation -->|"uses context"| node_turnctx
node_conversation -->|"selects model"| node_model
node_conversation -->|"dispatches tools"| node_tools
node_conversation -->|"compresses context"| node_compression
node_contextengine -->|"default engine"| node_compression
node_conversation -.->|"supports compression"| node_conversationcompression
node_conversation -->|"uses learned context"| node_memory
node_memory -->|"models user"| node_user
node_compression -->|"requests summaries"| node_auxclient
node_modelswitch -->|"chooses provider"| node_model
node_config -->|"configures models"| node_modelswitch
node_tools -->|"runs commands"| node_backends
node_scheduler -->|"delivers scheduled jobs"| node_gateway
node_conversation -->|"spawns workstreams"| node_subagents
node_conversation -->|"records trajectories"| node_trajectory
node_acpcommand -->|"starts adapter"| node_acp
node_gateway -->|"supports platform"| node_signal
node_gateway -.->|"reports status"| node_status
node_conversation -->|"uses runtime helpers"| node_helpers
node_conversation -->|"sanitizes context"| node_redaction
node_cli -.->|"offers console"| node_console
node_config -->|"uses shared constants"| node_constants
node_status -->|"uses compatibility helpers"| node_subprocess

click node_cli "https://github.com/ryuma-1/hermes-agent/blob/main/cli.py"
click node_tui "https://github.com/ryuma-1/hermes-agent/blob/main/ui-tui/src/app/turnController.ts"
click node_gateway "https://github.com/ryuma-1/hermes-agent/blob/main/gateway/platforms/signal.py"
click node_conversation "https://github.com/ryuma-1/hermes-agent/blob/main/agent/conversation_loop.py"
click node_prompt "https://github.com/ryuma-1/hermes-agent/blob/main/agent/prompt_builder.py"
click node_turnctx "https://github.com/ryuma-1/hermes-agent/blob/main/agent/turn_context.py"
click node_helpers "https://github.com/ryuma-1/hermes-agent/blob/main/agent/agent_runtime_helpers.py"
click node_tools "https://github.com/ryuma-1/hermes-agent/blob/main/agent/tool_executor.py"
click node_compression "https://github.com/ryuma-1/hermes-agent/blob/main/agent/context_compressor.py"
click node_contextengine "https://github.com/ryuma-1/hermes-agent/blob/main/agent/context_engine.py"
click node_conversationcompression "https://github.com/ryuma-1/hermes-agent/blob/main/agent/conversation_compression.py"
click node_memory "https://github.com/ryuma-1/hermes-agent/blob/main/agent/memory_manager.py"
click node_model "https://github.com/ryuma-1/hermes-agent/blob/main/agent/model_metadata.py"
click node_auxclient "https://github.com/ryuma-1/hermes-agent/blob/main/agent/auxiliary_client.py"
click node_backends "https://github.com/ryuma-1/hermes-agent/blob/main/tools/environments/local.py"
click node_config "https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/config.py"
click node_modelswitch "https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/model_switch.py"
click node_scheduler "https://github.com/ryuma-1/hermes-agent/blob/main/cron/scheduler_worker_env.py"
click node_subagents "https://github.com/ryuma-1/hermes-agent/blob/main/agent/subagent_lifecycle.py"
click node_trajectory "https://github.com/ryuma-1/hermes-agent/blob/main/agent/trajectory.py"
click node_acp "https://github.com/ryuma-1/hermes-agent/blob/main/acp_adapter/server.py"
click node_signal "https://github.com/ryuma-1/hermes-agent/blob/main/gateway/platforms/signal.py"
click node_status "https://github.com/ryuma-1/hermes-agent/blob/main/gateway/status.py"
click node_console "https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/console_engine.py"
click node_constants "https://github.com/ryuma-1/hermes-agent/blob/main/hermes_constants.py"
click node_redaction "https://github.com/ryuma-1/hermes-agent/blob/main/agent/redact.py"
click node_subprocess "https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/_subprocess_compat.py"
click node_acpcommand "https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/subcommands/acp.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_console,node_acpcommand,node_user toneBlue
class node_conversation,node_prompt,node_turnctx,node_helpers,node_tools,node_subagents,node_trajectory,node_redaction toneAmber
class node_compression,node_contextengine,node_conversationcompression,node_memory toneMint
class node_gateway,node_config,node_modelswitch,node_scheduler,node_signal,node_status,node_constants,node_subprocess toneRose
class node_model,node_auxclient,node_backends toneIndigo
```

## Components

### User Interfaces

- [CLI](https://github.com/ryuma-1/hermes-agent/blob/main/cli.py): `cli.py`
- [Terminal UI](https://github.com/ryuma-1/hermes-agent/blob/main/ui-tui/src/app/turnController.ts): `ui-tui/src/app/turnController.ts`
- [ACP Adapter](https://github.com/ryuma-1/hermes-agent/blob/main/acp_adapter/server.py): `acp_adapter/server.py`
- [Console Commands](https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/console_engine.py): `hermes_cli/console_engine.py`
- [ACP Command](https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/subcommands/acp.py): `hermes_cli/subcommands/acp.py`

### Agent Runtime

- [Conversation Loop](https://github.com/ryuma-1/hermes-agent/blob/main/agent/conversation_loop.py): `agent/conversation_loop.py`
- [Prompt Builder](https://github.com/ryuma-1/hermes-agent/blob/main/agent/prompt_builder.py): `agent/prompt_builder.py`
- [Turn Context](https://github.com/ryuma-1/hermes-agent/blob/main/agent/turn_context.py): `agent/turn_context.py`
- [Runtime Helpers](https://github.com/ryuma-1/hermes-agent/blob/main/agent/agent_runtime_helpers.py): `agent/agent_runtime_helpers.py`
- [Tool Execution](https://github.com/ryuma-1/hermes-agent/blob/main/agent/tool_executor.py): `agent/tool_executor.py`
- [Subagents](https://github.com/ryuma-1/hermes-agent/blob/main/agent/subagent_lifecycle.py): `agent/subagent_lifecycle.py`
- [Trajectory Research](https://github.com/ryuma-1/hermes-agent/blob/main/agent/trajectory.py): `agent/trajectory.py`
- [Redaction](https://github.com/ryuma-1/hermes-agent/blob/main/agent/redact.py): `agent/redact.py`

### Learning and Context

- [Context Compression](https://github.com/ryuma-1/hermes-agent/blob/main/agent/context_compressor.py): `agent/context_compressor.py`
- [Context Engine](https://github.com/ryuma-1/hermes-agent/blob/main/agent/context_engine.py): `agent/context_engine.py`
- [Conversation Compression](https://github.com/ryuma-1/hermes-agent/blob/main/agent/conversation_compression.py): `agent/conversation_compression.py`
- [Memory and Skills](https://github.com/ryuma-1/hermes-agent/blob/main/agent/memory_manager.py): `agent/memory_manager.py`

### Gateway and Operations

- [Messaging Gateway](https://github.com/ryuma-1/hermes-agent/blob/main/gateway/platforms/signal.py): `gateway/platforms/signal.py`
- [Configuration](https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/config.py): `hermes_cli/config.py`
- [Model Selection](https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/model_switch.py): `hermes_cli/model_switch.py`
- [Scheduled Automations](https://github.com/ryuma-1/hermes-agent/blob/main/cron/scheduler_worker_env.py): `cron/scheduler_worker_env.py`
- [Signal Platform](https://github.com/ryuma-1/hermes-agent/blob/main/gateway/platforms/signal.py): `gateway/platforms/signal.py`
- [Gateway Status](https://github.com/ryuma-1/hermes-agent/blob/main/gateway/status.py): `gateway/status.py`
- [Shared Constants](https://github.com/ryuma-1/hermes-agent/blob/main/hermes_constants.py): `hermes_constants.py`
- [Process Compatibility](https://github.com/ryuma-1/hermes-agent/blob/main/hermes_cli/_subprocess_compat.py): `hermes_cli/_subprocess_compat.py`

### Models and Tools

- [Model Metadata](https://github.com/ryuma-1/hermes-agent/blob/main/agent/model_metadata.py): `agent/model_metadata.py`
- [Auxiliary Model Client](https://github.com/ryuma-1/hermes-agent/blob/main/agent/auxiliary_client.py): `agent/auxiliary_client.py`
- [Terminal Backends](https://github.com/ryuma-1/hermes-agent/blob/main/tools/environments/local.py): `tools/environments/local.py`

### Other components

- **User**

## Connections

- User → CLI: starts chat (evidence: `README.md`)
- User → Terminal UI: uses terminal (evidence: `README.md`)
- User → Messaging Gateway: messages agent (evidence: `README.md`)
- CLI → Conversation Loop: submits turn
- Terminal UI → Conversation Loop: submits turn
- Messaging Gateway → Conversation Loop: routes turns
- Conversation Loop → Prompt Builder: builds prompt (evidence: `agent/conversation_loop.py`)
- Conversation Loop → Turn Context: uses context (evidence: `agent/conversation_loop.py`)
- Conversation Loop → Model Metadata: selects model (evidence: `agent/conversation_loop.py`)
- Conversation Loop → Tool Execution: dispatches tools (evidence: `README.md`)
- Conversation Loop → Context Compression: compresses context (evidence: `agent/conversation_loop.py`)
- Context Engine → Context Compression: default engine (evidence: `agent/context_engine.py`)
- Conversation Loop → Conversation Compression: supports compression
- Conversation Loop → Memory and Skills: uses learned context (evidence: `README.md`)
- Memory and Skills → User: models user (evidence: `README.md`)
- Context Compression → Auxiliary Model Client: requests summaries (evidence: `agent/context_compressor.py`)
- Model Selection → Model Metadata: chooses provider (evidence: `README.md`)
- Configuration → Model Selection: configures models (evidence: `README.md`)
- Tool Execution → Terminal Backends: runs commands (evidence: `README.md`)
- Scheduled Automations → Messaging Gateway: delivers scheduled jobs (evidence: `README.md`)
- Conversation Loop → Subagents: spawns workstreams (evidence: `README.md`)
- Conversation Loop → Trajectory Research: records trajectories (evidence: `README.md`)
- ACP Command → ACP Adapter: starts adapter (evidence: `acp_adapter/server.py`)
- Messaging Gateway → Signal Platform: supports platform (evidence: `README.md`)
- Messaging Gateway → Gateway Status: reports status
- Conversation Loop → Runtime Helpers: uses runtime helpers (evidence: `agent/conversation_loop.py`)
- Conversation Loop → Redaction: sanitizes context (evidence: `agent/conversation_loop.py`)
- CLI → Console Commands: offers console
- Configuration → Shared Constants: uses shared constants (evidence: `hermes_cli/config.py`)
- Gateway Status → Process Compatibility: uses compatibility helpers (evidence: `hermes_cli/_subprocess_compat.py`)
