Skip to main content

NVIDIA NeMo Agent Toolkit

SelfMemory integrates with the NVIDIA NeMo Agent Toolkit memory module, giving you access to NeMo's memory providers (Mem0, Redis, Zep) as alternative backends for your SelfMemory instance.

Overview​

The NeMo Agent Toolkit is NVIDIA's open-source framework for building teams of AI agents. Its memory subsystem stores and retrieves conversation history, user preferences, and long-term context across agent interactions.

SelfMemory's NeMo adapter wraps NeMo's async MemoryEditor interface behind the standard MemoryBase API, so you can swap between native SelfMemory and NeMo-backed memory with a config change.

Supported NeMo Memory Providers​

ProviderPackageDescription
Mem0nvidia-nat-mem0aiSelf-improving memory with semantic understanding
Redisnvidia-nat-redisFast in-memory operations with vector search
Zepnvidia-nat-zep-cloudCloud-hosted conversation memory

Installation​

# Install SelfMemory with NeMo support
pip install selfmemory[nemo]

This installs nvidia-nat and its dependencies. You also need the specific provider plugin:

# For Mem0 backend
pip install nvidia-nat-mem0ai

# For Redis backend
pip install nvidia-nat-redis

# For Zep backend
pip install nvidia-nat-zep-cloud

Quick Start​

Using the Memory Factory​

from selfmemory.utils.factory import MemoryFactory

# Create a NeMo Mem0-backed memory instance
memory = MemoryFactory.create("nemo_mem0", {
"api_key": "your-mem0-api-key",
})

# Use it like any SelfMemory instance
memory.add("I love Italian food", user_id="alice")
results = memory.search("food preferences", user_id="alice")

Using Configuration​

from selfmemory import SelfMemory
from selfmemory.configs.base import SelfMemoryConfig
from selfmemory.configs.nemo import NemoMemoryConfig
from selfmemory.memory.nemo_adapter import NemoMemoryAdapter

config = NemoMemoryConfig(
provider="mem0",
config={
"api_key": "your-mem0-api-key",
},
)

memory = NemoMemoryAdapter(config)
memory.add("Meeting with Sarah at 3pm", user_id="bob")

Using YAML Configuration​

Add to your ~/.selfmemory/config.yaml:

nemo_memory:
provider: mem0
config:
api_key: ${NEMO_MEMORY_API_KEY}

Provider Configuration​

Mem0​

from selfmemory.utils.factory import MemoryFactory

memory = MemoryFactory.create("nemo_mem0", {
"api_key": "your-mem0-api-key",
"organization": "your-org",
"project": "your-project",
})

Environment Variables:

export NEMO_MEMORY_API_KEY="your-mem0-api-key"

Redis​

from selfmemory.utils.factory import MemoryFactory

memory = MemoryFactory.create("nemo_redis", {
"host": "localhost",
"port": 6379,
"password": "your-redis-password",
})

Starting Redis with vector search:

docker run -p 6379:6379 redis/redis-stack:latest

Zep​

from selfmemory.utils.factory import MemoryFactory

memory = MemoryFactory.create("nemo_zep", {
"api_key": "your-zep-api-key",
"base_url": "https://api.getzep.com",
})

API Reference​

The NeMo adapter implements the full MemoryBase interface. All operations work identically to native SelfMemory.

add()​

memory.add(
"I prefer dark mode in all my apps",
user_id="alice",
tags="preferences,ui",
people_mentioned="Alice",
topic_category="preferences",
metadata={"source": "chat"},
)

Parameters:

ParameterTypeDescription
messagesstr, dict, or list[dict]Memory content (string, single message, or conversation)
user_idstrRequired. User identifier for isolation
tagsstrOptional. Comma-separated tags
people_mentionedstrOptional. Comma-separated names
topic_categorystrOptional. Topic category
metadatadictOptional. Additional key-value metadata
results = memory.search(
"ui preferences",
user_id="alice",
limit=5,
tags=["preferences"],
topic_category="preferences",
)

for result in results["results"]:
print(f"{result['content']} (id: {result['id']})")

Parameters:

ParameterTypeDefaultDescription
querystr""Search query
user_idstrrequiredUser identifier
limitint10Max results
tagslist[str]NoneFilter by tags
people_mentionedlist[str]NoneFilter by people
topic_categorystrNoneFilter by category
thresholdfloatNoneMin similarity score

