Skip to content

Python: mem0 basic example not working #2621

Closed

Description

On running the python basic example with mem0 hosted instance I get a 400 http request error.

REQUEST: POST https://api.mem0.ai/v2/memories/search/
HEADERS: {'host': 'api.mem0.ai', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx/0.28.1', 'authorization': 'Token m0-[REDACTED]', 'mem0-user-id': 'af[REDACTED]', 'content-length': '211', 'content-type': 'application/json'}
BODY: {"query":"Please retrieve my company report","user_id":"0dc6[REDACTED]","org_id":"org_[REDACTED]","project_id":"proj_[REDACTED]"}
================================================================================


================================================================================
RESPONSE: 400 Bad Request
HEADERS: {'date': 'Thu, 04 Dec 2025 06:52:38 GMT', 'content-type': 'application/json', 'content-length': '127', 'connection': 'keep-alive', 'server': 'uvicorn', 'vary': 'Accept, origin, Authorization, Cookie', 'allow': 'OPTIONS, POST', 'x-frame-options': 'DENY', 'x-content-type-options': 'nosniff', 'referrer-policy': 'same-origin', 'cross-origin-opener-policy': 'same-origin'}
BODY: {"error":"Filters are required and cannot be empty. Please refer to https://docs.mem0.ai/api-reference/memory/search-memories"}
================================================================================

Traceback (most recent call last):
  File "/home/Barco/agent-framework/python/samples/getting_started/context_providers/mem0/mem0_basic.py", line 116, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/Barco/agent-framework/python/samples/getting_started/context_providers/mem0/mem0_basic.py", line 91, in main
    result = await agent.run(query)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Barco/agent-framework/python/.venv/lib/python3.11/site-packages/agent_framework/_middleware.py", line 1249, in middleware_enabled_run
    return await original_run(self, normalized_messages, thread=thread, **kwargs)  # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Barco/agent-framework/python/.venv/lib/python3.11/site-packages/agent_framework/observability.py", line 1106, in trace_run
    return await run_func(self, messages=messages, thread=thread, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Barco/agent-framework/python/.venv/lib/python3.11/site-packages/agent_framework/_agents.py", line 832, in run
    thread, run_chat_options, thread_messages = await self._prepare_thread_and_messages(
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Barco/agent-framework/python/.venv/lib/python3.11/site-packages/agent_framework/_agents.py", line 1258, in _prepare_thread_and_messages
    context = await self.context_provider.invoking(input_messages or [])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Barco/agent-framework/python/.venv/lib/python3.11/site-packages/agent_framework/_memory.py", line 247, in invoking
    contexts = await asyncio.gather(*[provider.invoking(messages, **kwargs) for provider in self.providers])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Barco/agent-framework/python/.venv/lib/python3.11/site-packages/agent_framework_mem0/_provider.py", line 149, in invoking
    search_response: MemorySearchResponse_v1_1 | MemorySearchResponse_v2 = await self.mem0_client.search(  # type: ignore[misc]
                                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Barco/agent-framework/python/.venv/lib/python3.11/site-packages/mem0/client/main.py", line 1158, in search
    response.raise_for_status()
  File "/home/Barco/agent-framework/python/.venv/lib/python3.11/site-packages/httpx/_models.py", line 829, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.mem0.ai/v2/memories/search/'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

it looks like the mem0 v2 api is expecting filters param in the search argument as listed here https://docs.mem0.ai/api-reference/memory/search-memories

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Dec 4, 2025
  2. changed the title [-]mem0 basic example not working[/-] [+]Python: mem0 basic example not working[/+] on Dec 4, 2025
  3. added
    bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Dec 4, 2025
  4. moved this from Bug to In Progress in Agent Frameworkon Dec 4, 2025
  5. amit12cool commented on Dec 5, 2025

    @amit12cool
    ContributorAuthor

    ok so downgrading to mem0 to uv pip install mem0ai==0.1.118 --force-reinstall resolved the issue

  6. moved this from In Progress to Done in Agent Frameworkon Dec 5, 2025
  7. moved this from Done to In Review in Agent Frameworkon Dec 5, 2025
  8. moved this from In Review to In Progress in Agent Frameworkon Dec 5, 2025
  9. moonbox3 commented on Dec 8, 2025

    @moonbox3
    Contributor

    Amit Dhawan (@amit12cool), not sure if the original info in the issue was truly a valid token or not, but for safety, I've redacted some info. FYI.

  10. moved this from In Progress to In Review in Agent Frameworkon Dec 9, 2025
  11. moved this from In Review to Done in Agent Frameworkon Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)pythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions