{
  "id": 2625906,
  "title": "How I Built Memory for a Local AI Companion Without Sending Chats to a Server",
  "url": "https://urgent.news/2026/08/22/how-i-built-memory-for-a-local-ai-companion-without-sending-chats-to",
  "topic": "ai",
  "section": "AI",
  "published": "2026-08-22T18:17:18.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/lukasz_141142/how-i-built-memory-for-a-local-ai-companion-without-sending-chats-to-a-server-2ki8"
  },
  "original_language": "en",
  "account": "Building a memory system for an AI companion without sending chats to a server presents unique challenges. The first version of memory was to simply save messages, which provided a history but lacked recall capabilities. As the chat history grew, sending it back to a local language model for every message became slow and contextually inefficient. Thus, chat history and long-term memory were separated. Chat history provides immediate context for the model, while long-term memory consists of important facts, moments, preferences, and relationship details.\n\nThese memories are stored in SQLite, a local database, ensuring the app functions without a hosted database. Each character has their own data, so one character's memories do not inadvertently merge with another's. For each memory, the text itself, along with metadata like character association, creation time, importance, emotional weight, usage frequency, and vector embedding, is stored. The vector embedding enables semantic search, allowing the app to find related memories even if they don't share exact keywords.\n\nWhen recalling memories, similarity alone isn't enough. Recent memories and those with higher emotional weight or previous usefulness should be given more consideration. The memory system extracts a small knowledge graph, representing relationships and entities, which aids in answering structural questions. However, the memory system must include an escape hatch for users to inspect or remove stored data, preventing the companion from feeling intrusive or \"monitoring.\" Ensuring the embedding model is downloaded correctly during setup prevents silent memory loss, a common issue that can undermine the user's experience.",
  "summary": "A chatbot can sound convincing for five minutes without remembering anything. Then you mention the job interview you were stressed about last week, the name of your dog, or a small detail from a late-night conversation. It replies like none of it happened. That is where most \"AI companion\" demos fall apart. I am building Local Waifu , a desktop AI companion that runs on the user's own Mac or PC.…",
  "key_points": [
    "Chat history and long-term memory separated for efficiency",
    "SQLite database stores memories per character without merging",
    "Vector embeddings enable semantic search for related memories"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}