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

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

说明与用途

作者通过在 Synology NAS 上自托管 Mem0,构建了一个私有记忆层,使 AI 助手能够记住客户偏好和交互历史,而无需将数据发送到第三方。

问题

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

结果

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.

工作流

  • 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.

证据

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

来源

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

来源

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.

来源

  • 记录日期: 2026-10-20T05:41:21.270Z