使用 GetMemory 接口获取单条长期记忆。
前提条件
-
已创建 AgentStorage 实例且状态为
normal,并获取实例访问地址(endpoint)和实例名。 -
已创建 API Key。
-
Scope 规则:
scope为可选字段,提供时 4 个字段(appId、tenantId、agentId、runId)全部必填,不允许使用通配符*。
请求参数
|
字段 |
类型 |
必填 |
说明 |
|
|
string |
是 |
记忆库名称。 |
|
|
string |
是 |
记忆 ID。 |
|
|
object |
否 |
可选的完整 Scope,用于校验记忆归属;提供时 4 个字段全部必填,不允许使用通配符 |
请求示例
使用 API Key 认证时,通过 x-ots-instancename 和 x-ots-apikey 请求头传入实例名和 API Key。
curl -X POST https://<endpoint>/GetMemory \
-H "x-ots-instancename: <instance-name>" \
-H "x-ots-apikey: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{"memoryStoreName":"agent_memory","memoryId":"<memory-id>","scope":{"appId":"app-001","tenantId":"user-001","agentId":"assistant","runId":"session-001"}}'
响应
|
字段 |
说明 |
|
|
记忆库名称。 |
|
|
查询到的长期记忆单元。字段定义与《检索记忆》(SearchMemories)响应的 |
{
"memoryStoreName": "agent_memory",
"memory": {
"id": "1b88d0d65a5b6c0d9142e9b7c7347048",
"conversation_key": "app-001/user-001/assistant/session-001",
"scope": { "appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "session-001" },
"unit_type": "entity_fact",
"text": "[2026-08-25T05:52:19Z] 我写脚本只用 Python。",
"keywords": ["Python", "脚本", "编程语言", "偏好"],
"title": "用户编程语言偏好",
"version": 1,
"salience": 0.8,
"effective_at": "2026-08-25T05:52:19Z",
"time_precision": "second",
"created_at": "2026-08-25T05:52:19.185Z",
"updated_at": "2026-08-25T05:52:30.509Z"
}
}
该文章对您有帮助吗?