Overview
The Group Chat feature helps you use Mem0 with conversations involving multiple participants, such as team meetings or multi-agent conversations. You control which speaker a memory belongs to by scoping eachadd() call with user_id, agent_id, and run_id; Mem0 does not infer that scope automatically from the conversation.
When you scope conversations correctly, Mem0:
- Extracts memories from each participant’s messages
- Keeps each participant’s memories in a separate profile, addressed by the
user_idoragent_idyou assigned them - Lets you retrieve any participant’s memories independently using filters
How Group Chat Works
Mem0 does not automatically split a multi-participant conversation into separate memories per speaker. Aname field on a message is stored as context for extraction, but it does not change which user_id or agent_id the resulting memories are scoped to: that scope is always whatever user_id, agent_id, or run_id you pass to add().
To keep separate memory profiles per participant, scope each participant’s messages explicitly: call add() once per participant with their own user_id, or use run_id to group the conversation and filter by participant in your own message metadata.
Memory Attribution Rules
- Memories are always scoped to the
user_id,agent_id, andrun_idyou pass toadd(), not to thenamefield on individual messages. - If you need per-participant memories, call
add()separately for each participant’s messages with that participant’suser_id.
Using Group Chat
Basic Group Chat
Scope each participant’s messages with their ownuser_id and a shared run_id for the session. Call add() once per participant:
add() is asynchronous: it queues extraction and returns immediately. Poll get_all (see below) once processing completes to see the extracted memories. Each participant’s memory is scoped to the user_id you passed, so filtering by run_id returns all three, and filtering by a single user_id returns just that participant.
The name field does not change scope
The name field is stored as extraction context only. Attribution follows the user_id/agent_id/run_id you pass to add(), never the name. Passing two different names in one add() call does not split the memories across two profiles:
add() once per participant with their own user_id, as shown in Basic Group Chat above.
Retrieving Group Chat Memories
Get All Memories for a Session
Retrieve all memories from a specific group chat session:Get Memories for a Specific Participant
Retrieve memories from a specific participant in a group chat:Search Within Group Chat Context
Search for specific information within a group chat session:Message Format Requirements
Required Fields
Each message must include:role: The participant’s role ("user","assistant","agent")content: The message contentname(optional): The participant’s name, stored as context for extraction. It does not change whichuser_idoragent_ida memory is scoped to.
Example Message Structure
Roles
user: Human participantsassistant: AI assistants
Best Practices
-
Consistent Scoping: Use a consistent
user_id(oragent_id) per participant across sessions so their memories stay in one profile. -
Clear Role Assignment: Ensure each participant has the correct role (
user,assistant, oragent) for proper memory categorization. -
Session Management: Use meaningful
run_idvalues to organize group chat sessions and enable easy retrieval. - Memory Filtering: Use filters to retrieve memories from specific participants or sessions when needed.
- Async Processing: Memory additions are processed asynchronously by default, which is ideal for large group conversations.
- Search Context: Leverage the search functionality to find specific information within group chat contexts.
Use Cases
- Team Meetings: Track individual team member preferences and contributions
- Customer Support: Maintain separate memory profiles for different customers
- Multi-Agent Systems: Manage conversations with multiple AI assistants
- Collaborative Projects: Track individual preferences and expertise areas
- Group Discussions: Maintain context for each participant’s viewpoints
Discord
Join our community
GitHub
Ask questions on GitHub
Support
Talk to founders