Update Memory

Updated at:

Modify the content of an existing memory node

Updates the content of a specified memory node. The API automatically detects the node type and formats the content.

Endpoint

PATCHhttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/memory_nodes/{memory_node_id}

Replace {WorkspaceId} with your actual workspace ID.

Path parameters

memory_node_idstringRequired

Memory node ID

Location: Path

Request body

custom_contentstringRequired

Updated memory content

Location: Body
memory_library_idstringOptional

Memory library ID

Location: Body
meta_dataobjectOptional

Metadata. The update is incremental, and unspecified keys remain unchanged

Location: Body
skill_namestringConditional

If the node is a skill, skill_name, skill_description, and skill_tags are all required

Location: Body
skill_descriptionstringConditional

Skill description. Required under the same conditions as skill_name

Location: Body
skill_tagsarray[string]Conditional

Skill tags. Required under the same conditions as skill_name

Location: Body

Response fields

request_idstring

Request ID

Request example

curl --location --request PATCH 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/memory_nodes/42dfc089dfa7409889966960a95c3b7e' \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "custom_content": "Updated memory content",
    "memory_library_id": "memory_library_001",
    "meta_data": {"location_name": "Hangzhou"}
  }'
from agentscope_runtime.tools.modelstudio_memory import UpdateMemory
import asyncio

async def main():
    update_memory = UpdateMemory()
    try:
        await update_memory.arun(
            memory_node_id="MEMORY_NODE_ID",
            user_id="user_001",
            custom_content="Also remind me to take my medicine at 10 AM."
        )
        print("Memory updated successfully")
    finally:
        await update_memory.close()

asyncio.run(main())

Response example

{
  "request_id": "cc2690f9f2b3485a93013e5705c91241"
}

ImportantTo delete a memory, use Delete Memory.