Mem0 Support for filters in V2 Search API#2725
Closed
giles17 wants to merge 4 commits intomicrosoft:mainfrom
Closed
Mem0 Support for filters in V2 Search API#2725giles17 wants to merge 4 commits intomicrosoft:mainfrom
filters in V2 Search API#2725giles17 wants to merge 4 commits intomicrosoft:mainfrom
Conversation
filters in V2 Search API
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for the Mem0 search v2 API's filter parameter, transitioning from passing individual filter parameters (user_id, agent_id, run_id) to a unified filters dictionary. This enables more advanced filtering capabilities including logical operators, date ranges, and complex queries.
Key Changes:
- Modified the
invoking()method to accept an optionalfilterskwarg and use a centralized_build_filters()method - Updated all tests to verify the new filters dictionary format instead of individual parameters
- Added a 12-second delay in the sample to accommodate Mem0's asynchronous memory processing
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| python/packages/mem0/agent_framework_mem0/_provider.py | Implemented _build_filters() method to consolidate init parameters into a filters dict and merge with optional invocation filters; updated invoking() to pass filters dict to mem0 search API |
| python/packages/mem0/tests/test_mem0_context_provider.py | Updated existing tests to verify filters dict format; added comprehensive test coverage for _build_filters() method with various scenarios including merging, overriding, and exclusion of None values |
| python/samples/getting_started/context_providers/mem0/mem0_basic.py | Added 12-second sleep between memory storage and retrieval to handle Mem0's asynchronous processing |
python/samples/getting_started/context_providers/mem0/mem0_basic.py
Outdated
Show resolved
Hide resolved
dmytrostruk
approved these changes
Dec 9, 2025
Comment on lines
+60
to
+61
| For advanced filtering (OR logic, date ranges, comparisons, etc.), pass a `filters` | ||
| parameter to the `invoking()` through `agent.run()` method. |
Member
There was a problem hiding this comment.
Would it be possible to add an example how it looks like from user perspective?
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.
Motivation and Context
This PR updates the
Mem0Providerto support dynamic, per-invocation filters that align with the mem0 v2 API design. The change enables flexible memory filtering at query time while maintaining backward compatibility.In
_provider.py:invoking()method to acceptfiltersvia**kwargsand pass to mem0 search API_build_filters()method to build filter dictionaries from:(user_id, agent_id, thread_id, application_id)as base scopefiltersdictIn
mem0_basic.py:Description
Contribution Checklist