This document outlines the core data structures used for managing memory, including sessions, contexts, and individual events (episodes).
These data types are the atomic building blocks of the MemMachine SDK. They define how individual events (Episode) are recorded and how memory instances are securely isolated for different conversations (MemoryContext).
This enumeration specifies the format of the data stored within an Episode’s content field.
Member
Value
Description
STRING
"string"
The content is a standard text string.
This design allows for future expansion to support other data formats like vector embeddings or image metadata without changing the core episode structure.
An Episode represents a single, atomic event or piece of data in the memory system (e.g., a user message, an agent’s internal thought).The use of @dataclass(kw_only=True) means all fields must be specified using keyword arguments when you create an Episode instance.
Field
Type
Description
uuid
UUID
A unique identifier for this specific episode.
episode_type
str
The category of event (e.g., 'message', 'thought', 'action').
content_type
ContentType
The type of the data stored in the content field.
content
Any
The actual data of the episode.
timestamp
datetime
The date and time when the episode occurred.
group_id
str
Identifier for the larger conversation group.
session_id
str
Identifier for the specific session this episode belongs to.
producer_id
str
The ID of the user or agent that created this episode.
produced_for_id
`str
None`
The ID of the intended recipient, if any.
user_metadata
`JSONValue
None`
A dictionary for any additional, custom metadata in a JSON-compatible format.
The MemoryContext is used by the EpisodicMemoryManager to define the unique identifier for a memory instance. It ensures that memory access is isolated to the correct conversation.
The MemoryContext implements custom equality (__eq__) and hashing (__hash__) methods. A memory context is considered equal to another if and only if their group_id and session_id match. This ensures that the manager correctly uses these two fields as the primary lookup key for active memory instances, regardless of how the agent and user sets are structured.
The SessionInfo holds all the persistent metadata about a single conversation session. This is retrieved from the SessionManager when an existing memory instance is opened.
Field
Type
Description
group_id
str
The identifier for the group conversation.
session_id
str
The unique string identifier for the session.
agent_ids
list[str]
A list of agent IDs participating in the session.
user_ids
list[str]
A list of user IDs participating in the session.
configuration
dict
A dictionary containing any custom configuration for this session.