Memory 自动注入
wesgine 自动将记忆条目注入 LLM 上下文的三个注入面与九条注入臂。
三个注入面
| 面 | 位置 | 触发时机 | 臂数 |
|---|---|---|---|
| Eager Index | 系统提示词 | 每轮构建 | 5 |
| Lazy Overlay | 当轮消息 overlay | 当轮构建 | 3 |
| Cold-start Overlay | 跨会话摘要重放 | 新会话首轮 | 1 |
合计 9 条注入臂(INV-MEM-50)。
Eager Index(系统提示词)
注入到系统提示词的记忆,每轮都包含:
| 臂 | Scope + Namespace | 包含的 Kind |
|---|---|---|
| 1 | ScopeGlobal, CellNS | Constraint, Instruction |
| 2 | ScopeGlobal, CellNS | Collective |
| 3 | ScopeGlobal, UserNS(actor) | Constraint, Instruction, Fact, Preference |
| 4 | ScopeAgent, agentNS | Constraint, Instruction |
| 5 | ScopeAgent, agentNS + shared | Constraint |
可见性:ActorVisible(不含 session 门)。
Lazy Overlay(当轮)
注入到当前消息的记忆,语义相关条目:
| 臂 | Scope + Namespace | 包含的 Kind |
|---|---|---|
| 6 | ScopeGlobal, UserNS(actor) | Fact, Preference, Correction, Convention, Lesson |
| 7 | ScopeAgent, agentNS | Fact, Preference, Correction, Convention, Lesson |
| 8 | ScopeAgent, shared 通道 | Convention |
可见性:EntryVisible(含 session 门)。
Cold-start Overlay(跨会话)
新会话首轮重放之前会话的摘要:
| 臂 | Scope + Namespace | 包含的 Kind |
|---|---|---|
| 9 | ScopeSession, SessionNS | Context |
可见性:ActorVisible(读私有域)。
前置条件:CrossSessionDays > 0(默认 0 = 整面关闭)+ 行未过期 + Key 不是当前会话。
RecallQualityOK(INV-MEM-50)
每条注入臂的条目必须通过两半检查:
- 可见性:ActorVisible 或 EntryVisible
- 质量:
RecallQualityOK单点
质量门排除:
Conflicted = true(被detectSupersession标记)Stale = true(30+ 天零召回的 L4 条目)
GC 豁免的 Kind(Constraint/Instruction/Environment)对质量门是惰性的——但 KindCollective 不豁免。
显式检索不设质量门
memory(search) 工具回答"我存过什么"。
对指名索取者隐藏被取代的行是把错答换成缺答——记忆中心必须显示冲突否则无人能解决。
Kind 与注入面的关系
| Kind | Eager | Lazy | Cold-start |
|---|---|---|---|
| Constraint | ✓ | — | — |
| Instruction | ✓ | — | — |
| Environment | ✓ | — | — |
| Collective | ✓ | — | — |
| Fact | — | ✓ | — |
| Preference | ✓(L3) + ✓(Lazy) | ✓ | — |
| Correction | — | ✓ | — |
| Convention | — | ✓ | — |
| Lesson | — | ✓ | — |
| Context | — | — | ✓ |
Validate API(INV-MEM-25)
POST /cells/{id}/memory/validate 诊断一条记忆是否可被自动召回。
三面各答一对:
- Eager:
EagerCarriesRow+ActorVisible - Lazy:
LazyCarriesRow+EntryVisible - Cold-start:
ColdStartCarriesRow+ActorVisible
三者 OR = Recallable。
store 看不见的门报成条件:KB arm 的语料绑定在 agent config 上,cold-start 还要 CrossSessionDays > 0——两者都不是行的属性。
臂数写死在契约里
INV-MEM-50 把臂数 9 写死,不是留给后人数。
漏掉的正是数出来的那个——cold-start arm 与 Lazy 三臂同文件隔 350 行,第一遍收敛读作"两处"就收工了。
相关文档
- Memory Kind 与耐久性 →
memory-kind-durability.md - Memory 写入管线 →
memory-write-pipeline.md - Memory GC 与 Digest →
memory-gc-digest.md - Memory 层模型 →
memory-layer-model.md