Agent工坊

【Agent工坊】Hermes Profiles 多配置实战:一套安装跑3个独立AI Agent,隔离技能/记忆/API Key

你的"内容工厂"Agent每天凌晨2点自动跑流水线,但你想在工作时间用Hermes写代码——两个场景共享同一套API Key、技能库和记忆,相互污染。Hermes Profiles 就是解决这个问题的:一套安装,N个独立"身份",每个Profile有自己隔离的技能、记忆、配置和API Key池。

你肯定遇到过这个场景

你用Hermes搭了一套内容流水线——hotspot_scan搜热点 → researcher深度调研 → outliner出大纲 → writer写稿 → reviewer审核 → publisher发布。为了让这套流程每天自动跑,你配了Cron Job,凌晨2点触发。

一切正常,直到有一天——

你白天用Hermes问:"帮我重构一下这个Python项目的目录结构"。Agent干完活后,第二天起来发现——昨晚的内容流水线跑错了。因为Agent把白天代码重构中学到的"偏好"带到了晚上的内容生产中,它开始用"代码重构思维"去写公众号文章。

这不是Agent的错。是你的工作场景在互相污染。

更糟糕的是:
- 内容生产需要DeepSeek(便宜,适合长文),但写代码需要Claude(推理强)
- 内容生产的Skill库里有30个"写作类技能",但写代码时它们全是噪音
- 内容生产的记忆里有"读者偏好幽默风格",但写代码时不需要

你需要的是一个办法,让不同场景的Agent完全隔离

Hermes Profiles 就是做这件事的。

Profiles 是什么?(30秒速览)

Profiles 是 Hermes Agent 的"多身份"系统。每个 Profile 是一个独立的运行环境:

~/.hermes/
├── skills/          ← 全局技能(所有Profile共享)
├── sessions/        ← 全局会话记录
├── config.yaml      ← 默认Profile的配置
├── .env             ← 默认Profile的环境变量(API Key等)
└── profiles/        ← 👈 这里是隔离的核心
    ├── content-factory/
    │   ├── skills/       ← 仅此Profile可见的技能
    │   ├── memories/     ← 仅此Profile的记忆
    │   ├── config.yaml   ← 独立的配置(模型、温度等)
    │   └── .env          ← 独立的API Key(可用不同Provider)
    ├── dev-lab/
    │   ├── skills/
    │   ├── memories/
    │   ├── config.yaml
    │   └── .env
    └── personal/
        ├── skills/
        ...

关键特性:
- 技能隔离:每个Profile有自己的skills/目录,不会互相干扰
- 记忆隔离memories/独立,内容生产不会"记住"你的代码偏好
- 配置隔离:每个Profile可以用不同的模型、Provider、API Key
- 会话隔离sessions/独立,不会在错误Profile中Resume
- Cron独立:每个Profile有自己的定时任务配置

实战:创建3个典型Profile

Profile 1:「content-factory」内容工厂

这个Profile专门跑AI创业内参的内容流水线——搜热点、写文章、发公众号。特点是:
- 用DeepSeek(价格低,适合长文本生成)
- 加载30+个写作相关Skill
- 配了Cron Job:每天凌晨2点自动跑

# 创建Profile
hermes profile create content-factory

# 设置此Profile的默认模型(DeepSeek,便宜适合长文)
hermes -p content-factory model deepseek

# 为此Profile配置独立的API Key
# 编辑 ~/.hermes/profiles/content-factory/.env
DEEPSEEK_API_KEY=sk-your-deepseek-key
# 生产环境可以和默认Profile用不同的Key!

# 安装内容生产需要的Skill
hermes -p content-factory skills install ai-neican-hotspot
hermes -p content-factory skills install ai-neican-content-pipeline
hermes -p content-factory skills install wechat-public-account-draft

# 配置Cron:每天凌晨2点触发内容流水线
hermes -p content-factory cron add \
  --schedule "0 2 * * *" \
  --skill "ai-neican-hotspot" \
  --prompt "扫描AI热点,产出当日文章并自动提交草稿箱"

# 设为默认Profile(之后不指定-p也使用它)
hermes profile use content-factory

Profile 2:「dev-lab」开发实验室

这个Profile用来写代码、做实验。特点是:
- 用Claude Sonnet(推理强,适合编程)
- 只加载代码相关的Skill
- 可以随意折腾,不影响生产环境

# 从默认Profile克隆创建(保留基础配置)
hermes profile create dev-lab --clone

# 换成Claude模型
hermes -p dev-lab model claude-sonnet-4

# 配置独立的Anthropic API Key
# 编辑 ~/.hermes/profiles/dev-lab/.env
ANTHROPIC_API_KEY=sk-ant-your-anthropic-key

