Hermes 教程 02:配置详解

难度:⭐⭐ 基础 | 预计时间:15 分钟 | 适配版本:v0.13.0


配置文件架构

~/.hermes/config.yaml
model

默认模型/Provider
agent

Agent 行为参数
terminal

终端后端配置
display

显示/主题配置
memory

记忆系统配置
tools

工具集开关
gateway

网关配置
checkpoints

快照回滚配置
auxiliary

辅助任务路由
redaction

敏感信息脱敏
hermes auth 凭证池

通过 CLI 管理,替代手动编辑 .env


主要配置项

model --- 模型配置

yaml 复制代码
model:
  default: anthropic/claude-sonnet-4      # 默认模型
  provider: openrouter                    # 默认 Provider
  context_length: 200000                  # 上下文长度

支持的 Providers(200+):

Provider 认证方式 CLI 添加命令
OpenRouter API Key hermes auth add openrouter --api-key <key>
Anthropic API Key hermes auth add anthropic --api-key <key>
DeepSeek API Key hermes auth add deepseek --api-key <key>
xAI / Grok API Key hermes auth add xai --api-key <key>
Google Gemini API Key hermes auth add google --api-key <key>
Hugging Face Token hermes auth add huggingface --api-key <token>
MiniMax API Key hermes auth add minimax --api-key <key>
MiniMax CN API Key hermes auth add minimax-cn --api-key <key>
Nous Portal OAuth hermes auth add nous --type oauth
OpenAI Codex OAuth hermes auth add codex --type oauth
... ... ...

v0.13.0 新增 :Provider 插件化架构,第三方可通过 plugins/model-providers/ 目录即插即用,无需修改核心代码。

agent --- Agent 行为

yaml 复制代码
agent:
  max_turns: 90                            # 最大对话轮次
  tool_use_enforcement: false              # 强制使用工具

terminal --- 终端后端

yaml 复制代码
terminal:
  backend: local                           # local / docker / ssh / modal / daytona / singularity / vercel
  cwd: ~/                                  # 默认工作目录
  timeout: 180                             # 命令超时(秒)

7 种后端对比:

后端 适用场景 成本特点
Local 本地开发测试 零成本
Docker 容器化部署 基础设施成本
SSH 现有云主机托管 利用现有资源
Singularity HPC 环境 视集群而定
Modal Serverless,低频使用 空闲休眠,月成本个位数美元
Daytona Serverless,持久化 同上
Vercel Sandbox 边缘部署 按量计费

Serverless 成本优势:日均消息 < 100 条时,相比常驻 VPS($5-10/月)成本下降 70% 以上

memory --- 记忆系统

yaml 复制代码
memory:
  memory_enabled: true                     # 启用持久记忆
  user_profile_enabled: true               # 用户画像
  provider: builtin                        # builtin / honcho / mem0
  memory_char_limit: 3000                  # 单条记忆上限
  user_char_limit: 2000                    # 用户画像上限

checkpoints --- 快照回滚

yaml 复制代码
checkpoints:
  enabled: true                            # 启用文件系统快照
  auto_prune: true                         # 自动清理旧快照(v0.13.0 Checkpoints v2 真正剪枝)
  max_snapshots: 3                         # 最多保留快照数

v0.13.0 重要更新:Checkpoints v2 重写状态持久化,真正的剪枝机制,磁盘防护,消除孤立影子仓库。旧 checkpoint 可能需要重建。

auxiliary --- 辅助任务路由

yaml 复制代码
auxiliary:
  compression:
    provider: minimax-cn                   # 上下文压缩 Provider
    model: abab6.5s-chat
  vision:
    provider: minimax-cn                   # 图像分析 Provider
    model: auto
  curator:                                 # v0.13.0 新增:Curator 模型配置
    provider: minimax-cn
    model: auto

redaction --- 敏感信息脱敏(v0.13.0 安全强化)

yaml 复制代码
redaction:
  enabled: true                            # 默认开启!敏感信息自动脱敏

⚠️ 破坏性变更 :v0.13.0 将 redaction.enabled 默认改为 true。升级后如需关闭,显式设置 redaction.enabled: false

gateway --- 网关平台白名单(v0.13.0 新增)

yaml 复制代码
gateway:
  platforms:
    telegram:
      enabled: true
      bot_token: "123456:ABC-DEF..."
      allowed_chats:                        # 白名单:仅响应指定聊天
        - "-1001234567890"
        - "123456789"
    slack:
      enabled: true
      bot_token: "xoxb-..."
      signing_secret: "abc..."
      allowed_channels:                     # 白名单:仅响应指定频道
        - "#general"
        - "#dev"
    matrix:
      enabled: true
      allowed_rooms:                        # 白名单:仅响应指定房间
        - "#hermes:example.com"

