All Products
Search
Document Center

Tablestore:Short-term memory

Last Updated:Sep 24, 2026

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 messages has 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 scope must 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 200 status and an empty messages list are returned. This does not indicate an error.

  • Optional minTimestamp/maxTimestamp (RFC3339) filter by time range, limit controls the page size, and nextToken is used for pagination.

Console

  1. Log in to the Agent Storage console, open the target memory store, and go to the Short-term memory page.

  2. Select the specific application, tenant, and Agent, and then use the session selector in the upper-right corner to select a session.

  3. 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.

Related documents