Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I Self-Hosted a Mem0 Memory Stack (So My AI Agent Remembers)

Description and use

The author built a private memory layer for an AI assistant by self-hosting Mem0 on a Synology NAS, enabling the agent to remember customer preferences and interaction history without sending data to third parties.

Problem

An AI agent that forgets everything between conversations requires a persistent memory layer to retain context across sessions.

Outcome

The self-hosted Mem0 stack delivers a private, persistent memory layer that enables the AI agent to remember customer preferences, past interactions, and decisions across sessions, all without data leaving the local network.

Workflow

  • Deploy three Docker containers on the Synology NAS using Portainer compose: mem0 API, LiteLLM gateway, and PostgreSQL 17 with pgvector extension.
  • Configure mem0 API with environment variables for OpenAI API key, LiteLLM base URL, MEM0_API_KEY, and PostgreSQL connection string.
  • Set up LiteLLM to route fact extraction requests to the chosen LLM (e.g., OpenAI).
  • Use POST /memories to add facts, optionally with infer=false for fast verbatim storage.
  • Use POST /memories/search to retrieve relevant memories for a user_id and query.
  • Inject retrieved facts into the AI agent’s system prompt or context before generating a response.
  • Iterate: store new facts, retrieve relevant ones, and use them in subsequent replies.

Evidence

An AI agent that forgets everything between conversations is a tool you have to reintroduce yourself to every session.

Source

The stack sits in my own PostgreSQL behind my own network, none of that leaves my control.

Source

POST /memories with the default infer=true runs the LLM fact extractor — it classifies and cleans each memory. That's smart but slow, and every call costs a model round-trip.

Source

  • Record date: 2026-10-20T05:41:21.270Z