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
14 changes: 8 additions & 6 deletions mem0/memory/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ def _should_use_agent_memory_extraction(self, messages, metadata):
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

agent_id = metadata.get("agent_id")
if agent_id is None:
return False

# 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
for msg in messages:
if msg.get("role") == "assistant":
return True
return False

def add(
self,
Expand Down