-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Description
Description
The agent_id filter doesn't work in v2 API for get_all and search operations, even though the documentation states it should.
Documentation reference: https://docs.mem0.ai/platform/features/v2-memory-filters#missing-results-with-agent-id
Steps to Reproduce
from mem0 import AsyncMemoryClient
client = AsyncMemoryClient(api_key="...")
# 1. Add memory with agent_id
result = await client.add(
messages=[{"role": "user", "content": "Test memory"}],
user_id="test_user_123",
agent_id="test_agent_456",
run_id="test_run_789",
infer=False,
)
# ✅ Memory created successfully
# 2. Try to filter by agent_id
filters = {"AND": [{"user_id": "test_user_123"}, {"agent_id": "test_agent_456"}]}
results = await client.get_all(filters=filters)
# ❌ Returns 0 results
# 3. Try wildcard agent_id (per documentation)
filters = {"AND": [{"user_id": "test_user_123"}, {"agent_id": "*"}]}
results = await client.get_all(filters=filters)
# ❌ Returns 0 results
# 4. Filter by run_id works correctly
filters = {"AND": [{"user_id": "test_user_123"}, {"run_id": "test_run_789"}]}
results = await client.get_all(filters=filters)
# ✅ Returns 1 resultExpected Behavior
According to the documentation, filtering by agent_id should return memories that were added with that agent_id. The wildcard {"agent_id": "*"} should return all memories with non-null agent_id values.
Actual Behavior
agent_idfilter returns 0 results (both exact match and wildcard)run_idfilter works correctly- When retrieving the memory by ID, it shows
agent_idis stored in metadata but not as a filterable field
Memory Structure Returned
{
'id': '...',
'memory': 'Test memory',
'user_id': 'test_user_123',
'session_id': 'test_run_789', # run_id is mapped to session_id
'metadata': {
'agent_id': 'test_agent_456', # agent_id only in metadata
'run_id': 'test_run_789'
},
...
}Note: run_id is properly indexed as session_id, but agent_id appears to only be stored in metadata without indexing.
Environment
- mem0 SDK version: 0.1.98 (latest)
- Python version: 3.12
- API: Platform API (api.mem0.ai)
Questions
- Is
agent_idfiltering currently supported in v2 API? - If not, is this a planned feature?
- Should we use
run_idas the primary scope identifier instead?
Thank you!
Metadata
Metadata
Assignees
Labels
No labels