Retrieve API
POST /v1/users/:user_id/streams/:stream_id/retrieve
对某个用户和 stream 执行混合检索。
这个路由用来做什么
这是运行时最主要的 recall 接口。它不会只走一条检索路径,而是把多种信号融合起来。
可能参与的信号包括:
- 语义相似度
- 文本检索
- 图谱扩展
- 时间过滤
- 组织知识
- 多模态查询输入
请求
POST /v1/users/dylan/streams/11111111-1111-1111-1111-111111111111/retrieve
Authorization: Bearer <token>
Content-Type: application/json
{
"org_id": "default",
"agent_id": "coding-assistant",
"query": "What does Dylan prefer for systems work?",
"limit": 10,
"enable_arbitration": false,
"min_score": 0.2,
"graph_depth": 1,
"start_time": "2026-03-01T00:00:00Z",
"end_time": "2026-03-31T23:59:59Z",
"as_of": "2026-03-25T12:00:00Z"
}
请求字段
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
query | string | 是 | 检索查询文本 |
limit | number | 否 | 最大返回条数,服务端会限制上限 |
enable_arbitration | boolean | 否 | 是否开启仲裁式检索 |
min_score | number | 否 | 最低分数阈值 |
graph_depth | number | 否 | 图谱扩展深度 |
start_time | ISO8601 | 否 | 有效时间起点 |
end_time | ISO8601 | 否 | 有效时间终点 |
as_of | ISO8601 | 否 | 事务时间点查询 |
org_id | string | 否 | 是否带上组织共享知识 |
agent_id | string | 否 | 偏向某个 agent 的程序性记忆 |
image | string | 否 | Base64 图片,用于跨模态检索 |
audio | string | 否 | Base64 音频,用于跨模态检索 |
video | string | 否 | Base64 视频,用于跨模态检索 |
返回
{
"stream_id": "11111111-1111-1111-1111-111111111111",
"query": "What does Dylan prefer for systems work?",
"results": [
{
"unit": {
"id": "9db1d859-0a32-4c33-8b94-8cab9f8e0d16",
"memory_type": "Fact",
"content": "Dylan prefers Rust for systems work.",
"keywords": ["rust", "systems"],
"level": 1
},
"score": 0.94
}
],
"query_time_ms": 8
}
返回字段
| 字段 | 含义 |
|---|---|
stream_id | 本次检索使用的 stream |
query | 最终被嵌入和检索的文本查询 |
results[].unit | 命中的记忆单元视图 |
results[].score | 融合后的最终排序分数 |
query_time_ms | 服务端观测到的检索耗时 |
实践说明
- 即使是多模态检索,
query文本也仍然是必填。 - 提供
org_id后,结果集可以包含组织级共享知识。 graph_depth允许检索从直接命中扩展到图谱邻接上下文。- 当你想偏向某个 agent 的程序性记忆时,
agent_id很有用。