Skip to content

fix: update parameter added to the update function which is exposed t…#3799

Merged
whysosaket merged 4 commits intomem0ai:mainfrom
zaiddkhan:fix/metadata-param-update-function
Mar 26, 2026
Merged

fix: update parameter added to the update function which is exposed t…#3799
whysosaket merged 4 commits intomem0ai:mainfrom
zaiddkhan:fix/metadata-param-update-function

Conversation

@zaiddkhan
Copy link
Copy Markdown

@zaiddkhan zaiddkhan commented Dec 1, 2025

Description

Fixes #3795

Adds the metadata parameter to the public update() method in both Memory and AsyncMemory classes. The internal _update_memory() function already supported metadata updates, but this parameter was not exposed to the client-facing API. This change allows users to update memory metadata when updating memory content.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Automated Tests

6 new unit tests were added covering both sync and async update paths:

tests/test_main.py (sync Memory):

  • test_update — verifies None metadata is passed by default when not specified
  • test_update_with_metadata — verifies a metadata dict ({"category": "sports", "priority": "high"}) is forwarded to _update_memory
  • test_update_with_empty_metadata — verifies empty {} is passed through (not coerced to None)

tests/memory/test_main.py (async AsyncMemory):

  • test_async_update_without_metadata — same as sync, confirms None default
  • test_async_update_with_metadata — same as sync, confirms metadata forwarding
  • test_async_update_with_empty_metadata — same as sync, confirms empty dict passthrough

All 6 tests verify that the metadata argument is correctly forwarded from the public update() API to the internal _update_memory() method.

tests/test_main.py::test_update PASSED
tests/test_main.py::test_update_with_metadata PASSED
tests/test_main.py::test_update_with_empty_metadata PASSED
tests/memory/test_main.py::TestAsyncUpdate::test_async_update_without_metadata PASSED
tests/memory/test_main.py::TestAsyncUpdate::test_async_update_with_metadata PASSED
tests/memory/test_main.py::TestAsyncUpdate::test_async_update_with_empty_metadata PASSED

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • 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

Maintainer Checklist

…o the client, with all the relevant doc strings updated
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 1, 2025

CLA assistant check
All committers have signed the CLA.

@alexviquez
Copy link
Copy Markdown

Hey, big +1 on this PR.

Currently hitting the Memory.update() got an unexpected keyword argument 'metadata' error in the OSS version. It's a blocker for updating memory states without resorting to a delete + add workaround, which kills the original ID.

Since the underlying _update_memory already supports it, exposing this in the public API would be a huge win. Thanks for this product mem0 team!

utkarsh240799 and others added 2 commits March 24, 2026 15:54
Verify that both sync Memory.update() and async AsyncMemory.update()
correctly forward the metadata parameter to _update_memory, including
None default, populated dict, and empty dict cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge origin/main into fix/metadata-param-update-function, combining
the new Mock import (for metadata update tests) with the datetime
imports and UTC timestamp tests added on main.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
utkarsh240799
utkarsh240799 previously approved these changes Mar 24, 2026
Remove unused `asyncio` import and unused `result` variable assignments
flagged by ruff linter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@whysosaket whysosaket merged commit 5edc0cc into mem0ai:main Mar 26, 2026
12 of 22 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.

No metadata parameter in memory update method

5 participants