Skip to content

8-2、Hermes 中创建多个 Agent(profile)基础 ​

Hermes 创建多个 Agent 有两种主流方式:

  1. Profile(完全独立多实例):每个 Agent 是独立环境,有自己的配置、记忆、网关,适合 “一个角色一个 Bot”。

  2. Sub-agent(单实例内多子 Agent):在同一个 Hermes 里动态生成临时子 Agent,适合任务拆解、并行执行。


一、用 Profile 创建永久独立 Agent(最常用) ​

原理 ​

每个 Profile 对应:

Plain
~/.hermes/profiles/<名字>/
├── config.yaml
├── .env
├── SOUL.md
├── memories/
├── sessions/
├── skills/
└── state.db

完全隔离:记忆、会话、技能、网关、API Key 全部分开。

快速创建(3 个示例) ​

Plain
# 1. 空白新 Agent(最干净)
hermes profile create coder
coder setup   # 配置模型、API Key、网关
coder chat    # 进入对话# 

2. 克隆当前配置(同 Key、同模型,新记忆)
hermes profile create writer --clone# 

3. 完整复制(含所有记忆、会话、技能,用于备份/分叉)
hermes profile create researcher --clone-all

创建后自动生成命令别名:coder、writer、researcher。

分别启动网关(独立机器人) ​

Plain
# 每个 Agent 单独启动网关(不同终端)
coder gateway start
writer gateway start
researcher gateway start

每个 Profile 用不同的 Bot Token(在各自 .env 里配置)。

常用管理命令 ​

Plain
hermes profile list                # 列出所有 Agent
hermes profile use coder           # 切换默认
hermes profile delete researcher   # 删除
hermes -p coder chat               # 临时用指定 Profile

二、在一个 Agent 里创建临时 Sub-agent(动态多智能体) ​

原理 ​

主 Agent(orchestrator)在对话中动态生成子 Agent,用于并行任务:

  • 子 Agent 有独立会话、终端、API 调用

  • 用完即销毁(可配置保留)

  • 共享主 Agent 的 Key(也可单独配置)

自然语言创建(对话里直接说) ​

plaintext

Plain
请生成一个子 Agent,专门做代码审查,帮我检查这个 Python 函数。

或并行多个:

plaintext

Plain
生成两个子 Agent:一个做网页抓取,一个做数据分析,并行执行。

CLI 手动管理 ​

bash

运行

Plain
hermes agents list                  # 列出运行中的子 Agent
hermes agents use code-reviewer     # 切入某个子 Agent
hermes agents stop code-reviewer    # 停止

典型场景:主脑 + 工人 ​

  • 主 Agent:决策、拆任务、汇总结果(用默认 Profile)

  • 子 Agent:编码、搜索、绘图等专项工作


三、两种方式对比(怎么选) ​

表格


四、推荐做法(生产环境) ​

  1. 长期角色(如:编码助手、生活助手)→ 用 Profile

  2. 临时任务(如:写报告、查资料)→ 用 Sub-agent

  3. 混合架构:1 个主 Profile + 多个专用 Profile + 动态 Sub-agent

Released under the MIT License.