跳到主要内容

Profiles: 运行多个 Agent

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

什么是 profile?

profile 本质上就是一个独立的 Hermes 主目录。每个 profile 都有自己的目录,其中包含自己的 config.yaml.envSOUL.md、memories、sessions、skills、cron 作业和状态数据库。通过 profile,你可以为不同用途运行彼此独立的 agent,比如编码助手、个人 bot、研究 agent,而不会把 Hermes 的状态混在一起。

创建一个 profile 后,它会自动变成一个单独的命令。比如创建名为 coder 的 profile 后,你立刻就能使用 coder chatcoder setupcoder gateway start 等命令。

Quick start

hermes profile create coder       # creates profile + "coder" command alias
coder setup # configure API keys and model
coder chat # start chatting

就是这么简单。现在 coder 已经是一个独立的 Hermes profile,拥有自己的配置、记忆和状态。

创建 profile

空白 profile

hermes profile create mybot

这会创建一个全新的 profile,并为其初始化内置技能。然后运行 mybot setup 来配置 API 密钥、模型和网关 token。

仅克隆配置 (--clone)

hermes profile create work --clone

这会把当前 profile 的 config.yaml.envSOUL.md 复制到新 profile 中。也就是说,新 profile 会使用相同的 API 密钥和模型,但拥有全新的会话和记忆。如果你想换用不同的 API 密钥,可以编辑 ~/.hermes/profiles/work/.env;如果想换一个 personality,可以编辑 ~/.hermes/profiles/work/SOUL.md

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

hermes profile create backup --clone-all

这会复制全部内容,包括配置、API 密钥、personality、所有记忆、完整的会话历史、技能、cron 作业和插件。它相当于一个完整快照,适合做备份,或者从一个已经积累上下文的 agent 分叉出一个新实例。

从指定 profile 克隆

hermes profile create work --clone --clone-from coder
Honcho memory + profiles

启用 Honcho 时,--clone 会自动为新 profile 创建一个专属 AI peer,同时继续共享相同的用户工作区。每个 profile 都会建立自己的观察结果和身份。详见 Honcho -- Multi-agent / Profiles

使用 profiles

命令别名

每个 profile 都会自动在 ~/.local/bin/<name> 下生成一个命令别名:

coder chat                    # chat with the coder agent
coder setup # configure coder's settings
coder gateway start # start coder's gateway
coder doctor # check coder's health
coder skills list # list coder's skills
coder config set model.model anthropic/claude-sonnet-4

这个别名适用于所有 hermes 子命令,本质上只是 hermes -p <name> 的简写。

-p flag

你也可以在任意命令中显式指定 profile:

hermes -p coder chat
hermes --profile=coder doctor
hermes chat -p coder -q "hello" # works in any position

粘性默认值 (hermes profile use)

hermes profile use coder
hermes chat # now targets coder
hermes tools # configures coder's tools
hermes profile use default # switch back

这会设置一个默认值,让普通的 hermes 命令自动指向该 profile,效果类似于 kubectl config use-context

如何知道自己当前在哪个 profile

CLI 会始终显示当前激活的是哪个 profile:

  • 提示符:显示 coder ❯ 而不是
  • 横幅:启动时会显示 Profile: coder
  • hermes profile:显示当前 profile 名称、路径、模型和网关状态

Profiles、workspace 和 sandboxing 的区别

profile 经常会和 workspace 或 sandbox 混淆,但它们其实是不同的概念:

  • profile 为 Hermes 提供独立的状态目录,里面包含 config.yaml.envSOUL.md、会话、记忆、日志、cron 作业和网关状态。
  • workspaceworking directory 是终端命令起始执行的位置,这由 terminal.cwd 单独控制。
  • sandbox 才是限制文件系统访问范围的机制。profile 不会对 agent 提供沙箱隔离。

在默认的 local 终端后端中,agent 仍然拥有与你的用户账号相同的文件系统访问权限。profile 不会阻止它访问 profile 目录之外的文件夹。

如果你希望某个 profile 默认从指定项目目录启动,请在该 profile 的 config.yaml 中为 terminal.cwd 设置一个明确的绝对路径:

