Skip to content

Conversation

@giles17
Copy link
Contributor

@giles17 giles17 commented Dec 10, 2025

Motivation and Context

Updates Mem0Provider to use the filters parameter as required by mem0 v2 search API.

  • Added _build_filters() method to construct filters dict from initialization parameters
  • Updated invoking() to pass filters dict to mem0_client.search() instead of individual parameters
  • Updated existing tests to verify filters dict parameter instead of individual params
  • Added 12-second delay in mem0_basic sample to give time for memories to be indexed

Resolves #2621

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings December 10, 2025 22:48
@github-actions github-actions bot changed the title Update Mem0Provider to use v2 search API filters parameter Python: Update Mem0Provider to use v2 search API filters parameter Dec 10, 2025
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Dec 10, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/mem0/agent_framework_mem0
   _provider.py83396%164–165, 168
TOTAL16508257184% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2361 130 💤 0 ❌ 0 🔥 56.377s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Mem0Provider to use the v2 search API's filters parameter instead of individual parameters. The change aligns with the mem0 library's updated API while maintaining backward compatibility for the add() method.

Key changes:

  • Added _build_filters() method to construct filters dict from initialization parameters
  • Updated invoking() method to pass filters dict to mem0_client.search()
  • Updated all test assertions to verify the new filters parameter structure

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
python/packages/mem0/agent_framework_mem0/_provider.py Added _build_filters() helper method and updated invoking() to use filters dict for search API; added documentation note about filter initialization
python/packages/mem0/tests/test_mem0_context_provider.py Updated test assertions to verify filters dict parameter instead of individual params; added new test class for _build_filters() method
python/samples/getting_started/context_providers/mem0/mem0_basic.py Added 12-second delay with explanatory comments to handle Mem0's asynchronous memory indexing

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, does this need a particular version of the mem0 dependency?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: mem0 basic example not working

4 participants