Improve DELETE operation definition and examples in memory prompt
Description
Improved the definition and examples of the DELETE operation in DEFAULT_UPDATE_MEMORY_PROMPT to make memory management more accurate.
While analyzing mem0's memory update mechanism, I noticed that DEFAULT_UPDATE_MEMORY_PROMPT (the tool call prompt in the update phase) guides the model to output an operation (ADD, UPDATE, DELETE, or NONE) for each retrieved old memory. However, there is a conceptual confusion in the DELETE operation example:
When a user changes from "Loves cheese pizza" to "Dislikes cheese pizza", the original example incorrectly categorizes this preference change as a DELETE operation:
{
"id" : "1",
"text" : "Loves cheese pizza",
"event" : "DELETE"
}
This approach is problematic because "Dislikes cheese pizza" provides new information indicating a change in user preference, rather than just removing old information. In this case, the more appropriate operation should be UPDATE, which preserves the history of the user's preference change.
My modification clearly distinguishes between the appropriate scenarios for DELETE and UPDATE operations:
-
DELETE should only be used when information becomes completely invalid (such as canceled plans)
-
UPDATE should be used for preference or status changes (such as from "likes" to "dislikes")
I've added clearer examples demonstrating the correct handling of these two different situations, enabling the model to make more accurate decisions.
These improvements will help the model manage memories more accurately, preserving a more complete history of information, especially when tracking changes in user preferences.
Type of change
-
[x] Bug fix (non-breaking change which fixes an issue)
-
[ ] New feature (non-breaking change which adds functionality)
-
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
-
[ ] Refactor (does not change functionality, e.g. code style improvements, linting)
-
[x] Documentation update
How Has This Been Tested?
Manually checked the modified prompt text to ensure correct grammar and logic. Confirmed that the modifications only involve prompt content and examples, without affecting code structure or output format.
Attempted to run the test suite but encountered multiple missing dependency issues. Since I only modified the prompt wording and not the code logic, these test dependency issues should not affect the validity of my changes.
Checklist:
-
[x] My code follows the style guidelines of this project
-
[x] I have performed a self-review of my own code
-
[x] I have commented my code, particularly in hard-to-understand areas
-
[x] I have made corresponding changes to the documentation
-
[x] My changes generate no new warnings
-
[ ] I have added tests that prove my fix is effective or that my feature works
-
[ ] New and existing unit tests pass locally with my changes
-
[x] Any dependent changes have been merged and published in downstream modules
-
[x] I have checked my code and corrected any misspellings
Maintainer Checklist
-
[ ] closes # (no specific issue number)
-
[ ] Made sure Checks passed
While you wait on this PR, you may configure mem0/Memory with a custom_update_memory_prompt.
config: MemoryConfig = {
"vector_store": { ... },
"custom_update_memory_prompt": "< your custom prompt >"
}
memory = Memory.from_config(config)
@johnwlockwood Thanks for the tip!