Bugs found and fixed during end-to-end QA testing of the v3 OSS pipeline
across both the TypeScript and Python SDKs. All changes are OSS-side
only; platform client untouched.
## TypeScript fixes (mem0-ts/)
### 1. Entity extractor trailing punctuation (utils/entity_extraction.ts)
End-of-sentence proper nouns retained their trailing period ("Paris."
vs "Paris"), causing cross-batch entity dedup to fail silently —
embeddings of "Paris." and "Paris" don't hit the 0.95 similarity
threshold. Fix: strip trailing sentence punctuation (. , ; ! ?) in
the existing cleanup pass.
### 2. Undefined filter values leak into vector stores (memory/index.ts)
PR #4843's validateAndTrimEntityId refactor spread agent_id: undefined
and run_id: undefined into every getAll/search filter dict. Qdrant
rejected the malformed match (400), pgvector bound NULL (0 rows),
Redis emitted literal "undefined" in TAG filters. Fix: strip
undefined values via Object.fromEntries filter at both call sites.
### 3. Redis TAG filter values unescaped (vector_stores/redis.ts)
Every UUID contains hyphens, which RediSearch interprets as minus
operators. @user_id:{legacy-abc} parses as "legacy AND NOT abc" —
zero matches. Fix: escapeRedisTagValue helper backslash-escapes all
RediSearch TAG special characters.
### 4. Entity cleanup on delete/update/deleteAll (memory/index.ts)
delete(), update(), and deleteAll() never touched the _entities
collection — linkedMemoryIds accumulated stale ids on every mutation.
Search entity-boost then surfaced deleted or rewritten memories. Fix:
new _removeMemoryFromEntityStore and _linkEntitiesForMemory helpers,
wired into deleteMemory and updateMemory. deleteAll gets coverage for
free (loops deleteMemory).
### 5. textLemmatized missing on infer:false path (memory/index.ts)
createMemory() (used by infer:false) set data and hash but never
called lemmatizeForBm25(). Memories added with infer:false had
degraded BM25 — keyword search fell back to raw data. Fix: one-line
addition of textLemmatized to createMemory payload.
## Python fix (mem0/)
### 6. Entity cleanup on delete/update/deleteAll (memory/main.py)
Same bug as TS #4 — _delete_memory and _update_memory never touched
the entity store. Fix: _remove_memory_from_entity_store and
_link_entities_for_memory helpers (sync + async), wired into both
Memory and AsyncMemory. delete_all covered transitively.
## Verification
All changes verified via scratch QA probes against live vector stores:
TS probes (in-memory SQLite, Qdrant, pgvector, Redis):
- Entity cross-batch dedup: Paris entity merges linkedMemoryIds
- Entity boost at search: +67% score delta with vs without entities
- Delete cleanup: stale id removed, ghost entities deleted
- Update cleanup: old entity unlinked, new entity created
- deleteAll: entity store fully cleared
- Legacy data compat: all 4 stores pass (seed v1 record, v3 read/write)
- BM25 contributes real signal on in-memory store
- infer:false: 0 LLM calls, textLemmatized populated, entities skipped
- No-graph: clean separation, legacy config silently ignored
Python probes (Qdrant server):
- Delete/update/deleteAll entity cleanup: all 3 scenarios pass
TS build: clean (552 unit tests pass)
Python tests: 25 + 35 + 173 pass (2 pre-existing failures unrelated)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Learn more · Join Discord · Demo
📄 Building Production-Ready AI Agents with Scalable Long-Term Memory →
⚡ +26% Accuracy vs. OpenAI Memory • 🚀 91% Faster • 💰 90% Fewer Tokens
🎉 mem0ai v1.0.0 is now available! This major release includes API modernization, improved vector store support, and enhanced GCP integration. See migration guide →
🔥 Research Highlights
- +26% Accuracy over OpenAI Memory on the LOCOMO benchmark
- 91% Faster Responses than full-context, ensuring low-latency at scale
- 90% Lower Token Usage than full-context, cutting costs without compromise
- Read the full paper
Introduction
Mem0 ("mem-zero") enhances AI assistants and agents with an intelligent memory layer, enabling personalized AI interactions. It remembers user preferences, adapts to individual needs, and continuously learns over time—ideal for customer support chatbots, AI assistants, and autonomous systems.
Key Features & Use Cases
Core Capabilities:
- Multi-Level Memory: Seamlessly retains User, Session, and Agent state with adaptive personalization
- Developer-Friendly: Intuitive API, cross-platform SDKs, and a fully managed service option
Applications:
- AI Assistants: Consistent, context-rich conversations
- Customer Support: Recall past tickets and user history for tailored help
- Healthcare: Track patient preferences and history for personalized care
- Productivity & Gaming: Adaptive workflows and environments based on user behavior
🚀 Quickstart Guide
Choose between our hosted platform or self-hosted package:
Hosted Platform
Get up and running in minutes with automatic updates, analytics, and enterprise security.
- Sign up on Mem0 Platform
- Embed the memory layer via SDK or API keys
Self-Hosted (Open Source)
Install the sdk via pip:
pip install mem0ai
For enhanced hybrid search with BM25 keyword matching and entity extraction, install with NLP support:
pip install mem0ai[nlp]
python -m spacy download en_core_web_sm
Install sdk via npm:
npm install mem0ai
CLI
Manage memories from your terminal:
npm install -g @mem0/cli # or: pip install mem0-cli
mem0 init
mem0 add "Prefers dark mode and vim keybindings" --user-id alice
mem0 search "What does Alice prefer?" --user-id alice
See the CLI documentation for the full command reference.
Basic Usage
Mem0 requires an LLM to function, with gpt-4.1-nano-2025-04-14 from OpenAI as the default. However, it supports a variety of LLMs; for details, refer to our Supported LLMs documentation.
Mem0 uses text-embedding-3-small from OpenAI as the default embedding model. For best results with hybrid search (semantic + keyword + entity boosting), we recommend using at least Qwen 600M or a comparable embedding model. See Supported Embeddings for configuration details.
First step is to instantiate the memory:
from openai import OpenAI
from mem0 import Memory
openai_client = OpenAI()
memory = Memory()
def chat_with_memories(message: str, user_id: str = "default_user") -> str:
# Retrieve relevant memories
relevant_memories = memory.search(query=message, user_id=user_id, limit=3)
memories_str = "\n".join(f"- {entry['memory']}" for entry in relevant_memories["results"])
# Generate Assistant response
system_prompt = f"You are a helpful AI. Answer the question based on query and memories.\nUser Memories:\n{memories_str}"
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": message}]
response = openai_client.chat.completions.create(model="gpt-4.1-nano-2025-04-14", messages=messages)
assistant_response = response.choices[0].message.content
# Create new memories from the conversation
messages.append({"role": "assistant", "content": assistant_response})
memory.add(messages, user_id=user_id)
return assistant_response
def main():
print("Chat with AI (type 'exit' to quit)")
while True:
user_input = input("You: ").strip()
if user_input.lower() == 'exit':
print("Goodbye!")
break
print(f"AI: {chat_with_memories(user_input)}")
if __name__ == "__main__":
main()
For detailed integration steps, see the Quickstart and API Reference.
🔗 Integrations & Demos
- ChatGPT with Memory: Personalized chat powered by Mem0 (Live Demo)
- Browser Extension: Store memories across ChatGPT, Perplexity, and Claude (Chrome Extension)
- Langgraph Support: Build a customer bot with Langgraph + Mem0 (Guide)
- CrewAI Integration: Tailor CrewAI outputs with Mem0 (Example)
📚 Documentation & Support
- Full docs: https://docs.mem0.ai
- Community: Discord · X (formerly Twitter)
- Contact: founders@mem0.ai
Citation
We now have a paper you can cite:
@article{mem0,
title={Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memory},
author={Chhikara, Prateek and Khant, Dev and Aryan, Saket and Singh, Taranjeet and Yadav, Deshraj},
journal={arXiv preprint arXiv:2504.19413},
year={2025}
}
⚖️ License
Apache 2.0 — see the LICENSE file for details.