Response:

{
"results": [
{
"id": "mem_abc123",
"content": "I prefer dark mode in all my apps",
"metadata": {
"data": "I prefer dark mode in all my apps",
"user_id": "alice",
"tags": "preferences,ui",
"topic_category": "preferences"
}
}
]
}

delete()​

memory.delete("mem_abc123")

delete_all()​

memory.delete_all(user_id="alice")

get_all()​

results = memory.get_all(user_id="alice", limit=50)

health_check()​

status = memory.health_check()
# {"status": "healthy", "provider": "nemo_mem0"}

Data Model Mapping​

SelfMemory automatically converts between its data format and NeMo's MemoryItem model:

SelfMemoryNeMo MemoryItemDirection
messages (str/list)memory + conversationSelfMemory -> NeMo
user_iduser_idBidirectional
tags (comma-separated)tags (list)Bidirectional
metadata (dict)metadata (dict)Bidirectional
people_mentionedmetadata.people_mentionedSelfMemory -> NeMo
topic_categorymetadata.topic_categorySelfMemory -> NeMo

Architecture​

+---------------------+      +-------------------+      +------------------+
| Your Application | ---> | NemoMemoryAdapter | ---> | NeMo MemoryEditor|
| | | (MemoryBase) | | (async) |
+---------------------+ +-------------------+ +------------------+
| |
sync-to-async bridge +------+------+
(asyncio.to_thread / | | |
ThreadPoolExecutor) Mem0 Redis Zep

The adapter handles:

  • Sync-to-async bridging — NeMo's MemoryEditor is fully async. The adapter runs async operations via asyncio.run() or ThreadPoolExecutor when inside an existing event loop (e.g., FastAPI).
  • Data model translation — Converts between SelfMemory's string-based tags and NeMo's list-based tags, maps metadata fields, and extracts content from conversation lists.
  • User isolation — Passes user_id to all NeMo operations, maintaining SelfMemory's per-user memory isolation.

Environment Variables​

VariableDescription
NEMO_MEMORY_API_KEYAPI key for the NeMo memory provider
NEMO_MEMORY_HOSTHost URL for the memory provider

These are used as fallbacks when not specified in the config dict.

Python Version Requirements​

  • SelfMemory core: Python 3.10+
  • NeMo integration: Python 3.11+ (required by nvidia-nat)

The NeMo adapter is an optional dependency. Projects on Python 3.10 can use all other SelfMemory features.

Comparison with Native SelfMemory​

FeatureNative SelfMemoryNeMo Adapter
Vector stores29 providers (Qdrant, Chroma, Pinecone, etc.)Depends on NeMo provider
Embeddings15+ providers (Ollama, OpenAI, etc.)Managed by NeMo provider
Setup complexityConfigure vector store + embeddings separatelySingle provider config
Async supportSync APISync API (wraps NeMo's async internally)
EncryptionBuilt-in Fernet encryptionDepends on provider
LLM extractionOptional fact extraction via LLMDepends on provider

When to use NeMo adapter:

  • You are building agents with NVIDIA's NeMo Agent Toolkit
  • You want a managed memory service (Mem0 Cloud, Zep Cloud)
  • You need Redis-based memory for high-throughput scenarios
  • You want to evaluate different memory backends quickly

When to use native SelfMemory:

  • You need fine-grained control over vector stores and embeddings
  • You want to use local/self-hosted infrastructure
  • You need built-in encryption
  • You want LLM-based intelligent fact extraction

Troubleshooting​

ImportError: No module named 'nat'​

pip install selfmemory[nemo]

The nvidia-nat package is required. Make sure you're on Python 3.11+.

Provider-specific import errors​

Each NeMo provider requires its own package:

# Missing Mem0
pip install nvidia-nat-mem0ai

# Missing Redis
pip install nvidia-nat-redis

# Missing Zep
pip install nvidia-nat-zep-cloud

Event loop errors in FastAPI​

The adapter automatically handles this by detecting running event loops and using a ThreadPoolExecutor fallback. If you still encounter issues, ensure you're using the latest version of SelfMemory.

Next Steps​