Agent 记忆层
wesgine 的 L4 Agent 记忆——角色级认知存储。
定位
Agent 记忆(agent_memory)是按 Agent 隔离的认知存储。
每个 Agent 有自己的命名空间,存储该角色独有的学习成果。
层特征
| 属性 | 值 |
|---|---|
| 层名 | agent_memory |
| Scope | ScopeAgent |
| Actor | 必须有 |
| 可见范围 | 该 Actor 在该 Agent 命名空间下 |
| Namespace | AgentNS(agentID) |
| 可写 | ✅ |
| 可清空 | ✅ |
命名空间
Agent 记忆使用 AgentNS(agentID) 寻址。
空 namespace 的 agent_memory 写入会返回 ErrLayerNamespaceRequired:
- 写入成功但永不被召回
- 201 比 400 坏——调用方就此不再找了
共享通道
Agent 命名空间内有共享通道(shared / kb: / c:)。
这些是 Agent 内的共享,不是 Cell 级共识:
- 同一 Agent 的不同 Actor 可以共享某些知识
- 但不跨 Agent 边界
典型内容
| Kind | 示例 |
|---|---|
preference | 用户教给该 Agent 的偏好 |
correction | 用户对该 Agent 的纠正 |
lesson | Agent 在执行中学到的教训 |
fact | Agent 记录的事实 |
convention | 项目惯例 |
耐久性
Agent 记忆的耐久性由 Kind 决定:
constraint/instruction→ 持久,跨会话preference/correction→ 持久,跨会话episodic→ 仅当前会话
GC 与 Digest
Agent 记忆分区独立做 Digest:
- 按
(Namespace, CognitiveOwner)分区 - 不会与其他 Agent 的记忆交叉
detectSupersession在分区内检测被取代的条目
自动注入
L4 记忆通过 Eager 和 Lazy 注入面进入上下文。
Eager 面有两个 arm 读 ScopeAgent,但 kind 集不同。