Manage memories

Updated at:

View, search, update, and delete memories

Use metadata (meta_data) to categorize memories for precise retrieval. See Memory observation for conversation-associated memory changes and Memory audit for changes triggered by extraction and manual operations.

View memory details

On a memory library card, click 查看详情 (view details) and open the 记忆详情 (memory details) tab. The top shows counts of factual memories, user profiles, skill memories, and memory entities. Below is an entity list with fuzzy search by entity ID (user_id). Click 查看 (view) to inspect the entity's factual memories, user profiles, and skill memories by rule. These instructions use labels from the Chinese-language console.

List memories via API (replace {WorkspaceId} with your actual workspace ID; for the Python SDK endpoint setting, see Overview):

curl -X GET "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/memory_nodes?user_id=user_001&page_size=10&page_num=1" \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header "Content-Type: application/json"
from agentscope_runtime.tools.modelstudio_memory import (
    ListMemory, ListMemoryInput,
)
import asyncio

async def list_memory_example():
    list_memory = ListMemory()
    try:
        result = await list_memory.arun(ListMemoryInput(
            user_id="user_001", page_size=10, page_num=1
        ))
        for node in result.memory_nodes:
            print(f"Memory {node.memory_node_id}: {node.content}")
    finally:
        await list_memory.close()

asyncio.run(list_memory_example())

Search debugging

In the memory details page's Memory search tab, debug retrieval to optimize recall accuracy.

ParameterDescriptionRecommendation
Entity IDThe user_id used when writing—
Factual memory ruleSelect a specific rule to search—
Max resultsNumber of memories returned (1~100)As needed
Intent recallSystem judges if recall is needed, avoiding irrelevant searchesOn
RewriteOptimizes the query for better semantic searchOn for casual phrasing
RerankReranks results for relevanceOn for high relevance
Similarity threshold0.0~1.0, filters low-relevance results0.5~0.7

NoteRerank currently supports only the gte-rerank-v2 model. Too high a threshold may miss relevant memories; too low may introduce noise.

Search via API:

curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/memory_nodes/search \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "user_id": "user_001",
    "messages": [{"role": "user", "content": "What do I need to do?"}],
    "top_k": 10,
    "min_score": 0.3,
    "plan_version": "pro"
  }'
from agentscope_runtime.tools.modelstudio_memory import (
    SearchMemory, SearchMemoryInput, Message,
)
import asyncio

async def search_memory_example():
    search_memory = SearchMemory()
    try:
        result = await search_memory.arun(SearchMemoryInput(
            user_id="user_001",
            messages=[Message(role="user", content="What do I need to do?")],
            top_k=10,
            min_score=0.6
        ))
        for node in result.memory_nodes:
            print(f"Memory: {node.content}")
    finally:
        await search_memory.close()

asyncio.run(search_memory_example())

Update and delete memories

Edit a factual memory

  1. In the library's 记忆详情 (memory details) tab, find an entity and click 查看 (view).
  2. Under 事实记忆规则 (factual memory rules), select the corresponding rule. Find the memory card and click its details icon to open 事实记忆详情 (factual memory details).
  3. Click 编辑 (edit), change the content, and click 保存 (save) or 保存并关闭弹窗 (save and close).

After saving, confirm the new content in memory details. To compare the content before and after editing, inspect the update snapshot in Memory audit.

Disable and enable a factual memory

Turn off the enabled switch in 事实记忆详情 (factual memory details). The memory displays 未启用 (not enabled). Turn it back on to display 已启用 (enabled). Audit records these operations as 软删除 (soft deletion) and 恢复 (restoration), respectively.

Delete a factual memory

WarningA memory cannot be recovered after deletion is confirmed. To disable it temporarily, use the enabled switch instead of deleting it.

Click the delete icon on the target memory card, then click 删除 (delete) in the confirmation dialog. After deletion succeeds, check the memory list. In Memory audit, you can query the deletion record and the content before deletion.

Update and delete through the API

# Update memory
curl -X PATCH "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/memory_nodes/{memory_node_id}" \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "custom_content": "Also remind me to take medicine at 10 AM."
  }'

# Delete memory
curl -X DELETE "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/memory_nodes/{memory_node_id}" \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header "Content-Type: application/json"
from agentscope_runtime.tools.modelstudio_memory import (
    ListMemory, ListMemoryInput,
    DeleteMemory, DeleteMemoryInput,
)
import asyncio

async def manage_memory_example():
    list_memory = ListMemory()
    delete_memory = DeleteMemory()
    try:
        # List memories
        result = await list_memory.arun(ListMemoryInput(
            user_id="user_001", page_size=10, page_num=1
        ))
        for node in result.memory_nodes:
            print(f"Memory {node.memory_node_id}: {node.content}")

        # Delete memory
        await delete_memory.arun(DeleteMemoryInput(
            user_id="user_001",
            memory_node_id="MEMORY_NODE_ID"
        ))
    finally:
        await list_memory.close()
        await delete_memory.close()

asyncio.run(manage_memory_example())

ImportantFor parameter details see API reference. For billing and limits see Billing & limits.