Skip to main content
The update method replaces the content of a stored memory record. Use it to correct a fact, refine a preference, or reflect a change in user context.

Method signature

cog.update(
    memory_id: str,
    content: str,
    owner_id: str | None = None,
) -> CognisMemoryRecord

Parameters

ParameterTypeRequiredDescription
memory_idstrYesThe ID of the memory record to update.
contentstrYesThe new content to replace the existing memory.
owner_idstrNoOwner identifier for additional scoping.

Response

Returns the updated CognisMemoryRecord.
FieldTypeDescription
idstrMemory record ID.
contentstrThe updated memory content.
versionint | NoneIncremented version number.
is_currentbool | NoneAlways true for the updated record.
updated_atstr | NoneTimestamp of the update.

Basic usage

from lyzr import Cognis

cog = Cognis(api_key="sk-your-api-key")

updated = cog.update(
    memory_id="mem_abc123",
    content="Alice is now based in London.",
    owner_id="user_alice",
)
print(updated.content)
# "Alice is now based in London."

Async usage

import asyncio
from lyzr import Cognis

async def main():
    async with Cognis(api_key="sk-your-api-key") as cog:
        updated = await cog.aupdate(
            memory_id="mem_abc123",
            content="Alice prefers Python over JavaScript.",
        )
        print(updated.content)

asyncio.run(main())
To find the memory_id for a specific record, use Get Memories or Search Memories first, then pass the returned ID to update. Previous versions of the memory are retained and accessible via get() with include_historical=True.