# 清掉写作相关Skill(它们在这个Profile里是噪音)
# 直接删除 ~/.hermes/profiles/dev-lab/skills/ 下的写作skill目录

# 或者更干净:从零创建,不要--clone
hermes profile delete dev-lab
hermes profile create dev-lab  # 干净初始化

# 只装代码相关Skill
hermes -p dev-lab skills install test-driven-development
hermes -p dev-lab skills install github-pr-workflow
hermes -p dev-lab skills install python-debugpy

Profile 3:「personal-assistant」个人助理

日常问答、查资料、写邮件——不需要任何自动化流水线。用本地模型省成本:

hermes profile create personal

# 配置使用本地模型(Ollama)
hermes -p personal model ollama/llama4

# 或者用最便宜的云端方案
hermes -p personal model openrouter/deepseek/deepseek-chat

# 不同Profile用不同Key,避免配额互相影响
# ~/.hermes/profiles/personal/.env
OPENROUTER_API_KEY=sk-or-personal-key

切换Profile的超实用技巧

# 临时切换(仅本次会话)
hermes -p dev-lab

# 永久切换(之后所有hermes命令默认使用此Profile)
hermes profile use dev-lab

# 查看当前使用的Profile
hermes profile show
# 或会话内输入
/profile

# 查看所有Profile
hermes profile list
# 输出示例:
#   content-factory  (active)
#   dev-lab
#   personal

Profile 隔离机制深度解析

1. 技能隔离(核心价值)

~/.hermes/skills/              ← 全局技能:所有Profile可见
    autonomous-ai-agents/
        hermes-agent/SKILL.md

~/.hermes/profiles/dev-lab/skills/  ← Profile级技能:仅dev-lab可见
    software-development/
        test-driven-development/SKILL.md

~/.hermes/profiles/content-factory/skills/  ← 仅content-factory可见
    ai-neican-hotspot/SKILL.md

规则
- 全局 ~/.hermes/skills/ 下的技能 所有Profile都能加载
- Profile 下的 skills/ 仅该Profile可见
- 加载优先级:Profile级 > 全局级(同名Skill时Profile覆盖全局)
- 一个Profile不能修改另一个Profile的技能(有安全守卫)

2. 记忆隔离

~/.hermes/profiles/content-factory/memories/
    ├── user-preference.md    ← "读者喜欢幽默风格,多用emoji"
    └── workflow-notes.md     ← "热点文章标题要带数字"

~/.hermes/profiles/dev-lab/memories/
    ├── user-preference.md    ← "代码风格用black,测试用pytest"
    └── coding-rules.md       ← "禁止一行超过120字符"

两个Profile的user-preference.md完全不同,Agent在content-factory里不会"想起"你的代码风格偏好。

3. 配置隔离

# ~/.hermes/profiles/content-factory/config.yaml
model:
  default: deepseek/deepseek-chat
agent:
  max_turns: 150          # 内容流水线需要更多turn
compression:
  enabled: true
  threshold: 0.5          # 上下文过半自动压缩

# ~/.hermes/profiles/dev-lab/config.yaml
model:
  default: anthropic/claude-sonnet-4-20250514
agent:
  max_turns: 60           # 代码任务通常更快完成
security:
  website_blocklist: []   # 开发环境不做网站限制

4. Cron Job 隔离

每个Profile的Cron配置独立存储:

# content-factory的Cron:每天凌晨2点
hermes -p content-factory cron add \
  --schedule "0 2 * * *" \
  --skill "ai-neican-hotspot"

# dev-lab的Cron:每天早上10点自动review昨天的PR
hermes -p dev-lab cron add \
  --schedule "0 10 * * *" \
  --skill "github-code-review"

两个Cron互不干扰——content-factory凌晨跑,dev-lab白天跑,各自用自己的API Key。

高级用法

Clone:快速复制Profile

# 从content-factory克隆一个test版本
hermes profile create content-factory-test --clone-from content-factory

# 克隆全部(包括技能、记忆、配置)
hermes profile create backup-20260723 --clone-all

--clone vs --clone-all
- --clone:只复制配置文件
- --clone-all:复制配置 + 技能 + 记忆 + Cron

Export/Import:迁移到另一台机器

# 导出Profile为压缩包
hermes profile export content-factory
# 生成 content-factory.tar.gz

# 在另一台机器导入
hermes profile import content-factory.tar.gz

这对多机器部署特别有用——在开发机上调试好Profile,导出后导入到服务器。

Alias:命令行快捷方式

# 给dev-lab Profile创建一个快捷命令
hermes profile alias dev-lab

