Post

一、总体架构

一、总体架构

系统概述

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
┌─────────────────────────────────────────────────────────────────────┐
│                        Entry Points                                 │
│                                                                     │
│  CLI (cli.py)    Gateway (gateway/run.py)    ACP (acp_adapter/)     │
│  Batch Runner    API Server                  Python Library         │
└──────────┬──────────────┬───────────────────────┬───────────────────┘
           │              │                       │
           ▼              ▼                       ▼
┌─────────────────────────────────────────────────────────────────────┐
│                     AIAgent (run_agent.py)                          │
│                                                                     │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐               │
│  │ Prompt       │  │ Provider     │  │ Tool         │               │
│  │ Builder      │  │ Resolution   │  │ Dispatch     │               │
│  │ (prompt_     │  │ (runtime_    │  │ (model_      │               │
│  │  builder.py) │  │  provider.py)│  │  tools.py)   │               │
│  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘               │
│         │                 │                 │                       │
│  ┌──────┴───────┐  ┌──────┴───────┐  ┌──────┴───────┐               │
│  │ Compression  │  │ 3 API Modes  │  │ Tool Registry│               │
│  │ & Caching    │  │ chat_compl.  │  │ (registry.py)│               │
│  │              │  │ codex_resp.  │  │ 61 tools     │               │
│  │              │  │ anthropic    │  │ 52 toolsets  │               │
│  └──────────────┘  └──────────────┘  └──────────────┘               │
└─────────┴─────────────────┴─────────────────┴───────────────────────┘
           │                                    │
           ▼                                    ▼
┌───────────────────┐              ┌──────────────────────┐
│ Session Storage   │              │ Tool Backends        │
│ (SQLite + FTS5)   │              │ Terminal (7 backends)│
│ hermes_state.py   │              │ Browser (5 backends) │
│ gateway/session.py│              │ Web (4 backends)     │
└───────────────────┘              │ MCP (dynamic)        │
                                   │ File, Vision, etc.   │
                                   └──────────────────────┘

接入层

包括 CLI、Messaging Gateway、ACP、API Server、Python Library等组件。

Agent 引擎层

核心是以 ReAct 模式循环,负责提示词构建、模型调用、工具执行、重试、fallback、上下文压缩和持久化。

  • Prompt(Context) 构建:组装系统提示词,来源包括 会话历史、memory、skills、AGENTS.md / .hermes.md、工具使用规则(Schema)、模型等。
  • Memory 管理:包含长期记忆,会话历史召回和外部记忆 provider。
  • LLM Provider:适配多家大模型提供商。

存储层

  • SQLite + FTS5:SQLite 保存会话历史,FTS5提供Memory全文检索召回
  • 文件系统:保存长期记忆(MEMORY.md、 USER.md)等

工具层

负责工具注册,工具集分组,多 backend 调用等,覆盖 web、terminal、file、browser、vision、memory、cron、delegation、MCP 等。

Skills 系统

兼容 agentskills.io 标准,并能在使用中自我改进

Hermes VS OpenClaw

 核心架构安全性系统定位/使用场景
Hermes单 Agent ReAct 模式,强调 memory 和 skill 的自动演化权限收敛个人助手
OpenClawcontrol plane + multi-agent 编排,强调workflow、调度和多渠道集成系统级最高权限企业级 AI 自动化 workflow 平台

参考

This post is licensed under CC BY 4.0 by the author.