sidebar_position: 1
title: Architecture
description: >-
Hermes Agent internals β major subsystems, execution paths, and where to read
next
Architecture
This page is the top-level map of Hermes Agent internals. The project has grown beyond a single monolithic loop, so the best way to understand it is by subsystem.
High-level structure
hermes-agent/
βββ run_agent.py # AIAgent core loop
βββ cli.py # interactive terminal UI
βββ model_tools.py # tool discovery/orchestration
βββ toolsets.py # tool groupings and presets
βββ hermes_state.py # SQLite session/state database
βββ batch_runner.py # batch trajectory generation
β
βββ agent/ # prompt building, compression, caching, metadata, trajectories
βββ hermes_cli/ # command entrypoints, auth, setup, models, config, doctor
βββ tools/ # tool implementations and terminal environments
βββ gateway/ # messaging gateway, session routing, delivery, pairing, hooks
βββ cron/ # scheduled job storage and scheduler
βββ honcho_integration/ # Honcho memory integration
βββ acp_adapter/ # ACP editor integration server
βββ acp_registry/ # ACP registry manifest + icon
βββ environments/ # Hermes RL / benchmark environment framework
βββ skills/ # bundled skills
βββ optional-skills/ # official optional skills
βββ tests/ # test suite
Recommended reading order
If you are new to the codebase, read in this order:
- this page
- Agent Loop Internals
- Prompt Assembly
- Provider Runtime Resolution
- Adding Providers
- Tools Runtime
- Session Storage
- Gateway Internals
- Context Compression & Prompt Caching
- ACP Internals
- Environments, Benchmarks & Data Generation
Major subsystems
Agent loop
The core synchronous orchestration engine is AIAgent in run_agent.py.
It is responsible for:
- provider/API-mode selection
- prompt construction
- tool execution
- retries and fallback
- callbacks
- compression and persistence
See Agent Loop Internals.
Prompt system
Prompt-building logic is split between:
run_agent.pyagent/prompt_builder.pyagent/prompt_caching.pyagent/context_compressor.py
See:
Provider/runtime resolution
Hermes has a shared runtime provider resolver used by CLI, gateway, cron, ACP, and auxiliary calls.
See Provider Runtime Resolution.
Tooling runtime
The tool registry, toolsets, terminal backends, process manager, and dispatch rules form a subsystem of their own.
See Tools Runtime.
Session persistence
Historical session state is stored primarily in SQLite, with lineage preserved across compression splits.
See Session Storage.
Messaging gateway
The gateway is a long-running orchestration layer for platform adapters, session routing, pairing, delivery, and cron ticking.
See Gateway Internals.
ACP integration
ACP exposes Hermes as an editor-native agent over stdio/JSON-RPC.
See:
Cron
Cron jobs are implemented as first-class agent tasks, not just shell tasks.
See Cron Internals.
RL / environments / trajectories
Hermes ships a full environment framework for evaluation, RL integration, and SFT data generation.
See:
Design themes
Several cross-cutting design themes appear throughout the codebase:
- prompt stability matters
- tool execution must be observable and interruptible
- session persistence must survive long-running use
- platform frontends should share one agent core
- optional subsystems should remain loosely coupled where possible
Implementation notes
The older mental model of Hermes as βone OpenAI-compatible chat loop plus some toolsβ is no longer sufficient. Current Hermes includes:
- multiple API modes
- auxiliary model routing
- ACP editor integration
- gateway-specific session and delivery semantics
- RL environment infrastructure
- prompt-caching and compression logic with lineage-aware persistence
Use this page as the map, then dive into subsystem-specific docs for the real implementation details.