Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

Changed the default value in Mem0 config (#3216)

Vidit Ostwal864e9bfb761c
diff --git a/docs/en/concepts/memory.mdx b/docs/en/concepts/memory.mdx
index 67c13ee56..e7d5b9bb8 100644
--- a/docs/en/concepts/memory.mdx
+++ b/docs/en/concepts/memory.mdx
@@ -720,7 +720,7 @@ crew = Crew(
```
### Advanced Mem0 Configuration
-When using Mem0 Client, you can customize the memory configuration further, by using parameters like 'includes', 'excludes', 'custom_categories' and 'run_id' (this is only for short-term memory).
+When using Mem0 Client, you can customize the memory configuration further, by using parameters like 'includes', 'excludes', 'custom_categories', 'infer' and 'run_id' (this is only for short-term memory).
You can find more details in the [Mem0 documentation](https://docs.mem0.ai/).
```python
@@ -744,7 +744,7 @@ crew = Crew(
"run_id": "my_run_id", # Optional - for short-term memory
"includes": "include1", # Optional
"excludes": "exclude1", # Optional
- "infer": True
+ "infer": True # Optional defaults to True
"custom_categories": new_categories # Optional - custom categories for user memory
},
"user_memory": {}
@@ -776,7 +776,7 @@ crew = Crew(
"config": {"api_key": "your-api-key", "model": "text-embedding-3-small"}
}
},
- "infer": True
+ "infer": True # Optional defaults to True
},
"user_memory": {}
}
diff --git a/src/crewai/memory/storage/mem0_storage.py b/src/crewai/memory/storage/mem0_storage.py
index e0e8af890..8e6e1f65d 100644
--- a/src/crewai/memory/storage/mem0_storage.py
+++ b/src/crewai/memory/storage/mem0_storage.py
@@ -43,7 +43,7 @@ class Mem0Storage(Storage):
self.includes = cfg.get("includes")
self.excludes = cfg.get("excludes")
self.custom_categories = cfg.get("custom_categories")
- self.infer = cfg.get("infer", False)
+ self.infer = cfg.get("infer", True)
def _initialize_memory(self):
api_key = self.config.get("api_key") or os.getenv("MEM0_API_KEY")
diff --git a/tests/storage/test_mem0_storage.py b/tests/storage/test_mem0_storage.py
index 6c4cf3c6e..76de5f63d 100644
--- a/tests/storage/test_mem0_storage.py
+++ b/tests/storage/test_mem0_storage.py
@@ -270,3 +270,20 @@ def test_search_method_with_memory_client(mem0_storage_with_memory_client_using_
assert len(results) == 2
assert results[0]["content"] == "Result 1"
+
+
+def test_mem0_storage_default_infer_value(mock_mem0_memory_client):
+ """Test that Mem0Storage sets infer=True by default for short_term memory."""
+ with patch.object(MemoryClient, "__new__", return_value=mock_mem0_memory_client):
+ crew = MockCrew(
+ memory_config={
+ "provider": "mem0",
+ "config": {
+ "user_id": "test_user",
+ "api_key": "ABCDEFGH"
+ },
+ }
+ )
+
+ mem0_storage = Mem0Storage(type="short_term", crew=crew)
+ assert mem0_storage.infer is True
\ No newline at end of file