Use the ListMemoryStoreMessages interface to query short-term memory, which consists of original session messages.
Prerequisites
-
An AgentStorage instance has been created and is in the
normalstate. Obtain the instance endpoint and instance name. -
An API Key has been created.
-
Scope rule: Querying short-term memory requires a complete Scope. All four fields (
appId,tenantId,agentId,runId) are required, and wildcards (*) are not allowed.
Request parameters
|
Field |
Type |
Required |
Description |
|
|
string |
Yes |
The name of the memory store. |
|
|
object |
Yes |
The complete Scope. All four fields are required, and wildcards ( |
|
|
int |
No |
The number of results to return. |
|
|
string |
No |
The pagination token for the next page. |
|
|
string |
No |
The minimum timestamp in RFC3339 format. |
|
|
string |
No |
The maximum timestamp in RFC3339 format. |
Request example
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>/ListMemoryStoreMessages \
-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": "user-001",
"agentId": "assistant",
"runId": "session-001"
},
"limit": 100
}'
Response
|
Field |
Description |
|
|
The session message wrapper object. |
|
|
The queried Scope. |
|
|
The message list. |
|
|
The message ID. |
|
|
The message role. |
|
|
The speaker identifier. |
|
|
The message content. |
|
|
The message timestamp in RFC3339 format. |
|
|
The message metadata. |
{
"session": {
"scope": { "appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "session-001" },
"messages": [
{
"messageId": "d0d9dd778a27e8cde773a243a5bab13c",
"role": "user",
"speaker": "user",
"content": "[10:00 AM on 13 May, 2026] 我以后出差都优先订靠窗座位",
"timestamp": "2026-05-13T10:00:00Z",
"metadata": { "channel": "chat", "source": "chat" }
}
]
}
}
When the memory store exists but no messages are found for the specified Scope, 200 is returned with an empty messages list.