Skip to the content.

Architecture

Hercules consists of a reusable agent core and three façade interfaces (CLI, Telegram, Web API + frontend) that contain no business logic of their own.

Component Overview

                  ┌─────────────┐   ┌──────────────┐   ┌──────────────────────┐
    User          │   CLI (REPL)│   │ Telegram bot │   │ Web API + Astro UI   │
                  └──────┬──────┘   └──────┬───────┘   └──────────┬───────────┘
                         │                 │                      │
                         └─────────────────┼──────────────────────┘
                                           ▼
                                  ┌──────────────────┐
                                  │     AgentCore    │  main processing loop
                                  └───┬───────┬──────┘
               ┌──────────────────────┘       └──────────────────────┐
               ▼            ▼            ▼            ▼               ▼
         SkillRouter  SkillManager  MemoryManager  ReflectionEngine  ILLMClient
               │            │            │              │             │
               └──── FileSkillRepository / MemoryStore / SqliteSessionStore ──── ResilientLLMClient
                                                                                   │
                                                                  ┌────────────────┼────────────────┐
                                                               YandexGPT      Ollama Cloud     Ollama Local
                                                                  (via Microsoft.Extensions.AI / OpenAI)

Layers

1. Interfaces (CLI/, Telegram/, Hercules.WebApi/ + Studio)

Accept user input, call AgentCore.HandleAsync(), and display the result. The Web API uses Agent/WebApiAdapter.cs (DTO + mapping) as a thin layer over the core. It also serves the Studio SPA at /ui (ADR-0009), so the web UI and the API are one process; hercules-web/ (Astro) is deprecated.

2. Agent Core (Agent/)

3. LLM Layer (LLM/)

Unified ILLMClient interface on top of Microsoft.Extensions.AI (IChatClient).

4. Storage (Storage/)

Hybrid:

Request Processing Flow (self-improving cycle)

  1. Request → load profile and context from memory.
  2. Routing → SkillRouter looks up a skill by triggers.
  3. LLM response → with a skill (skill-prompt) or directly (direct).
  4. Logging → input/output/confidence/mode in SQLite.
  5. Creation threshold → repeat SkillCreationThreshold times → propose creating a skill (with confirmation).
  6. Improvement threshold → success_rate < SkillImprovementThreshold → propose updating the skill.
  7. Memory → extract facts about the user, entities, preferences.
  8. Reflection → at the end of a session or every N commands.

Design Principles

Runtime Data (data/)

data/
├── Skills/   # skill.{id}.md / .prompt.md / .meta.json / .usage.json / .v{N}.md
├── Memory/   # user_profile.md, preferences.md, entities.md, context_{date}.md
└── sessions.db  # SQLite: sessions, interactions, metrics