Skip to content

Conversation

@themavik
Copy link

@themavik themavik commented Feb 9, 2026

Summary

Fixes #3966.

Root cause: The update() method used {"$set": {"payload": payload}} which replaced the entire payload document. When updating memory content, all custom metadata fields (bucket_id, context_id, category, source, etc.) were completely lost.

Fix: Use dot notation in $set to merge individual fields: {"$set": {"payload.key1": val1, "payload.key2": val2}}. This preserves existing metadata keys that aren't being updated.

Changes

  • mem0/vector_stores/mongodb.py: Changed update() to use dot notation for payload field updates

Testing

  • Metadata fields preserved during content updates
  • Backward compatible — full payload updates still work
  • No impact on other vector store backends

…0ai#3966)

Root cause: The update() method used $set with the entire payload
object, which replaced all existing metadata fields. When updating
memory content, custom metadata like bucket_id, context_id, category
were completely lost.

Fix: Use dot notation (payload.key) in $set to merge individual
fields into the existing payload document, preserving unmodified
metadata keys.
@CLAassistant
Copy link

CLAassistant commented Feb 9, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MongoDB Implementation Bug: update replaces metadata entirely

2 participants