Bug Report
Description
Mem0Provider.invoking() passes user_id, agent_id, and run_id inside a filters dict to mem0_client.search():
filters = self._build_filters()
search_response = await self.mem0_client.search(
query=input_text,
filters=filters,
)
This works with the Mem0 Platform client (AsyncMemoryClient), but fails with the Mem0 OSS client (AsyncMemory), which expects user_id, agent_id, and run_id as direct keyword arguments:
# Mem0 OSS AsyncMemory.search() signature (mem0ai v1.0.3):
async def search(self, query, *, user_id=None, agent_id=None, run_id=None, ...)
Error
mem0.exceptions.ValidationError: At least one of 'user_id', 'agent_id', or 'run_id' must be provided.
Steps to Reproduce
- Create a
Mem0Provider with mem0_client=AsyncMemory() (OSS) and user_id="some_user"
- Attach it to a
ChatAgent via context_provider=
- Call
agent.run("any message")
- The
invoking() hook calls search(query=..., filters={"user_id": "some_user"}) which fails
Expected Behavior
Mem0Provider should work with both AsyncMemoryClient (Platform) and AsyncMemory (OSS). The search call should detect the client type and pass scoping parameters appropriately.
Suggested Fix
In _provider.py, invoking() should unpack the filters as keyword args when using AsyncMemory (OSS):
search_kwargs = {"query": input_text}
if isinstance(self.mem0_client, AsyncMemory):
# OSS client expects user_id/agent_id/run_id as direct kwargs
search_kwargs.update(filters)
else:
# Platform client uses filters dict
search_kwargs["filters"] = filters
search_response = await self.mem0_client.search(**search_kwargs)
Additional Context
Note that invoked() (the add call) already passes user_id as a direct keyword argument and works correctly with both clients. Only the search call in invoking() has this inconsistency.
Environment
agent-framework-mem0 at commit 98cd72839e
mem0ai==1.0.3
- Python 3.12
Bug Report
Description
Mem0Provider.invoking()passesuser_id,agent_id, andrun_idinside afiltersdict tomem0_client.search():This works with the Mem0 Platform client (
AsyncMemoryClient), but fails with the Mem0 OSS client (AsyncMemory), which expectsuser_id,agent_id, andrun_idas direct keyword arguments:Error
Steps to Reproduce
Mem0Providerwithmem0_client=AsyncMemory()(OSS) anduser_id="some_user"ChatAgentviacontext_provider=agent.run("any message")invoking()hook callssearch(query=..., filters={"user_id": "some_user"})which failsExpected Behavior
Mem0Providershould work with bothAsyncMemoryClient(Platform) andAsyncMemory(OSS). The search call should detect the client type and pass scoping parameters appropriately.Suggested Fix
In
_provider.py,invoking()should unpack the filters as keyword args when usingAsyncMemory(OSS):Additional Context
Note that
invoked()(theaddcall) already passesuser_idas a direct keyword argument and works correctly with both clients. Only thesearchcall ininvoking()has this inconsistency.Environment
agent-framework-mem0at commit98cd72839emem0ai==1.0.3