Manage memory stores in the Memory Storage Service, including creating, querying, listing, updating, and deleting operations.
Prerequisites
You have created an AgentStorage instance and obtained the endpoint and instance name.
The Agent Storage SDK is installed: Python ≥
1.0.10, TypeScript ≥0.0.13
Create a memory store
A memory store is the top-level container for memory data. When you create one, you specify the input type (where the data comes from) and the output type (what form the memory is stored in).
Setting | Description |
Name | Letters, digits, and underscores, up to 32 characters. Must be unique within the same instance. |
Description | Describes the purpose of the memory store, up to 1024 characters. |
Input type |
|
Output type |
|
Extract instructions | Guide structured memory extraction, up to 4096 characters. |
The input type and output type must be compatible: messages input can be paired with ["structured"], ["file"], or ["structured","file"]; file input can only be paired with ["file"]. If no type is specified, the default is messages input + structured output.
Console
Log on to the Agent Storage console, go to Memory store management, and click Create memory store.
Enter a name (must start with a letter and contain only letters, digits, and underscores, up to 32 characters) and a description.
Select the input type: short-term messages or file.
Select the output type: structured memory, file memory, or both.
Optionally enter extract instructions (to guide structured memory extraction).
Click OK to create the memory store.
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>",
)
# Create a memory store: messages input, structured + file output
client.create_memory_store({
"memoryStoreName": "agent_memory",
"description": "Agent long-term memory store",
"inputType": "messages",
"outputTypes": ["structured", "file"],
"extractInstructions": "Focus on user dietary preferences and travel habits",
})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>',
});
await client.createMemoryStore({
memoryStoreName: 'agent_memory',
description: 'Agent long-term memory store',
inputType: 'messages',
outputTypes: ['structured', 'file'],
extractInstructions: 'Focus on user dietary preferences and travel habits',
});API
Call CreateMemoryStore to create a memory store. For the complete request fields and response details, see Create a memory store.
Query memory store details
Query the complete configuration of a specified memory store, including the name, description, input/output type, and extract instructions.
Console
On the Memory store management page, click the target memory store card to view its details, or access basic information (name, storage mode, creation time, description, extract instructions) via ··· > Details/Settings in the upper-right corner of the card.
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.get_memory_store({"memoryStoreName": "agent_memory"})
data = resp["data"] if "data" in resp else resp
print(f"Name: {data.get('memoryStoreName')}")
print(f"Input type: {data.get('inputType')}, Output type: {data.get('outputTypes')}")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.getMemoryStore({ memoryStoreName: 'agent_memory' });
const data = resp.data ?? resp;
console.log(data.memoryStoreName, data.inputType, data.outputTypes);API
Call GetMemoryStore to query memory store details. For the complete fields, see Query a memory store.
List memory stores
Paginate through all memory stores under the current instance.
Console
On the Memory store management page, you can directly view the list of all memory stores, including the name, storage mode, and creation time.
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_stores({})
stores = resp.get("stores", [])
for s in stores:
print(f"{s['memoryStoreName']} | Input:{s.get('inputType')} Output:{s.get('outputTypes')}")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.listMemoryStores({});
for (const s of resp.stores) {
console.log(s.memoryStoreName, s.inputType, s.outputTypes);
}API
Call ListMemoryStores to list memory stores. For the complete fields, see List memory stores.
Update a memory store
Update the description, extract instructions, or output type of a memory store.
outputTypesuses replacement-based updates. The value passed in fully replaces the existing set of output types.inputTypecannot be modified. An empty string can cleardescriptionandextractInstructions.
Console
Go to the Settings of the target memory store, click Modify, and update the description, extract instructions, or output type.
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>",
)
client.update_memory_store({
"memoryStoreName": "agent_memory",
"description": "Updated description",
"extractInstructions": "Focus on user preferences and travel habits",
"outputTypes": ["structured", "file"],
})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>',
});
await client.updateMemoryStore({
memoryStoreName: 'agent_memory',
description: 'Updated description',
extractInstructions: 'Focus on user preferences and travel habits',
outputTypes: ['structured', 'file'],
});API
Call UpdateMemoryStore to update a memory store. For the complete fields, see Update a memory store.
Delete a memory store
This operation is irreversible. Deleting a memory store also deletes all memory and file data under it.
Console
In the upper-right corner of the memory store card, click and confirm as prompted. Deletion clears all data in the memory store.
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>",
)
client.delete_memory_store({"memoryStoreName": "agent_memory"})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>',
});
await client.deleteMemoryStore({ memoryStoreName: 'agent_memory' });API
Call DeleteMemoryStore to delete a memory store. For the complete fields, see Delete a memory store.