terminal:
backend: local
cwd: /absolute/path/to/project

在本地后端里使用 cwd: "." 的含义是“从 Hermes 启动时所在的目录开始”,而不是“从 profile 目录开始”。

还要注意:

  • SOUL.md 可以引导模型,但不会真正强制工作区边界。
  • SOUL.md 的修改会在新会话中干净生效,已有会话可能仍在使用旧的 prompt 状态。
  • 直接问模型“你现在在哪个目录?”并不是可靠的隔离测试。如果你需要一个可预测的工具起始目录,请明确设置 terminal.cwd

运行网关

每个 profile 都会以独立进程运行自己的网关,并使用自己的 bot token:

coder gateway start           # starts coder's gateway
assistant gateway start # starts assistant's gateway (separate process)

使用不同的 bot token

每个 profile 都有自己独立的 .env 文件。你可以为每个 profile 配置不同的 Telegram / Discord / Slack bot token:

# Edit coder's tokens
nano ~/.hermes/profiles/coder/.env

# Edit assistant's tokens
nano ~/.hermes/profiles/assistant/.env

安全性:token 锁

如果两个 profile 不小心使用了同一个 bot token,第二个网关会被阻止启动,并显示明确的错误信息,指出冲突的是哪个 profile。Telegram、Discord、Slack、WhatsApp 和 Signal 都支持这一机制。

持久化服务

coder gateway install         # creates hermes-gateway-coder systemd/launchd service
assistant gateway install # creates hermes-gateway-assistant service

每个 profile 都会获得自己独立的服务名,它们彼此独立运行。

配置 profiles

每个 profile 都拥有各自独立的:

  • config.yaml - 模型、provider、工具集和全部设置
  • .env - API 密钥和 bot token
  • SOUL.md - personality 和说明
coder config set model.model anthropic/claude-sonnet-4
echo "You are a focused coding assistant." > ~/.hermes/profiles/coder/SOUL.md

如果你希望这个 profile 默认在某个特定项目中工作,也可以给它单独设置 terminal.cwd

coder config set terminal.cwd /absolute/path/to/project

Updating

hermes update 只会拉取一次共享代码,然后自动把新的内置技能同步到所有 profiles:

hermes update
# → Code updated (12 commits)
# → Skills synced: default (up to date), coder (+2 new), assistant (+2 new)

用户自行修改过的技能永远不会被覆盖。

管理 profiles

hermes profile list           # show all profiles with status
hermes profile show coder # detailed info for one profile
hermes profile rename coder dev-bot # rename (updates alias + service)
hermes profile export coder # export to coder.tar.gz
hermes profile import coder.tar.gz # import from archive

删除 profile

hermes profile delete coder

这会停止网关、移除 systemd/launchd 服务、删除命令别名,并删除该 profile 的全部数据。系统会要求你输入 profile 名称来确认。

如需跳过确认,可使用 --yeshermes profile delete coder --yes

备注

你不能删除默认 profile(~/.hermes)。如果想移除全部内容,请使用 hermes uninstall

Tab completion

# Bash
eval "$(hermes completion bash)"

# Zsh
eval "$(hermes completion zsh)"

把这行加入 ~/.bashrc~/.zshrc 后,就能获得持久化补全。它可以补全 -p 后的 profile 名称、profile 子命令以及顶层命令。

How it works

profile 机制依赖 HERMES_HOME 环境变量。当你运行 coder chat 时,包装脚本会在启动 hermes 之前先设置 HERMES_HOME=~/.hermes/profiles/coder。由于代码库中有 119+ 个文件会通过 get_hermes_home() 来解析路径,因此 Hermes 的状态会自动限定到这个 profile 目录,包括配置、会话、记忆、技能、状态数据库、网关 PID、日志和 cron 作业。

这和终端工作目录是两回事。工具执行会从 terminal.cwd 开始,或者在本地后端使用 cwd: "." 时从启动目录开始,而不会自动从 HERMES_HOME 开始。

默认 profile 本质上就是 ~/.hermes 本身,不需要迁移,现有安装会保持完全一致的工作方式。