Manage short-term messages (raw session messages) in the memory store. Short-term messages are generated by Structured memory (AddMemories). This page covers querying only.
Prerequisites
-
A memory store with the input type
messageshas been created. See Memory store management. -
Agent Storage SDK installed: Python ≥
1.0.10, TypeScript ≥0.0.13
List short-term messages
Query raw session message records under a specified scope with pagination.
-
The
scopemust include all four levels and does not support wildcards. Otherwise, no matching session can be found. -
If the memory store exists but no messages exist for the scope, a
200status and an emptymessageslist are returned. This does not indicate an error. -
Optional
minTimestamp/maxTimestamp(RFC3339) filter by time range,limitcontrols the page size, andnextTokenis used for pagination.
Console
-
Log in to the Agent Storage console, open the target memory store, and go to the Short-term memory page.
-
Select the specific application, tenant, and Agent, and then use the session selector in the upper-right corner to select a session.
-
The list displays the raw conversation messages (role, content, and time) of the session.
SDK
Python
from tablestore_agent_storage import AgentStorageClient
client = AgentStorageClient(
api_key="<your-api-key>",
ots_endpoint="https://<instance>.<region>.ots.aliyuncs.com",
ots_instance_name="<instance-name>",
)
resp = client.list_memory_store_messages({
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "user-001",
"agentId": "assistant",
"runId": "session-001",
},
"limit": 50,
})
session = resp.get("session", resp)
for msg in session.get("messages", []):
print(f"[{msg['role']}] {msg['content']}")
TypeScript
import { AgentStorageClient } from '@tablestore/agent-storage';
const client = new AgentStorageClient({
apiKey: '<your-api-key>',
endpoint: 'https://<instance>.<region>.ots.aliyuncs.com',
instanceName: '<instance-name>',
});
const resp = await client.listMemoryStoreMessages({
memoryStoreName: 'agent_memory',
scope: {
appId: 'app-001',
tenantId: 'user-001',
agentId: 'assistant',
runId: 'session-001',
},
limit: 50,
});
const session = resp.session ?? resp;
for (const msg of session.messages) {
console.log(`[${msg.role}] ${msg.content}`);
}
API
Call ListMemoryStoreMessages to list short-term messages. For the full field description, see List short-term messages.