Skip to content

fix: preserve original actor_id during memory update#4570

Merged
kartik-mem0 merged 1 commit intomainfrom
fix/actor-id-overwrite-on-update
Mar 27, 2026
Merged

fix: preserve original actor_id during memory update#4570
kartik-mem0 merged 1 commit intomainfrom
fix/actor-id-overwrite-on-update

Conversation

@kartik-mem0
Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (no functional changes)
  • Documentation update

Breaking Changes

N/A

Test Coverage

  • I added/updated unit tests
  • I added/updated integration tests
  • I tested manually (describe below)
  • No tests needed (explain why)

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

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix/feature works
  • New and existing tests pass locally
  • I have updated documentation if needed

@kartik-mem0 kartik-mem0 merged commit c2698f2 into main Mar 27, 2026
8 checks passed
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.

Bug Report: actor_id metadata gets overwritten during memory UPDATE operations

2 participants