记忆 Eager 注入(系统提示词索引)
Eager 注入是 wesgine 三层记忆自动注入中的第一层——在系统提示词构建阶段就将高优先级记忆条目嵌入到 Agent 的指令中。
定位
Eager 注入面向必须在每轮都出现的核心记忆,无论用户这轮问了什么。
典型内容:
KindConstraint:行为约束(如"回复用中文")KindInstruction:操作指令(如"代码注释用英文")KindEnvironment:宿主环境信息(OS、运行时版本等)
注入位置
系统提示词
├── Agent Prompt(固定文本)
├── ★ Eager Memory Overlay(高优先级记忆)
├── Skill 指令
├── 工具列表
└── 治理声明
Eager 内容嵌入在系统提示词的特定位置,对模型来说是"基础设定"的一部分。
EagerCarriesRow 白名单
Eager 层携带的条目由 EagerCarriesRow 判定:
| Scope | Kind | 是否携带 |
|---|---|---|
| ScopeSystem | environment | ✅ |
| ScopeGlobal(无 actor) | constraint / instruction | ✅(部门级约束) |
| ScopeGlobal(有 actor) | constraint / instruction | ✅(个人约束) |
| ScopeAgent + agentNS | constraint / instruction | ✅(角色级约束) |
| ScopeAgent + shared | constraint | ❌(停在 shared 里的 Constraint 不被注入) |
| 其他 | * | ❌ |
5 个 arm
Eager 层内部有 5 个注入臂(arm),每个 arm 对应一个 (scope, namespace) 组合:
- ScopeSystem 全局环境
- ScopeGlobal 无 actor(部门共识的约束/指令)
- ScopeGlobal 有 actor(个人约束/指令)
- ScopeAgent + agent 命名空间(角色级约束/指令)
- ScopeAgent + shared 子命名空间(仅特定 Kind)
可见性与质量
每个 arm 都经过两道过滤:
ActorVisible:确保带 actor 标签的条目属于当前 actorRecallQualityOK:排除Conflicted=true或stale=true的条目
对 GC 豁免的 Kind(constraint、instruction、environment),RecallQualityOK 门控是惰性的——这些 Kind 不会被标记 stale,所以实际上总是通过。
与 Prompt Cache 的关系
Eager 内容在会话生命周期内尽量保持稳定,以维护 prompt cache 命中率。当 Eager 内容发生变化(如新增约束)时,缓存失效。
不变量
INV-MEM-50:Eager 的 5 个 arm 都必须经过 RecallQualityOK 质量门控。
相关文档
- 记忆自动注入 →
memory-auto-injection.md - 上下文叠加管线 →
context-overlay-pipeline.md - Lazy Recall →
memory-lazy-recall.md - 记忆 GC 豁免 →
memory-gc-exempt.md