Getting Started
Core Features
How-To Guides
Configuration
Troubleshooting
Integrations
This page addresses common issues you might encounter, especially after upgrading to mem0 v1.0.0. This version introduced significant API simplifications, which means some of your existing code might need minor adjustments. Understanding these changes will help you resolve problems quickly and efficiently.
The mem0 v1.0.0 release streamlines the API by removing confusing version parameters and standardizing response formats. If you are experiencing unexpected behavior or errors, especially KeyError or TypeError, it's likely related to these changes.
If you haven't already, follow these steps to upgrade your mem0 installation and code. This often resolves many common problems.
Upgrade your mem0ai package to the latest version.
pip install mem0ai==1.0.0Remove any version or output_format parameters from your Memory or MemoryClient initialization and method calls.
Before:
# With Memory API
memory = Memory(config=MemoryConfig(version="v1.1"))
result = memory.add("I like pizza")
# With Client API
client.add(messages, output_format="v1.1")
client.search(query, version="v2", output_format="v1.1")After:
# With Memory API
memory = Memory() # Version is automatic now
result = memory.add("I like pizza")
# With Client API
client.add(messages) # Just remove those extra parameters
client.search(query)All responses now use a consistent format: a dictionary with a "results" key. You need to access the actual data through this key.
Before:
result = memory.add("I like pizza")
for item in result: # Treating it as a list
print(item)After:
result = memory.add("I like pizza")
for item in result["results"]: # Access the results key
print(item)Here are some specific errors you might encounter and how to fix them.
KeyError: 'results'This error occurs when your code expects the API response to be a direct list of memories, but it's now a dictionary containing a "results" key.
In mem0 v1.0.0, all API responses (from add, search, get_all, etc.) are now consistently structured as a dictionary with a top-level key called "results". The actual data you're interested in (e.g., the list of memories) is nested under this key.
Example of a new response:
{
"results": [
{"memory": "I like pizza", "timestamp": "..."},
{"memory": "I like pasta", "timestamp": "..."}
]
}resultsModify your code to access the "results" key from the response dictionary.
Change this:
for memory_item in response:
# ... your code ...To this:
for memory_item in response["results"]:
TypeError: unexpected keyword argumentThis error indicates that you are passing parameters that are no longer supported by the mem0 API methods. Specifically, version and output_format have been removed.
Review your Memory or MemoryClient initialization and any method calls (like add, search) for version or output_format parameters.
Change this:
# Example with MemoryClient
client.add(messages, output_format="v1.1")
client.search(query, version="v2", output_format="v1.1")
# Example with MemoryConfig
memory = Memory(config=MemoryConfig(version="v1.0"))To this:
# Example with MemoryClient
client.add(messages)
client.search(query)
# Example with MemoryConfig
memory = Memory() # Remove the version parameterIf you see warnings related to version parameters, it means you still have an explicit version set in your MemoryConfig.
version from MemoryConfigThe version parameter is no longer needed in MemoryConfig as the API now uses a single, consistent version.
Change this:
from mem0 import Memory, MemoryConfig
config = MemoryConfig(
version="v1.0",
# ... other configurations ...
)
memory = Memory(config=config)To this:
from mem0 import Memory, MemoryConfig
config = MemoryConfig(
# ... other configurations, but no 'version' ...
)
memory = Memory(config=config)
# Or, if you don't have other config:
memory = Memory()As mentioned, all API responses now return a dictionary with a "results" key. This standardization makes it easier to predict and handle data returned by mem0, regardless of the specific operation.
The MemoryClient now supports the same flexible message formats as the open-source version. You can provide messages as:
{"role": "user", "content": "..."}).from mem0 import MemoryClient
client = MemoryClient(api_key="your-key")
# 1. Single string
client.add("I like pizza", user_id="alice")
# 2. Single message dictionary
client.add({"role": "user", "content": "I like pizza"}, user_id="alice")
# 3. List of messages (conversation)
client.add([
{"role": "user", "content": "I like pizza"},
{"role": "assistant", "content": "I'll remember that!"}
], user_id="alice")The async_mode parameter for adding memories now defaults to True. This generally provides better performance by processing memory additions in the background. You can explicitly set it to False if you have specific requirements for synchronous processing, but it's usually not necessary.
# Default behavior (async_mode=True)
client.add(messages, user_id="alice")
# Explicitly set async mode
client.add(messages, user_id="alice", async_mode=True)
# Disable async mode if needed
client.add(messages, user_id="alice", async_mode=False)After making changes, you can use this quick sanity check to ensure your migration was successful and the API responses are in the expected format.
Execute the following Python code to verify that add, search, and get_all methods return dictionaries with the "results" key.
from mem0 import Memory
memory = Memory()
# Add should return a dict with "results"
result = memory.add("I like pizza", user_id="test")
assert "results" in result, "Add method did not return 'results' key"
# Search should return a dict with "results"
search = memory.search("food", user_id="test")
assert "results" in search, "Search method did not return 'results' key"
# Get all should return a dict with "results"
all_memories = memory.get_all(user_id="test")
assert "results" in all_memories, "Get all method did not return 'results' key"
print("✅ Migration successful! All checks passed.")