Architecture
معمارية Hermes
Start with meaning, then move to detail.
This lesson explains Architecture as part of Hermes internals and extension points. You will learn what it does, when it matters, and the smallest safe test that proves it works.
If you are new, do not memorize names. Focus on three questions: what problem does this solve, what access does it need, and how can you verify the result?
For practice, inspect the first example, identify its effects, run it on test data, and compare the result with the source claim.
For advanced readers, inspect System Overview, Directory Structure, Data Flow, then verify failure modes and version compatibility.
Know Python, Git, and basic project structure before changing code.
A clear outcome before you read.
- Understand Architecture without assumed prior knowledge.
- Separate the source description from what still needs testing in your environment.
- Read the first command and identify its inputs and outputs before copying it.
Short definitions before the details.
- Gateway
- The process that connects Hermes to channels such as Telegram or Discord and routes messages.
- Session & memory
- A session holds conversation context, while memory keeps selected facts that should persist.
- Automation
- Running work later or repeatedly with explicit success and failure conditions.
Hermes Agent internals — major subsystems, execution paths, data flow, and where to read next
What does the source say, and in what order?
- 01System Overview
Start here to understand the core idea or structure.
- 02Directory Structure
Read this after the foundation, then connect it to the previous step.
- 03Data Flow
Read this after the foundation, then connect it to the previous step.
- 04CLI Session
Read this after the foundation, then connect it to the previous step.
- 05Gateway Message
Read this after the foundation, then connect it to the previous step.
- 06Cron Job
Read this after the foundation, then connect it to the previous step.
- 07Recommended Reading Order
Read this after the foundation, then connect it to the previous step.
- 08Major Subsystems
Read this after the foundation, then connect it to the previous step.
- 09Agent Loop
Read this after the foundation, then connect it to the previous step.
- 10Prompt System
Finish here to verify the result and special cases.
Copy only after you understand the effect.
┌─────────────────────────────────────────────────────────────────────┐
│ Entry Points │
│ │
│ CLI (cli.py) Gateway (gateway/run.py) ACP (acp_adapter/) │
│ Batch Runner API Server Python Library │
└──────────┬──────────────┬───────────────────────┬───────────────────┘
│ │ │
▼ ▼ ▼
┌────────────────────────────────────────────────────────────hermes-agent/
├── run_agent.py # AIAgent — core conversation loop (large file)
├── cli.py # HermesCLI — interactive terminal UI (large file)
├── model_tools.py # Tool discovery, schema collection, dispatch
├── toolsets.py # Tool groupings and platform presets
├── hermes_state.py # SQLite session/state database with FTS5
├── hermes_constants.py # HERMES_HOME, profile-aware paths
├── batch_runner.py # Batch trajectory generation
│
├── agent/ # Agent internals
│ ├── prompt_builder.py # SystUser input → HermesCLI.process_input()
→ AIAgent.run_conversation()
→ prompt_builder.build_system_prompt()
→ runtime_provider.resolve_runtime_provider()
→ API call (chat_completions / codex_responses / anthropic_messages)
→ tool_calls? → model_tools.handle_function_call() → loop
→ final response → display → save to SessionDBRead the first command and identify its inputs and outputs before copying it.
Match every command to your installed Hermes version, review the files and accounts it can reach, and use non-sensitive data for the first test. If this explanation differs from the source, the official source wins.