# 10 个自用 Agent 的 Honcho 拓扑 > 目标:10 个 AI Agent 共用一份记忆,但各自保持独立身份与视角。 > 适用:`deploy.stack/honcho/` + Hermes(或任意 Honcho SDK)客户端。 --- ## 0. 一句话结论 ``` workspace = home (10 个 agent 共用) 用户 peer = laodeng (10 个 agent 共用同一个 ID ← 关键) agent peer = agent-01..10 (每个 agent 独立) session = agent-NN-<话题> ``` **用户 peer 必须统一** —— 否则会得到 10 份互不相干的画像,跨 agent 召回直接失效。 --- ## 1. 为什么这么配 ### 1.1 Honcho 的三个存储原语 | 原语 | 作用 | 隔离强度 | |------|------|----------| | **workspace** | 硬隔离边界,什么都不跨 | 最强 | | **peer** | 一个持久身份;**representation 按 peer 存储,跨该 peer 的所有 session 累积** | — | | **session** | 一段有界对话上下文;摘要和最近消息只在本 session 内 | 最弱 | 来源:[Architecture](https://honcho.dev/docs/v3/documentation/core-concepts/architecture)、 [Design Patterns](https://honcho.dev/docs/v3/documentation/core-concepts/design-patterns)。 ### 1.2 representation 的累积规则 > "When `observe_me=true`, Honcho forms one representation per peer, > reasoning over every message written to that peer **across all sessions**." 关键在 **across all sessions**:只要消息署名是同一个 peer, 无论落在哪个 session,都会汇入同一份画像。 这带来两个结论: 1. **用户统一用 `laodeng`** → 你在 agent-01 说的话和 agent-05 说的话, 都进 `laodeng` 的画像 → 任何 agent 召回 `laodeng` 都能拿到全部。 2. **agent 各自用 `agent-NN`** → 每个 agent 自己的发言单独成一份画像, 互不混淆,可审计「哪台 agent 说了什么」。 ### 1.3 ⚠️ 常见错误:把用户拆成多个 peer 仓库现有 `share-multi-client.md` 用的方案: ``` laodeng-mypc03x / laodeng-govpcxxxx / laodeng-macxxxxxxx ← 错误 ``` 上游文档明确把这种做法列为 **Common Mistake**: > "Splitting one identity across peer IDs — If the same user is `alice`, > `alice-discord`, and `alice-cursor`, Honcho builds separate representations. > Use one stable peer ID when you want unified memory." 后果:`laodeng-mypc03x` 的画像里只有 mypc03 上的对话。 agent-02 在 gov-pc 上问「用户喜欢什么」,只能读到 `laodeng-govpcxxxx` 的画像 —— **看不到 mypc03 上的对话**。文档声称的「A 上聊的事 B 上能召回」不成立。 **正确做法**:`peerName`(用户)全局唯一,设备区分靠 `aiPeer` + session 命名。 --- ## 2. 具体映射 ### 2.1 Honcho 侧 ``` workspace: home ├─ peer: laodeng observe_me = true ← 用户画像,跨 agent 共享 ├─ peer: agent-01 observe_me = false ← 确定性执行体,不建模 ├─ peer: agent-02 observe_me = false └─ ... session: agent-01-coding peers = [laodeng, agent-01] session: agent-01-writing peers = [laodeng, agent-01] session: agent-02-research peers = [laodeng, agent-02] ``` ### 2.2 Hermes 侧(每个 agent 一份配置) 上游 Hermes 插件的配置格式(`~/.hermes/honcho.json` 或 `$HERMES_HOME/honcho.json`): ```json { "baseUrl": "http://10.8.0.9:8000", "hosts": { "hermes": { "enabled": true, "aiPeer": "agent-01", "peerName": "laodeng", "workspace": "home", "recallMode": "hybrid", "writeFrequency": "async", "sessionStrategy": "per-directory", "dialecticReasoningLevel": "low", "messageMaxChars": "25000" } } } ``` **10 个 agent 之间唯一不同的是 `aiPeer`**,`peerName` 和 `workspace` 全部一致。 > ⚠️ **配置格式以你的 Hermes 版本为准。** > 仓库 `honcho/readme.md` 和 `share-multi-client.md` 里写的是旧版 YAML 格式 > (`memory.provider: honcho` / `memory.honcho.api_url`)。 > 插件版(`hermes-plugin-honcho`)用的是上面这个 JSON。 > 装好后用 `hermes honcho status` 确认连通性和 peer 映射。 ### 2.3 关键字段 | 字段 | 作用 | 10 agent 场景取值 | |------|------|-------------------| | `peerName` | **用户** peer ID | 全部填 `laodeng` | | `aiPeer` | **AI** peer ID | 每个 agent 填自己的 `agent-NN` | | `workspace` | 工作区 | 全部填 `home` | | `sessionStrategy` | session 命名策略 | `per-directory` 或 `per-repo`(别用 `per-session`,会碎) | | `writeFrequency` | 写入时机 | `async`(不阻塞对话) | | `recallMode` | 召回方式 | `hybrid`(自动注入 + 工具) | | `dialecticReasoningLevel` | dialectic 推理档位 | `low`;`high`/`max` 每次调用贵得多 | --- ## 3. 三个记忆层次 10 个 agent 同时存在时,「共享到什么程度」是个连续谱: | 层次 | 配置 | 效果 | 适合 | |------|------|------|------| | **L1 完全共享** | 同一 workspace + 同一用户 peer | agent-05 知道 agent-01 学到的用户偏好 | 默认,推荐 | | **L2 视角隔离** | session 级 `observe_others=true` | agent-01 只「见过」自己参与过的对话,不见 agent-02 的 | 涉密场景、角色扮演 | | **L3 话题隔离** | named scope | 某类话题的记忆不串台,服务端强制边界 | 客户 A / 客户 B 混用一套实例 | ### 3.1 L2 怎么开 ```bash # 给 agent-01 的 session 打开「观察他人」 curl -X POST "http://10.8.0.9:8000/v3/sessions/agent-01-coding/peers/agent-01/config" \ -H "Authorization: Bearer $AGENT01_TOKEN" \ -H "Content-Type: application/json" \ -d '{"observe_others": true}' ``` 之后 `agent-01` 对 `laodeng` 的画像只包含 agent-01 参与过的 session。 > ⚠️ **无追溯性**:peer 是**在消息写入时**才被排进推理队列的。 > 后加入 session 的 peer **不会**回头处理之前的消息。 > 所以要开 `observe_others` 必须在写第一条消息**之前**配置好。 ### 3.2 L3 什么时候用 named scope 是**服务端强制**的:即使调用方不传 `scope` 参数, scope key 也拿不到 scope 之外的数据(普通 `scope=[...]` 查询参数只是协作式过滤,可绕过)。 ``` scope: work → agent 处理的正经工作内容 scope: personal → 私人闲聊 ``` scope 适合「同一套服务服务多个互不相干的客户/主体」。 --- ## 4. 成本影响(10 agent 规模) ### 4.1 `observe_me: false` 是最大的省钱开关 Honcho 只对 `observe_me=true` 的 peer 做画像推理。 agent 的发言通常和你的发言 1:1,**把 agent peer 的 `observe_me` 关掉, deriver 的 LLM 调用量直接砍掉 40–60%**。 代价:agent 自己没有「自我画像」。对执行型 agent 通常不需要 —— 上游文档原话:"Yes, for deterministic peers Honcho does not need to model, like bots or tool agents." > ⚠️ `observe_me` 是 peer 的属性,创建后不太容易改。 > **建 peer 时就定好**,别等跑起来再调。 ### 4.2 session 粒度 | 策略 | 效果 | 建议 | |------|------|------| | `per-session`(每次新会话) | 上下文碎片化,本地记忆断裂 | ❌ | | `per-directory` / `per-repo` | 同一项目内上下文连续 | ✅ 推荐 | | `global` | 全部挤一个 session | ⚠️ 摘要会互相污染 | > 上游 Common Mistake: "Too many tiny sessions — Summaries and recent messages > are local to one session. Splitting a continuous conversation across many > sessions fragments that local context." ### 4.3 预估 10 agent × 30 msg/天 → 约 **28M token/月** 的 deriver 消耗(详见 `ecs-sizing.md` §6)。 --- ## 5. 验证 ```bash # 1. 确认 peer 数量与 observe_me 配置 docker exec -it honcho-database psql -U honcho -d honcho -c \ "SELECT id, configuration FROM peers ORDER BY id;" # 2. 确认用户在所有 session 里都是同一个 peer docker exec -it honcho-database psql -U honcho -d honcho -c \ "SELECT DISTINCT peer_id FROM messages WHERE peer_id = 'laodeng';" # 3. 队列深度(10 agent 规模应 < 500) curl -s -H "Authorization: Bearer $ADMIN_TOKEN" \ http://10.8.0.9:8000/v3/workspaces/home/queue/status | jq # 4. 跨 agent 召回测试(关键) # agent-05 问「用户之前在 agent-01 那边说过什么偏好」 # → 若能召回,说明用户 peer 统一生效 ``` --- ## 6. 常见问题 | 症状 | 原因 | 修法 | |------|------|------| | agent 读不到别的 agent 学到的用户偏好 | 用户 peer 被拆成了多个 ID | 统一 `peerName` | | 每个 agent 画像都是空的 | peer 创建时 `observe_me` 为 false,但客户端在写消息 | 确认写入用的 peer 名 | | agent-03 能看到 agent-01 的对话(不该) | session 开了 `observe_others` | 关闭该 session 的 `observe_others` | | 新 agent 拿不到历史结论 | 无追溯推理:后加入的 peer 不处理旧消息 | 老消息需要重新触发或手工建 conclusion | | 某 agent 的记忆串到了另一个客户 | 没做 scope 隔离 | 建 named scope + 发 scope key | | 10 个 agent 一起用时 deriver 队列堆积 | `DERIVER_WORKERS=1` 跟不上 | 先加到 2,观察 SiliconFlow 限流 | --- ## 7. 关联文档 - `honcho/ecs-sizing.md` — ECS 选型与成本 - `honcho/public-exposure.md` — 对外提供服务的方案 - `honcho/create-multi-keys.sh` — 批量签发各 agent 的 peer-scoped JWT - `honcho/share-multi-client.md` — 多客户端共享方案(**peer 命名部分已过时,见本文 §1.3**) - [Honcho 设计模式](https://honcho.dev/docs/v3/documentation/core-concepts/design-patterns) - [方向性 representation](https://honcho.dev/docs/v3/documentation/features/advanced/directional-representations) - [Scopes](https://honcho.dev/docs/v3/documentation/features/advanced/scopes)