GET /memory
列出记忆条目。支持按层过滤、分页。
GET /cells/{cellID}/memory
认证
Authorization: Bearer $TOKEN
查询参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
layer | string | 否 | — | 按层过滤:environment / consensus / about_me / agent_memory / session / working / unknown |
namespace | string | 否 | — | 按命名空间过滤 |
kind | string | 否 | — | 按类别过滤:preference / fact / constraint 等 |
limit | int | 否 | 20 | 每页条数 |
offset | int | 否 | 0 | 分页偏移量 |
actor | string | 否 | — | 指定 actor 过滤。仅 admin token 有效,非 admin 一律取 token 中的 actor |
请求示例
列出 about_me 层的前 20 条记忆:
curl "http://localhost:9091/cells/dept-legal/memory?layer=about_me&limit=20&offset=0" \
-H "Authorization: Bearer $TOKEN"
列出 agent_memory 层中指定命名空间的条目:
curl "http://localhost:9091/cells/dept-legal/memory?layer=agent_memory&namespace=agent-coder&limit=50" \
-H "Authorization: Bearer $TOKEN"
响应
成功(200 OK)
[
{
"id": "mem-abc123",
"layer": "about_me",
"kind": "preference",
"content": "我喜欢使用 Vim 键位的编辑器",
"namespace": "",
"actor": "alice",
"created_at": "2026-09-20T10:30:00Z",
"accessed_at": "2026-09-21T08:15:00Z"
},
{
"id": "mem-def456",
"layer": "about_me",
"kind": "fact",
"content": "我负责法务合同审查工作",
"namespace": "",
"actor": "alice",
"created_at": "2026-09-19T14:00:00Z",
"accessed_at": "2026-09-20T16:45:00Z"
}
]
条目字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 条目唯一 ID |
layer | string | 所属层 |
kind | string | 记忆类别 |
content | string | 记忆内容 |
namespace | string | 命名空间 |
actor | string | 归属 actor |
created_at | string | 创建时间(RFC 3339) |
accessed_at | string | 最近访问时间(RFC 3339) |
注意事项
layer过滤下推到引擎 SQL,在LIMIT之内执行,不在客户端过滤。页外过滤在少量数据时看不出差别,但共享分区一大,用户自己的行会被挤出窗口。layer与scope不可同时给出,否则返回ErrMemoryLayerScopeConflict(400)。- 不带
layer时返回当前 actor 可见的全部条目。 - 排序默认按
accessed_at DESC, created_at DESC, id。
错误码
| HTTP | 错误 | 说明 |
|---|---|---|
| 400 | ErrMemoryLayerScopeConflict | layer 和 scope 同时给出 |
| 400 | ErrUnknownLayer | 不认识的层名 |
| 401 | — | Token 缺失或无效 |
| 403 | — | Token 权限不足 |
相关端点
- POST /memory — 保存记忆
- POST /memory/search — 语义搜索
- GET /memory/counts — 层计数
- GET /memory/{id} — 获取单条