📋 概述
Hermes Agent 作为一款强大的开源 AI 代理框架,支持通过 Profile(配置文件) 机制运行多个完全独立的实例。每个 Profile 拥有自己独立的配置、API Key、对话记录、技能库、永久记忆和定时任务,彼此之间完全隔离。
本文将以本站(乾坤BOT)的实际运维场景为例,深入讲解 Profile 的创建、配置、切换和最佳实践。
🔍 Profile 与传统多会话的区别
| 维度 | 同一Profile的多个会话(微信/QQ/网页/CLI) | 不同Profile |
|---|---|---|
| 本质 | 同一个人的多个聊天窗口 | 多个独立的 Hermes 分身 |
| 配置文件 | 共享同一份 config.yaml | 各自独立的 config.yaml |
| API Key | 共享同一个 Key | 可以用不同 Key 或不同 provider |
| 永久记忆 | 共享(微信记住了QQ也知道) | 完全隔离(互不知道对方存在) |
| 技能库 | 共享 | 独立 |
| 定时任务 | 共享 | 独立 |
| 会话记录 | 各自独立不串 | 各自独立不串 |
📁 Profile 的文件结构
每个 Profile 对应一个独立的目录,默认 Profile 位于 ~/.hermes/,其他 Profile 位于 ~/.hermes/profiles/<名称>/。
~/.hermes/ # 默认 Profile(根目录)
├── config.yaml # 主配置
├── .env # API Key 等环境变量
├── state.db # SQLite 会话数据库
├── skills/ # 技能库
├── memories/ # 永久记忆
├── cron/ # 定时任务
├── sessions/ # 会话导出
└── profiles/ # 其他 Profile
└── work/ # "work" 分身
├── config.yaml
├── .env
├── state.db
├── skills/
└── memories/
⚙️ Profile 常用命令
# 查看所有 Profile
hermes profile list
# 创建新 Profile(如 work)
hermes profile create work
# 查看某个 Profile 的详情
hermes profile show work
# 启动时指定 Profile
hermes --profile work
# 设置某个 Profile 为默认
hermes profile use work
# 重命名 Profile
hermes profile rename work writer
# 创建时克隆已有 Profile 的配置
hermes profile create writer --clone-from default
# 导出 Profile(便于迁移)
hermes profile export work
# 导入 Profile
hermes profile import work.tar.gz
# 删除 Profile
hermes profile delete work
💡 乾坤BOT实战场景
以下是以本站真实运维来举例的几种 Profile 使用方案:
场景一:日常运维 + 内容创作分离
| 项目 | default Profile(日常) | writer Profile(写作) |
|---|---|---|
| 模型 | DeepSeek 直连(稳定快速) | SenseNova 转接(免费额度) |
| 用途 | 网站管理、对话、调试 | 定时批量写文章、搜资料 |
| 定时任务 | 无 | 每天定时生成新闻稿 |
| API Key | DeepSeek API Key | SenseNova 免费 Key |
| 记忆 | 认识站长、了解网站全局 | 只关注写作任务 |
操作步骤:
# 1. 创建 writer Profile
hermes profile create writer
# 2. 切换到 writer 目录编辑配置
cd ~/.hermes/profiles/writer
# 修改 config.yaml 中的 model.provider 和 api_key 为 SenseNova
# 修改 .env 填入 SenseNova 的 API Key
# 3. 启动 writer 分身
hermes --profile writer
# 4. 在 writer 里设置定时任务
# 使用 cronjob 工具安排写作任务
场景二:不同项目使用不同模型
乾坤BOT 运营过程中可能涉及多种 AI 模型需求:
- 网站对话助手:用 DeepSeek 直连(响应快、稳定)
- 图像生成:用 SenseNova U1 Fast(免费额度,每5小时1500次)
- 文章校对:用 SenseNova 6.7 Flash-Lite(轻量低成本)
通过不同 Profile 分别配置不同模型和 Key,互不干扰。
场景三:多站点管理隔离
如果您同时运营多个网站(如乾坤BOT qiankunbot.com 和 bazihome.com),可以为每个站点创建独立的 Profile,各站点有独立的配置、记忆和定时任务:
hermes profile create qiankun
hermes profile create bazihome
# 分别启动
hermes --profile qiankun # 管理乾坤BOT
hermes --profile bazihome # 管理八字之家
⚠️ 注意事项与常见问题
- Gateway 绑定:微信/QQ/网页等渠道同时只能绑定一个 Profile。切换 Profile 后需要重启 gateway:
hermes gateway restart。 - 对话保留:切换 Profile 不会丢失原 Profile 的对话记录。再切回来时,用
hermes -c --profile default即可恢复上次对话。 - 数据隔离:每个 Profile 有独立的 state.db,对话不会串到其他 Profile。
- 克隆配置:创建新 Profile 时可用
--clone-from default把默认配置复制过去,免去重复配置。 - 迁移备份:
hermes profile export可将整个 Profile 打包成 tar.gz,方便在服务器之间迁移。
📊 什么样的场景不需要 Profile?
Profile 虽好,但并非所有场景都需要。如果您只是一个人运维一个站点(如本站目前的情况),一个 default Profile 完全够用。Profile 更适合以下场景:
- 多人共享一台服务器的不同任务隔离
- 需要完全隔离的记忆和技能(不同项目互不知情)
- 不同 Profile 用不同 API Key 来分摊免费额度或成本归属
- 需要独立调试或测试新配置而不影响生产环境
🎯 总结
Hermes Agent 的 Profile 功能提供了一种优雅的"多实例管理"方案。通过 Profile,您可以将不同用途、不同模型、不同 Key 的 Hermes 实例完全隔离开来,互不干扰。对于单用户单站点的场景,一个默认 Profile 就足够;但对于需要多任务隔离、多 Key 管理或多站点运维的进阶用户,Profile 是不可或缺的工具。
— 乾坤BOT · 2026年6月11日