Skip to main content
The custom update memory prompt tells Mem0 how to handle changes when new facts arrive. Craft the prompt so the LLM can compare incoming facts with existing memories and choose the right action.
You’ll use this when…
  • Stored memories need to stay consistent as users change preferences or correct past statements.
  • Your product has clear rules for when to add, update, delete, or leave a memory untouched.
  • You want traceable decisions (ADD, UPDATE, DELETE, NONE) for auditing or compliance.
Prompts that mix instructions or omit examples can lead to wrong actions like deleting valid memories. Keep the language simple and test each action path.

Feature anatomy

  • Action verbs: The prompt teaches the model to return ADD, UPDATE, DELETE, or NONE for every memory entry.
  • ID retention: Updates reuse the original memory ID so downstream systems maintain history.
  • Old vs. new text: Updates include old_memory so you can track what changed.
  • Decision table: Your prompt should explain when to use each action and show concrete examples.
ActionWhen to choose itOutput details
ADDFact is new and not stored yetGenerate a new ID and set event: "ADD".
UPDATEFact replaces older info about the same topicKeep the original ID, include old_memory.
DELETEFact contradicts the stored memory or you explicitly remove itKeep ID, set event: "DELETE".
NONEFact matches existing memory or is irrelevantKeep ID with event: "NONE".

Configure it

Author the prompt

UPDATE_MEMORY_PROMPT = """You are a smart memory manager which controls the memory of a system.
You can perform four operations: (1) add into the memory, (2) update the memory, (3) delete from the memory, and (4) no change.

Based on the above four operations, the memory will change.

Compare newly retrieved facts with the existing memory. For each new fact, decide whether to:
- ADD: Add it to the memory as a new element
- UPDATE: Update an existing memory element
- DELETE: Delete an existing memory element
- NONE: Make no change (if the fact is already present or irrelevant)

There are specific guidelines to select which operation to perform:

1. **Add**: If the retrieved facts contain new information not present in the memory, then you have to add it by generating a new ID in the id field.
- **Example**:
    - Old Memory:
        [
            {
                "id" : "0",
                "text" : "User is a software engineer"
            }
        ]
    - Retrieved facts: ["Name is John"]
    - New Memory:
        {
            "memory" : [
                {
                    "id" : "0",
                    "text" : "User is a software engineer",
                    "event" : "NONE"
                },
                {
                    "id" : "1",
                    "text" : "Name is John",
                    "event" : "ADD"
                }
            ]

        }

2. **Update**: If the retrieved facts contain information that is already present in the memory but the information is totally different, then you have to update it. 
If the retrieved fact contains information that conveys the same thing as the elements present in the memory, then you have to keep the fact which has the most information. 
Example (a) -- if the memory contains "User likes to play cricket" and the retrieved fact is "Loves to play cricket with friends", then update the memory with the retrieved facts.
Example (b) -- if the memory contains "Likes cheese pizza" and the retrieved fact is "Loves cheese pizza", then you do not need to update it because they convey the same information.
If the direction is to update the memory, then you have to update it.
Please keep in mind while updating you have to keep the same ID.
Please note to return the IDs in the output from the input IDs only and do not generate any new ID.
- **Example**:
    - Old Memory:
        [
            {
                "id" : "0",
                "text" : "I really like cheese pizza"
            },
            {
                "id" : "1",
                "text" : "User is a software engineer"
            },
            {
                "id" : "2",
                "text" : "User likes to play cricket"
            }
        ]
    - Retrieved facts: ["Loves chicken pizza", "Loves to play cricket with friends"]
    - New Memory:
        {
        "memory" : [
                {
                    "id" : "0",
                    "text" : "Loves cheese and chicken pizza",
                    "event" : "UPDATE",
                    "old_memory" : "I really like cheese pizza"
                },
                {
                    "id" : "1",
                    "text" : "User is a software engineer",
                    "event" : "NONE"
                },
                {
                    "id" : "2",
                    "text" : "Loves to play cricket with friends",
                    "event" : "UPDATE",
                    "old_memory" : "User likes to play cricket"
                }
            ]
        }


3. **Delete**: If the retrieved facts contain information that contradicts the information present in the memory, then you have to delete it. Or if the direction is to delete the memory, then you have to delete it.
Please note to return the IDs in the output from the input IDs only and do not generate any new ID.
- **Example**:
    - Old Memory:
        [
            {
                "id" : "0",
                "text" : "Name is John"
            },
            {
                "id" : "1",
                "text" : "Loves cheese pizza"
            }
        ]
    - Retrieved facts: ["Dislikes cheese pizza"]
    - New Memory:
        {
        "memory" : [
                {
                    "id" : "0",
                    "text" : "Name is John",
                    "event" : "NONE"
                },
                {
                    "id" : "1",
                    "text" : "Loves cheese pizza",
                    "event" : "DELETE"
                }
        ]
        }

4. **No Change**: If the retrieved facts contain information that is already present in the memory, then you do not need to make any changes.
- **Example**:
    - Old Memory:
        [
            {
                "id" : "0",
                "text" : "Name is John"
            },
            {
                "id" : "1",
                "text" : "Loves cheese pizza"
            }
        ]
    - Retrieved facts: ["Name is John"]
    - New Memory:
        {
        "memory" : [
                {
                    "id" : "0",
                    "text" : "Name is John",
                    "event" : "NONE"
                },
                {
                    "id" : "1",
                    "text" : "Loves cheese pizza",
                    "event" : "NONE"
                }
            ]
        }
"""

Define the expected output format

{
  "memory": [
    {
      "id": "0",
      "text": "This information is new",
      "event": "ADD"
    }
  ]
}
Consistent JSON structure makes it easy to parse decisions downstream or log them for auditing.

See it in action

  • Run reconciliation jobs that compare retrieved facts to existing memories.
  • Feed both sources into the custom prompt, then apply the returned actions (add new entries, update text, delete outdated facts).
  • Log each decision so product teams can review why a change happened.
The prompt works alongside custom_fact_extraction_prompt—fact extraction identifies candidate facts, and the update prompt decides how to merge them into long-term storage.

Verify the feature is working

  • Test all four actions with targeted examples, including edge cases where facts differ only slightly.
  • Confirm update responses keep the original IDs and include old_memory.
  • Ensure delete actions only trigger when contradictions appear or when you explicitly request removal.

Best practices

  1. Keep instructions brief: Remove redundant wording so the LLM focuses on the decision logic.
  2. Document your schema: Share the prompt and examples with your team so everyone knows how memories evolve.
  3. Track prompt versions: When rules change, bump a version number and archive the prior prompt.
  4. Review outputs regularly: Skim audit logs weekly to spot drift or repeated mistakes.
  5. Pair with monitoring: Visualize counts of each action to detect spikes in deletes or updates.

Compare prompts

Featurecustom_update_memory_promptcustom_fact_extraction_prompt
Primary jobDecide memory actions (ADD/UPDATE/DELETE/NONE)Pull facts from user and assistant messages
InputsRetrieved facts + existing memory entriesRaw conversation turns
OutputStructured memory array with eventsArray of extracted facts