Files
16gagent/research/hermes-agent-study.md
T
2026-06-06 10:40:48 +08:00

73 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Hermes Agent 深挖笔记(第二层)
> 2026-05-31 下午
> 重点:委派系统 / Curator / Kanban / 记忆插件实现
## 1. 委派(Subagent)系统 — delegate_tool.py
**设计思想:**
- **嵌套深度控制**max_spawn_depth = 1-3),防止无限递归委派
- **Orchestrator 角色**:深度-1 的子 Agent 也可以产生自己的 Worker
- **心跳监控**:每 30s 父进程检查子 Agent 活跃状态,450s 空闲或 1200s 卡住一个工具 → 标记为 stale
- **受限工具集**:子 Agent 永远不能访问 delegate_task / clarify / memory / send_message / execute_code
- **工具集继承+扩展**:父工具的 composite toolset 自动展开匹配子任务请求
- **ThreadPoolExecutor** 实现并行执行
**迁移价值**:高。这是真正的多 Agent 协作模式,比我的简单"拆解"更深一层——它明确了 Agent 间的信任边界和监控机制。
## 2. Curator 后台维护系统 — agent/curator.py
**设计思想:**
- **空闲触发**(不是 cron 定时),Agent 空闲时自动运行
- **Skill 生命周期管理**pin(固定)/ archive(归档)/ consolidate(合并)/ patch(打补丁)
- **永不删除** — 只归档,可恢复
- **独立客户端** — 不接触主会话的 prompt cache,用 auxiliary client
- **持久状态** — last_run_at、时长、summary 存储在 `.curator_state`
**迁移价值**:中高。后台维护模式很适合"自改进循环"的自动化。
## 3. Kanban 项目追踪系统 — hermes_cli/kanban_db.py
**设计思想:**
- **SQLite 多板** — 不同项目用不同 board,完全隔离
- **CAS 并发控制**Compare-and-Swap)— WAL 模式 + BEGIN IMMEDIATE,多 Worker 同时认领任务不会冲突
- **多 Profile 协调** — 不同 Hermes profile 共享同一个 board
- **Env 解析链**:参数 > 环境变量 > 配置文件 > 默认值
- **Worker 隔离** — 子 Agent 只看到自己的 board
**迁移价值**:中。对于大项目的进度追踪很有参考价值。
## 4. 真实记忆插件实现 — plugins/memory/
**验证了 MemoryProvider 抽象基类模式:**
| 插件 | 特点 | 数据存储 |
|------|------|----------|
| Honcho | AI-native 记忆,语义搜索、peer profile、dialectic Q&A、conclusions | 远程 API |
| Hindsight | 基于时间线的记忆回顾 | SQLite 本地 |
| Mem0 | 新一代 AI 记忆 | 远程 API |
| Supermemory | 记忆管理 | 本地文件 |
| Byterover | 字节级记忆 | 自定义格式 |
| OpenViking | 维京记忆系统 | SQLite |
| RetainDB | 持久化数据库 | SQLite |
| Holographic | 全息记忆(向量存储 + 检索) | 本地 + 向量 |
**共同模式:**
- 都实现了 MemoryProvider ABCinitialize / prefetch / sync_turn / get_tool_schemas / shutdown
- 配置解析链:profile-local > global > env var
- Profile 隔离:每个 Hermes profile 有独立身份
**迁移价值**:高。验证了我的记忆系统插件化方向是对的。
## 5. 值得移植到我的系统的模式
1. **子 Agent 心跳监控** — 委派任务不应盲目等待,需要超时 + 活跃检测
2. **Orchestrator 角色** — 不是所有 Agent 都平级,可以有"组长 Agent"来协调
3. **空闲触发后台任务** — 不是所有维护都需要定时,空闲时运行更省心
4. **永不删除只归档** — 技能、记忆、项目的安全策略
5. **CAS 并发控制** — 多 Agent 同时操作同一资源时的协调模式
6. **配置解析链** — 参数 > 环境变量 > 文件 > 默认,确定的优先级