Skip to main content

Overview

The AddMemoryOptions interface defines the optional configuration used when adding a new memory via the MemMachineMemory.add() method. It allows for detailed categorization, role assignment, and metadata tagging.

Properties

All properties in this interface are optional, allowing for flexible memory ingestion depending on your use case.
PropertyTypeDescription
producerstringThe ID of the entity that produced the memory.
roleMemoryProducerRoleThe role of the producer (e.g., user, assistant).
produced_forstringThe ID of the target entity the memory was produced for.
episode_typestringA custom classification for the type of interaction episode.
timestampstringThe specific time the memory occurred (ISO 8601 string).
metadataRecord<string, string>Key-value pairs for additional custom contextual data.
typesMemoryType[]The classification of memories to be created (e.g., episodic).

Usage Example

The following example shows how to use AddMemoryOptions to provide context when saving a user preference.
import { AddMemoryOptions } from '@memmachine/client';

const memory = project.memory();

const options: AddMemoryOptions = {
  role: 'user',
  episode_type: 'preference_update',
  metadata: {
    feature: 'dark_mode',
    source: 'settings_ui'
  }
};

await memory.add('User toggled dark mode to "on" for the dashboard.', options);
While metadata is optional, using it consistently is recommended for advanced filtering during semantic searches.