# 之后可以直接用
dev-lab "帮我写一个快排的Python实现"
# 等同于
hermes -p dev-lab chat -q "帮我写一个快排的Python实现"

与 Cron Jobs 组合:实现真正的"无人值守"

这是Profile系统的杀手级用法。回到开头说的场景:

┌─────────────────────────────────────────────────┐
│              凌晨2:00 — 自动触发                 │
│                                                  │
│  Cron → content-factory Profile                 │
│         ↓                                       │
│  AI创业内参流水线(hotspot_scan → ... → 发布)     │
│         ↓                                       │
│  使用DeepSeek API Key #1(内容生产专用)           │
│         ↓                                       │
│  记忆:"读者喜欢XX风格"                            │
│         ↓                                       │
│  文章提交到微信公众号草稿箱                        │
│                                                  │
├─────────────────────────────────────────────────┤
│              白天10:00 — 手动使用                 │
│                                                  │
│  hermes -p dev-lab "review PR #42"               │
│         ↓                                       │
│  使用Anthropic API Key #2(开发专用)              │
│         ↓                                       │
│  记忆:"代码风格用black,测试用pytest"              │
│         ↓                                       │
│  产出 Code Review 意见                            │
│                                                  │
├─────────────────────────────────────────────────┤
│              随时 — 临时使用                      │
│                                                  │
│  hermes -p personal "今天的天气?"                 │
│         ↓                                       │
│  使用OpenRouter Key #3(轻量日常)                 │
│         ↓                                       │
│  记忆:通用问答,无特定偏好                         │
└─────────────────────────────────────────────────┘

三个身份,三套Key,三组记忆,互不干扰。这才是真正的一人多面。

常见坑与最佳实践

坑1:忘记指定 -p,在错误Profile中操作

# 你本来想给dev-lab装skill,但忘记-p
hermes skills install test-driven-development
# ❌ 这会装到当前活动Profile(可能是content-factory)

# 正确做法
hermes -p dev-lab skills install test-driven-development
# 或用 alias
dev-lab skills install test-driven-development

建议:用hermes profile use明确设置活动Profile,或在.bashrc中设置环境变量HERMES_PROFILE

坑2:Profile之间的Skill互相引用

如果你在dev-lab的Skill里写了related_skills: [ai-neican-hotspot],但这个Skill只在content-factory中存在——dev-lab会找不到它。跨Profile引用是安全的(不会报错),但Skill不会加载。

建议:Profile级Skill的related_skills只引用同Profile或全局Skill。

坑3:Clone时带入了不需要的API Key

hermes profile create dev-lab --clone-all
# 如果默认Profile的.env里有生产Key,dev-lab也会复制一份

建议:用--clone(只复制配置),然后手动配置.env

坑4:Cron Job在错误的Profile运行

# ❌ 如果当前活动Profile是dev-lab,这个cron会加到dev-lab
hermes cron add --schedule "0 2 * * *" --skill "ai-neican-hotspot"

# ✅ 明确指定Profile
hermes -p content-factory cron add --schedule "0 2 * * *" --skill "ai-neican-hotspot"

最佳实践总结

场景 Profile 模型建议 API Key策略 Skill数量
自动化流水线 content-factory DeepSeek/GPT-4o-mini 独立Key 10-30个
代码开发 dev-lab Claude Sonnet 4 独立Key 5-10个
日常问答 personal Llama4/最便宜模型 独立Key 0-5个
实验测试 test-xxx 随意 限额Key 按需

核心理则:
1. 一个Profile只做一类事——不要让dev-lab又写代码又发文章
2. API Key要独立——万一一个Key泄露或超额,不影响其他Profile
3. 技能要精简——dev-lab不需要知道怎么写公众号爆款标题
4. 内存要隔离——Agent"记住"的东西越少越精准

行动建议

看到这里,你可以立刻做三件事:

  1. 创建你的第一个Profile
hermes profile create my-project --clone
hermes -p my-project model claude-sonnet-4
  1. 把现有Cron Job迁移到独立Profile
# 先检查当前Profile的Cron
hermes cron list
# 创建专门的Profile
hermes profile create auto-pipeline
# 删掉旧Profile的Cron,加到新Profile
hermes cron remove <job-id>
hermes -p auto-pipeline cron add ...
  1. 设置Profile Alias,省掉每次敲-p
hermes profile alias dev-lab
# 之后直接用
dev-lab "review this PR"

一句话总结:Hermes Profiles 解决了"一个Agent做多件事会互相污染"的根本问题——不是让一个Agent更聪明,而是让多个Agent各自专注,互不干扰。


AI创业 #HermesAgent #一人公司 #AI工具 #效率提升