Memory

Memory 模块提供三类持久上下文:curated memory、session/run memory、skill learning memory。主链 prompt 使用 frozen curated snapshot,审计和学习使用 session/run evidence;Task evidence 只作为事实记录。

大模块流程

CuratedMEMORY.md / USER.md
->
Snapshotrun 开始前冻结
->
PromptContextBuilder 注入 system sections
->
Session运行事件和可见历史
->
Learningrun receipts / skill effects

小模块拆分

curated

人工或工具维护的长期记忆文件。MemoryService 在每个 run 开始前捕获 snapshot,ContextBuilder 只读 snapshot,避免运行中变化影响同一轮 prompt。

读取 workspace 下的 memory 文件。
生成 MemorySnapshot。
as_prompt_sections() 渲染为 system prompt sections。

sessions

SQLite session store 保存 message/event 流、usage、system prompt snapshot、tool call、tool result、task evidence 与 acceptance 事件等,并支持 FTS 检索。

AgentLoop append_message 记录每一步。
context_visible=false 的内部事件不进入普通对话历史。
get_history 给 ContextBuilder 取可见历史。
session_search 工具使用检索能力找历史证据。

runs

run memory 记录一次 run 的 receipts、acceptance metadata、skill effects。它是 skill learning 的主要证据来源,但 learning 入口由 task accepted 触发,而不是单个 run 触发。

run_completed 后记录 run receipt。
用户 acceptance accept/revise/abandon 更新 task 状态,并为 skill learning 标记 final accepted run。
skill effects 根据成功率重算版本分数。

skills learning store

保存 learning candidates、drafts、review 状态和发布记录。它把一次运行经验变成可审核的长期能力改动。

从 accepted task evidence 建 candidate,包含 task 的所有 runs 和 final_accepted_run_id。
candidate 进入 synthesis。
生成 draft 后由人审阅发布。