Appearance
Hermes Agent 多角色团队搭建指南。Profile 机制让你在同一台机器上跑多个完全独立的 Agent,各自拥有独立的配置、密钥、记忆、会话和技能库。
背景:为什么需要多 Agent
之前大部分人把所有任务都塞给一个 Agent,API 密钥、记忆、会话全混在一起,上下文里夹着许多聊天记录,Agent 的记忆库被日常琐事污染。
Hermes 的 Profile 机制可以让你在同一台机器上跑多个完全独立的 Agent:
| 隔离项 | 说明 |
|---|---|
| 配置 | 独立的 config.yaml |
| 密钥 | 独立的 .env |
| 记忆 | 独立的记忆库 |
| 会话 | 独立的历史会话 |
| 技能库 | 独立的技能配置 |
| 状态数据库 | 独立的状态 |
三步搭建多 Agent 体系
Step 1:创建专用 Profile
bash
# 创建 Profile
hermes profile create "coder" --clone--clone 的作用:
- 继承当前的 config.yaml
- 继承 .env
- 继承 SOUL.md
- 记忆和会话完全隔离
个性化配置:
| 配置项 | 路径 | 说明 |
|---|---|---|
| API 密钥 | ~/.hermes/profiles/coder/.env | 独立的 API 密钥 |
| 人设 | 对应的 SOUL.md | 独立的人设配置 |
| 记忆 | 独立的记忆库 | 不与其他 Profile 污染 |
Step 2:为每个 Profile 定制身份
编辑各自的 SOUL.md,明确这个 Agent 的专长边界:
| Profile | 职责 | SOUL.md 配置重点 |
|---|---|---|
| 编码助手 | 专注代码审查和重构 | 编程语言、技术栈 |
| 研究 Agent | 只处理文献检索和知识整理 | 研究方法、信息源 |
| 个人助理 | 负责日程和提醒 | 日程管理、提醒逻辑 |
配置示例(SOUL.md):
markdown
# 编码助手 Profile
## 专长
- 代码审查
- 重构优化
- Bug 定位
## 工作方式
- 严谨、精确
- 注重代码质量
- 优先推荐最佳实践
## 禁止
- 不处理非代码相关任务
- 不参与闲聊Step 3:直接调用,各司其职
Profile 创建后自动生成同名命令:
bash
# 使用 coder Profile
coder chat
coder setup
coder gateway start
# 或使用 -p 标志切换
hermes -p research chat
# 设置默认 Profile
hermes profile use coder
# 之后所有 hermes 命令自动指向 coder Profile核心命令速查
| 命令 | 功能 |
|---|---|
hermes profile create <name> --clone | 创建新 Profile(继承配置) |
hermes profile list | 列出所有 Profile |
hermes profile use <name> | 设置默认 Profile |
hermes profile delete <name> | 删除 Profile |
hermes -p <profile> <command> | 指定 Profile 执行命令 |
coder chat | 使用 coder Profile 聊天 |
coder setup | coder Profile 初始化 |
coder gateway start | coder Profile Gateway 启动 |
Profile 隔离机制
目录结构
~/.hermes/
├── profiles/
│ ├── default/ # 默认 Profile
│ │ ├── config.yaml
│ │ ├── .env
│ │ ├── SOUL.md
│ │ ├── memory/
│ │ ├── sessions/
│ │ └── skills/
│ │
│ ├── coder/ # 编码助手 Profile
│ │ ├── config.yaml # 独立的配置
│ │ ├── .env # 独立的密钥
│ │ ├── SOUL.md # 独立的身份
│ │ ├── memory/ # 独立的记忆
│ │ ├── sessions/ # 独立的会话
│ │ └── skills/ # 独立的技能
│ │
│ ├── research/ # 研究 Agent Profile
│ │ ├── config.yaml
│ │ ├── .env
│ │ ├── SOUL.md
│ │ ├── memory/
│ │ ├── sessions/
│ │ └── skills/
│ │
│ └── assistant/ # 个人助理 Profile
│ ├── config.yaml
│ ├── .env
│ ├── SOUL.md
│ ├── memory/
│ ├── sessions/
│ └── skills/隔离效果
| 场景 | 单 Agent | 多 Profile |
|---|---|---|
| 上下文污染 | 严重 | 完全隔离 |
| 记忆污染 | 严重 | 完全隔离 |
| 配置冲突 | 经常 | 不存在 |
| 密钥管理 | 混乱 | 清晰分离 |
进阶玩法
独立的 Gateway 进程
每个 Profile 可以跑独立的 Gateway 进程:
bash
# 为不同 Profile 启动不同的 Gateway
coder gateway start --port 3001
research gateway start --port 3002
assistant gateway start --port 3003配置不同的 Telegram/Discord 频道:
| Profile | Gateway | 频道 |
|---|---|---|
| coder | coder-gateway | #coding-help |
| research | research-gateway | #research-updates |
| assistant | assistant-gateway | #personal-tasks |
Profile 间协作
虽然 Profile 完全隔离,但可以通过共享数据目录实现协作:
bash
# 在配置中设置共享目录
# ~/.hermes/profiles/coder/config.yaml
shared_dirs:
- /shared/project-docs
- /shared/meeting-notes适用场景
| 场景 | 推荐 Profile 配置 |
|---|---|
| 个人开发者 | coder + research + assistant |
| 小团队 | developer + reviewer + tester |
| 科研人员 | researcher + writer + manager |
| 内容创作者 | writer + editor + publisher |
不适合场景
| 场景 | 原因 |
|---|---|
| 简单任务 | Profile 切换反而麻烦 |
| 单人单 Agent 足够 | 不需要多角色分工 |
最佳实践
1. Profile 命名规范
bash
# 推荐命名
hermes profile create "coder"
hermes profile create "researcher"
hermes profile create "assistant"
# 不推荐(太通用)
hermes profile create "profile1"
hermes profile create "agent2"2. SOUL.md 职责边界
| 原则 | 说明 |
|---|---|
| 职责单一 | 每个 Profile 只负责一类任务 |
| 边界清晰 | 在 SOUL.md 中明确禁止事项 |
| 上下文纯净 | 不让无关内容进入 Profile |
3. 定期清理
bash
# 清理过期会话
hermes profile cleanup <name> --older-than 30d
# 清理记忆
hermes profile cleanup <name> --memory --older-than 7d一句话总结
Hermes Profile = 多个完全独立的 Agent,各司其职,上下文不串。
三步搭建:
hermes profile create <name> --clone- 编辑 SOUL.md 定制身份
- 直接调用,各司其职
核心价值:API 密钥隔离、记忆隔离、会话隔离、技能库隔离。
