Session 结束后,Agent 的上下文默认随之消失。Memory Stores 让 Agent 的学习成果和工作产出跨 Session 持久保留——下次启动时,Agent 可以”回忆”之前的内容。Documentation Index
Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
Use this file to discover all available pages before exploring further.
核心概念
| 概念 | 说明 |
|---|---|
| Memory Store | 记忆仓库,按项目或领域划分 |
| Entry | 一条记忆,由 path 标识,每条 Entry 有唯一的 entry_id |
| Version | 每次写入/更新/删除自动生成的版本快照 |
| Redact | 不可逆地遮蔽某版本内容(合规场景) |
API 端点一览
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /memory_stores | 创建 Memory Store |
| GET | /memory_stores | 列出所有 Memory Store |
| GET | /memory_stores/{id} | 获取 Memory Store 详情 |
| DELETE | /memory_stores/{id} | 删除 Memory Store |
| POST | /memory_stores/{id}/memories | 创建 Entry |
| GET | /memory_stores/{id}/memories | 列出所有 Entry |
| GET | /memory_stores/{id}/memories/{entry_id} | 获取单条 Entry(含 content) |
| PUT | /memory_stores/{id}/memories/{entry_id} | 更新 Entry(OCC) |
| DELETE | /memory_stores/{id}/memories/{entry_id} | 删除 Entry |
| POST | /memory_stores/{id}/versions/{version_id}/redact | 遮蔽某版本内容 |
路径规则
Entry 的path 必须是相对路径:
- 合法:
notes/meeting-2026-05-18.md、config.yaml - 非法:
/notes/meeting.md(不能以/开头)
完整流程
1. 创建 Memory Store
2. 创建 Entry
列表接口不返回
content 字段,需要调用单条获取接口才能读取内容。3. 获取单条 Entry
通过entry_id 获取完整内容(包括 content 字段):
4. 更新 Entry
更新 Entry 必须使用 PUT 方法,路径中带entry_id,并携带当前 version(乐观并发控制)。系统会自动生成新版本快照:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
content | string | 是 | 新的内容 |
version | integer | 是 | 当前 Entry 的版本号(用于冲突检测) |
version 与服务端不一致(说明有并发写入),API 将返回 409 Conflict,需要先 GET 最新版本再重试。
5. 删除 Entry
通过entry_id 删除指定 Entry:
删除使用
entry_id(如 mem_entry_xyz),不支持通过 path 查询参数删除。6. 在 Session 中使用
创建 Session 时通过memory_store_ids 关联:
版本追踪
每次对 Entry 执行创建、更新或删除操作,系统都会自动生成一个版本快照。版本不可修改,提供完整的变更历史。Redact(内容遮蔽)
当某个版本包含敏感信息需要永久清除时:统计字段
| 字段 | 说明 |
|---|---|
entry_count | Store 中的 Entry 总数 |
total_size | 所有 Entry 内容的总字节数 |
常见问题
Q: 一个 Session 可以关联多少个 Memory Store? A: 支持多个,按需关联。 Q: Entry 的 path 可以包含子目录吗? A: 可以,如notes/2026/05/daily.md,支持多级路径。
Q: 删除 Entry 后版本还在吗? A: 删除操作本身会生成一个”删除”版本记录,之前的版本仍可追溯。
Q: Memory Store 有容量限制吗? A: 具体限制请参考账户配额,通常足够一般项目使用。
建议为每个独立项目创建单独的 Memory Store,避免不同项目的记忆混淆。