Skip to content

extractMemories

function extractMemories(session, options?): MemoryEntry[];

Extracts MemoryEntry objects from a session’s user + assistant messages.

Used by adapter-backed MemoryService implementations (postgres-store, redis-store, etc.) when ingesting a closed session. Each qualifying message becomes one memory; messages with non-string content are flattened via the text parts only.

Messages that are not role user or assistant, and messages whose flattened content is empty/whitespace, are skipped.

Memory ids are deterministic per-session: ${session.id}:${index} — this matches the shape that PostgresMemoryService and RedisMemoryService rely on for idempotent re-ingestion (delete-then-reinsert keeps the session_id grouping stable).

Parameter Type

session

Session

options?

MemoryIngestionOptions

MemoryEntry[]