Skip to content

Add mem0 Memory Implementation #6510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

alpha-xone
Copy link

@alpha-xone alpha-xone commented May 11, 2025

Why are these changes needed?

These changes are needed to expand AutoGen's memory capabilities with a robust, production-ready integration with Mem0.ai.

This PR adds a new memory component for AutoGen that integrates with Mem0.ai, providing a robust memory solution that supports both cloud and local backends. The Mem0Memory class enables agents to store and retrieve information persistently across conversation sessions.

Key Features

  • Seamless integration with Mem0.ai memory system
  • Support for both cloud-based and local storage backends
  • Robust error handling with detailed logging
  • Full implementation of AutoGen's Memory interface
  • Context updating for enhanced agent conversations
  • Configurable search parameters for memory retrieval

Related issue number

Checks

Copy link

gitguardian bot commented May 11, 2025

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@alpha-xone
Copy link
Author

@microsoft-github-policy-service agree

@alpha-xone alpha-xone changed the title add mem0 memory implementation Add mem0 Memory Implementation May 12, 2025
Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Could you add unit tests so we can ensure the correctness of the features?

Copy link

codecov bot commented May 13, 2025

Codecov Report

Attention: Patch coverage is 0% with 133 lines in your changes missing coverage. Please review.

Project coverage is 78.63%. Comparing base (177211b) to head (b360f78).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ackages/autogen-ext/src/autogen_ext/memory/mem0.py 0.00% 133 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6510      +/-   ##
==========================================
- Coverage   79.29%   78.63%   -0.67%     
==========================================
  Files         225      226       +1     
  Lines       16679    16812     +133     
==========================================
- Hits        13226    13220       -6     
- Misses       3453     3592     +139     
Flag Coverage Δ
unittests 78.63% <0.00%> (-0.67%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alpha-xone
Copy link
Author

Thanks for replying 🚀

Unit test added: https://github.com/alpha-xone/autogen/actions/runs/14992498495
This is tested with my mem0 api key. If the test is from the main branch, it requires another key to test.

@ekzhu
Copy link
Collaborator

ekzhu commented May 14, 2025

Thanks for adding the tests. Can we use the open source verison of mem0? I think it can run entirely locally.

@alpha-xone
Copy link
Author

Yes we can. I'm running it locally with the combination of neo4j for graph storage + chromadb for vector db + SQLite for historical db. All we need to do is setup the local environment and pass a dict of configurations of these in. But for unit testing, I'm not sure how to make these environments ready to test.

@ekzhu
Copy link
Collaborator

ekzhu commented May 14, 2025

For SQLite and Chroma DB, I think you can instantiate directly as test fixture, right? See example on ChromaDBVectorMemory tests: https://github.com/microsoft/autogen/blob/78ef148c88beb29a7e7602aa39a772b0ffbc50d5/python/packages/autogen-ext/tests/memory/test_chroma_memory.py

For Neo4j, there should be github actions that can set this up in CI. For local integration test, we can skip it if no neo4j server is running.

Besides all these above, I thought mem0's can run independently as in-memory python code? That's my impression reading their documentation. https://docs.mem0.ai/open-source/python-quickstart#basic

@alpha-xone
Copy link
Author

The neo4j container cannot initiated on the server:
https://github.com/alpha-xone/autogen/actions/runs/15066738718

  Error: Failed to initialize container neo4j:5.19
Error: One or more containers failed to start.

I can only test locally with the same config in the test_mem0.py file - it's working on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants