fix: preserve original actor_id during memory update#4570
Merged
kartik-mem0 merged 1 commit intomainfrom Mar 27, 2026
Merged
Conversation
utkarsh240799
approved these changes
Mar 27, 2026
This was referenced Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Closes #4490
Description
actor_id metadata gets overwritten during memory UPDATE operations when a different actor triggers the update. The preservation condition "actor_id" not in new_metadata in _update_memory() never
triggers because new_metadata always contains the caller's actor_id (passed through from _build_filters_and_metadata() via deepcopy(metadata)).
This breaks actor-level memory isolation in multi-actor scenarios (shared user_id with per-actor actor_id). After a different actor triggers an UPDATE, querying by the original creator's actor_id
returns empty results.
Fix: Remove the "actor_id" not in new_metadata guard so actor_id is always preserved from the existing memory. This treats actor_id as memory ownership rather than last-updater. The history table
already tracks all contributors via db.add_history().
Applied to both sync and async _update_memory() code paths.
Type of Change
Breaking Changes
N/A
Test Coverage
Added two tests covering both sync and async paths: test_update_preserves_actor_id_when_different_actor_updates and test_async_update_preserves_actor_id_when_different_actor_updates. All 36 tests
pass locally.
Checklist