跳到主要内容

配置文件:运行多个 Agent

在同一台机器上运行多个独立的 Hermes Agent —— 每个 Agent 拥有自己的配置、API 密钥、记忆、会话、技能和网关。

什么是配置文件?

配置文件是一个完全隔离的 Hermes 环境。每个配置文件都有自己的目录,包含独立的 config.yaml.envSOUL.md、记忆、会话、技能、定时任务和状态数据库。配置文件让你可以为不同用途运行独立的 Agent —— 例如代码助手、个人机器人、研究 Agent —— 而不会产生任何相互干扰。

当你创建一个配置文件时,它会自动成为一个独立的命令。创建名为 coder 的配置文件后,你立即拥有 coder chatcoder setupcoder gateway start 等命令。

快速入门

hermes profile create coder       # 创建 profile + "coder" 命令别名
coder setup # 配置API键和model
coder chat # 开始聊天

完成。coder 现在是一个完全独立的 Agent。它拥有自己的配置、自己的记忆、以及所有其他独立资源。

创建配置文件

空配置文件

hermes profile create mybot

创建一个包含预置技能的全新配置文件。运行 mybot setup 来配置 API 密钥、模型和网关令牌。

仅克隆配置(--clone

hermes profile create work --clone

将当前配置文件的 config.yaml.envSOUL.md 复制到新配置文件中。使用相同的 API 密钥和模型,但会话和记忆是全新的。编辑 ~/.hermes/profiles/work/.env 以使用不同的 API 密钥,或编辑 ~/.hermes/profiles/work/SOUL.md 以设置不同的个性。

克隆全部内容(--clone-all

hermes profile create backup --clone-all

复制 全部内容 —— 配置、API 密钥、个性、所有记忆、完整的会话历史、技能、定时任务、插件。这是一个完整的快照。适用于备份或复制一个已有上下文的 Agent。

从特定配置文件克隆

hermes profile create work --clone --clone-from coder
Honcho 记忆 + 配置文件

当启用 Honcho 时,--clone 会自动为新配置文件创建一个专用的 AI 同伴,同时共享相同的用户工作区。每个配置文件会构建自己的观察和身份。详情请参见 Honcho — 多 Agent / 配置文件

使用配置文件

命令别名

每个配置文件都会自动在 ~/.local/bin/<name> 处获得一个命令别名:

coder chat                    # 与编码员 agent 聊天
coder setup # 配置编码器的设置
coder gateway start # 启动编码器的gateway
coder doctor # 检查编码器的健康状况
coder skills list # 列出编码器的 skills
coder config set model.model anthropic/claude-sonnet-4

该别名支持所有 hermes 子命令 —— 其底层只是 hermes -p <name>

-p 标志

你也可以通过任意命令显式指定配置文件:

hermes -p coder chat
hermes --profile=coder doctor
hermes chat -p coder -q "hello" # 在任何位置工作

设置默认配置文件(hermes profile use

hermes profile use coder
hermes chat # 现在的目标是编码员
hermes tools # 配置编码器的tools
hermes profile use default # 切换回来

设置默认配置文件,使得普通的 hermes 命令默认指向该配置文件。类似于 kubectl config use-context

知道当前所在位置

CLI 始终显示当前激活的配置文件:

  • 提示符:显示为 coder ❯ 而非
  • 启动横幅:显示 Profile: coder
  • hermes profile:显示当前配置文件名称、路径、模型和网关状态

运行网关

每个配置文件都以独立进程运行自己的网关,并拥有独立的机器人令牌:

coder gateway start           # 启动编码器的 gateway
assistant gateway start # 启动助手的gateway(单独的进程)

不同的机器人令牌

每个配置文件都有自己的 .env 文件。在每个文件中配置不同的 Telegram/Discord/Slack 机器人令牌:

# 编辑编码器的tokens
nano ~/.hermes/profiles/coder/.env

# 编辑助理的tokens
nano ~/.hermes/profiles/assistant/.env

安全性:令牌锁定

如果两个配置文件意外使用了相同的机器人令牌,第二个网关将被阻止,并显示明确的错误信息,指出冲突的配置文件。支持 Telegram、Discord、Slack、WhatsApp 和 Signal。

持久化服务

coder gateway install         # 创建hermes-gateway-编码器系统d​​/launchd服务
assistant gateway install # 创建hermes-gateway-助理服务

每个配置文件都有自己的服务名称。它们独立运行。

配置文件配置

每个配置文件都有自己的:

  • config.yaml —— 模型、提供者、工具集、所有设置
  • .env —— API 密钥、机器人令牌
  • SOUL.md —— 个性和指令
coder config set model.model anthropic/claude-sonnet-4
echo "You are a focused coding assistant." > ~/.hermes/profiles/coder/SOUL.md

更新

hermes update 仅拉取一次代码(共享),并自动将新预置技能同步到 所有 配置文件:

hermes update
# → 代码更新(12 次提交)
# → Skills 已同步:默认(最新)、编码器(+2 个新)、助手(+2 个新)

用户修改过的技能不会被覆盖。

管理配置文件

hermes profile list           # 显示所有 profiles 的状态
hermes profile show coder # 一台 profile 的详细信息
hermes profile rename coder dev-bot # 重命名(更新别名+服务)
hermes profile export coder # 导出到 coder.tar.gz
hermes profile import coder.tar.gz # 从存档导入

删除配置文件

hermes profile delete coder

这将停止网关、移除 systemd/launchd 服务、删除命令别名,并删除所有配置文件数据。系统会要求你输入配置文件名称以确认。

使用 --yes 可跳过确认:hermes profile delete coder --yes

备注

你无法删除默认配置文件(~/.hermes)。如需删除全部内容,请使用 hermes uninstall

Tab 补全

# Bash
eval "$(hermes completion bash)"

# Zsh
eval "$(hermes completion zsh)"

将该行添加到你的 ~/.bashrc~/.zshrc 中以实现持久补全。在 -p 后、配置文件子命令和顶层命令后均可补全配置文件名称。

工作原理

配置文件使用 HERMES_HOME 环境变量。当你运行 coder chat 时,包装脚本会在启动 Hermes 前设置 HERMES_HOME=~/.hermes/profiles/coder。由于代码库中 119+ 个文件通过 get_hermes_home() 解析路径,所有内容自动作用于配置文件目录 —— 包括配置、会话、记忆、技能、状态数据库、网关 PID、日志和定时任务。

默认配置文件就是 ~/.hermes 本身。无需迁移 —— 现有安装可完全兼容。