Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions mem0/memory/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ def __init__(self, config: MemoryConfig = MemoryConfig()):

telemetry_config = _safe_deepcopy_config(self.config.vector_store.config)
telemetry_config.collection_name = "mem0migrations"
if self.config.vector_store.provider in ["faiss", "qdrant"]:
if self.config.vector_store.provider in ("faiss", "qdrant"):
provider_path = f"migrations_{self.config.vector_store.provider}"
telemetry_config.path = os.path.join(mem0_dir, provider_path)
os.makedirs(telemetry_config.path, exist_ok=True)
Expand Down Expand Up @@ -1319,14 +1319,15 @@ def _should_use_agent_memory_extraction(self, messages, metadata):
Returns:
bool: True if should use agent memory extraction, False for user memory extraction
"""
# Check if agent_id is present in metadata
has_agent_id = metadata.get("agent_id") is not None

# Check if there are assistant role messages
has_assistant_messages = any(msg.get("role") == "assistant" for msg in messages)

# Use agent memory extraction if agent_id is present and there are assistant messages
return has_agent_id and has_assistant_messages
# Check if agent_id is present in metadata and there are assistant role messages
agent_id = metadata.get("agent_id")
if agent_id is None:
return False
# Fast loop: exit on first match, avoids building lists or unnecessary generator objects
for msg in messages:
if msg.get("role") == "assistant":
return True
return False

async def add(
self,
Expand Down