文档导航
文档 / 记忆

记忆

OpenSquilla 记忆帮助 agent 回忆持久上下文,而不必每次都回放所有旧对话。可用于稳定的偏好、可复用的项目事实、以往的决策,以及需要跨 session 留存的笔记。

记忆与 skills 是分开的。Skills 教会 agent 如何完成一项任务;记忆则存储 agent 后续可能需要的有用事实与上下文。

应当存储什么

好的记忆条目是稳定且可复用的:

  • 用户偏好;
  • 项目约定;
  • 反复使用的输出格式;
  • 重要仓库、目录或服务的名称;
  • 用户希望复用的决策;
  • 已完成任务的简短笔记。

避免将以下内容放入记忆:

  • API 密钥或机密;
  • 不需要长期回忆的原始私密数据;
  • 仅用于当前 turn 的一次性指令;
  • 会污染未来检索的嘈杂转储;
  • 应当作为 session 记录导出的精确对话记录。

常用命令

检查记忆健康度:

opensquilla memory status
opensquilla memory status --deep

索引并列出记忆来源:

opensquilla memory index
opensquilla memory list

搜索并查看记忆:

opensquilla memory search "release note format"
opensquilla memory show <path>

同时搜索以往 session 和记忆:

opensquilla memory search "deployment decision" --source all

自然对话用法

当某件事应当被记住时,自然地表达:

Remember that I prefer concise release notes with a risk section.

之后引用该偏好:

Use my usual release-note format for this changelog.

当记忆似乎过时时,请 agent 显式搜索:

Search memory for my release-note preferences before drafting this.

Session 衍生的记忆

对于较长或重要的 sessions,在归档、compaction 或切换任务之前将 session 状态刷入记忆:

opensquilla memory flush-session <session-key>

当精确的旧措辞很重要时,使用 session 导出:

opensquilla sessions export <session-key>

记忆用于有用的回忆。Session 导出用于精确记录。

维护与修复

在编辑记忆文件或更改记忆配置后,刷新索引:

opensquilla memory index --force

检查回退和修复面:

opensquilla memory raw-fallbacks list
opensquilla memory repair list

在诊断指示时,显示或修复已降级的 compaction 记忆记录:

opensquilla memory repair show --summary-id <id>
opensquilla memory repair run --summary-id <id>

最佳实践

  • 保持条目简短且可溯源。
  • 优先使用”Remember X for project Y”,而非含糊的”remember this.”。
  • 在认为 agent 已遗忘前,先搜索记忆。
  • 移除或修订过时的偏好,而不是叠加相互冲突的偏好。
  • 不要将机密放入记忆。
  • 大型参考材料使用 artifacts 或文件保存。

文档索引 · 产品指南 · 改进此页面 · 报告文档问题

在 GitHub 上编辑此页(英文原稿) OpenSquilla 文档 · 中文社区翻译