v0.13.0 新增平台白名单配置:allowed_channels(Slack)、allowed_chats(Telegram)、allowed_rooms(Matrix/Mattermost 等),增强安全性。


认证管理(v0.13.0 推荐方式)

bash 复制代码
# 添加 API Key
hermes auth add openrouter --api-key sk-or-xxxxx
hermes auth add anthropic --api-key sk-ant-xxxxx

# 添加 OAuth(交互式)
hermes auth add nous --type oauth

# 查看所有认证
hermes auth list
hermes auth status openrouter

# 移除认证
hermes auth remove openrouter 0

# 重置冷却时间
hermes auth reset openrouter

# 登出 OAuth
hermes auth logout nous

虽然 .env 文件仍兼容,但 v0.13.0 强烈推荐使用 hermes auth 管理凭证,支持多 key 轮询和自动故障切换。

.env 文件示例(legacy 兼容)

bash 复制代码
# 模型 API Keys
ANTHROPIC_API_KEY=sk-ant-xxxxx
OPENROUTER_API_KEY=sk-or-xxxxx
DEEPSEEK_API_KEY=sk-xxxxx
MINIMAX_API_KEY=xxxxx
MINIMAX_CN_API_KEY=xxxxx

# TTS / STT(可选)
ELEVENLABS_API_KEY=xxxxx

# 其他
GITHUB_TOKEN=ghp_xxxxx                     # Skills Hub rate limit 优化

Profiles --- 独立配置集

Profiles 让你运行多个独立的 Hermes 实例,环境完全隔离。

bash 复制代码
# 创建 Profile
hermes profile create work                 # 创建名为 work 的 Profile
hermes profile create dev --clone          # 从当前配置克隆

# 切换 Profile
hermes profile use work                    # 切换到 work
hermes -p work                             # 或用命令行参数

# 查看所有 Profile
hermes profile list
hermes profile show work                   # 显示详情

# 导入导出
hermes profile export work                 # 导出为 tar.gz
hermes profile import work.tar.gz          # 从 tar.gz 导入

每个 Profile 的目录结构:

复制代码
~/.hermes/profiles/<name>/
├── config.yaml
├── .env
├── skills/
├── sessions/
└── ...

配置命令速查

bash 复制代码
hermes config show                       # 显示当前配置
hermes config edit                       # 在 $EDITOR 中打开 config.yaml
hermes config set model.default anthropic/claude-sonnet-4
hermes config path                       # 查看配置文件路径
hermes config env-path                   # 查看 .env 路径
hermes config check                      # 检查配置完整性
hermes config migrate                    # 更新配置(添加新选项)

hermes auth list                         # 查看所有认证池
hermes auth status <provider>            # 查看特定提供商认证状态

推荐配置组合

入门推荐(免费优先)

yaml 复制代码
model:
  default: openrouter/anthropic/claude-sonnet-4
  provider: openrouter

使用 hermes auth add openrouter --api-key <key> 配置。

OpenRouter 有免费额度,适合入门。

进阶推荐(国内用户)

yaml 复制代码
model:
  default: minimax-cn/MiniMax-Text-01
  provider: minimax-cn
auxiliary:
  compression:
    provider: minimax-cn
  vision:
    provider: minimax-cn
  curator:
    provider: minimax-cn

相关推荐
冬奇Lab6 小时前
每日一个开源项目(第140篇):AgentScope 2.0 - 阿里开源的生产级 Agent 框架
人工智能·开源·agent
冬奇Lab6 小时前
Skill 系列(04):Skill 指标体系——L1/L2/L3 三层监控,让质量下降有据可查
人工智能·开源·llm
IT_陈寒7 小时前
Vite的静态资源打包让我熬夜到三点,这坑千万别跳
前端·人工智能·后端
玩转AI不是事8 小时前
用IndexedDB做AI对话离线缓存实战
人工智能
Asize9 小时前
多模态生图:从 Vite 工程化到前端调用 Qwen Image
javascript·人工智能·后端
MobotStone9 小时前
AI项目越多,为什么越容易失控
人工智能·aigc
十有八七9 小时前
AI时代的置身X内
前端·人工智能
Lkstar9 小时前
A2A协议深度解析|Agent2Agent通信标准,智能体互联网的"HTTP"
人工智能·llm
百度Geek说9 小时前
当代码越来越便宜,什么在变贵?
人工智能
橘子星9 小时前
LLM 无状态架构实践:从原理到代码落地
前端·javascript·人工智能