Use the ListMemories interface to list long-term memories.
Prerequisites
-
An AgentStorage instance has been created and its status is
normal, and the instance endpoint and instance name have been obtained. -
An API Key has been created.
-
Scope rules: You can use the wildcard
*at any level (left-prefix rule: fields after*must also be*or empty); empty fields are treated as__default__. We recommend that you provide at leastappId.
Request parameters
|
Field |
Type |
Required |
Description |
|
|
string |
Yes |
The name of the memory store. |
|
|
object |
No |
The scope. You can use the wildcard |
|
|
object |
No |
Scope Filter. Combined with |
|
|
int |
No |
The number of entries to return. Default: 50. Maximum: 100. |
|
|
string |
No |
The pagination token for the next page. It can only be used with the same |
Request examples
When you use API Key authentication, pass the instance name and API Key through the x-ots-instancename and x-ots-apikey request headers.
curl -X POST https://<endpoint>/ListMemories \
-H "x-ots-instancename: <instance-name>" \
-H "x-ots-apikey: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "*",
"agentId": "*",
"runId": "*"
},
"limit": 20
}'
Use a filter to list memories across multiple conversations:
{
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "user-001",
"agentId": "*",
"runId": "*"
},
"filter": {
"op": "eq",
"field": "text",
"value": "*sess*"
},
"limit": 20
}
Response
|
Field |
Description |
|
|
The list of long-term memory units. The unit fields are the same as |
|
|
The pagination token for the next page. Omitted when there is no more data. |
|
|
The scope used for the query. |
|
|
The name of the memory store. |
{
"memories": [
{
"id": "3a8d77658e7e92522f2f3ebefb16290e",
"text": "用户常驻杭州。",
"scope": { "appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "session-002" },
"unit_type": "atomic_fact",
"created_at": "2026-09-20T03:28:50Z"
}
],
"memoryStoreName": "agent_memory",
"scope": { "appId": "app-001", "tenantId": "*", "agentId": "*", "runId": "*" }
}
When filter is used, the results are grouped by scope. Scope groups are sorted in ascending order by the scopeKey generated by the service. Within the same scope, memories are sorted by creation time from newest to oldest; when creation times are equal, they are sorted by memory ID in descending order. A single request scans at most 100 scopes, so the number of returned entries may be less than limit or even empty, but a nextToken may still be returned. The caller should keep paginating until nextToken is empty.
When the scope query capability is temporarily unavailable, the interface returns HTTP 503 and SERVICE_UNAVAILABLE. An invalid, expired, or mixed nextToken used with other query conditions returns HTTP 400 and INVALID_PARAMETER.