Skip to content

Memory System

Location: cogs/memory/

The Memory System is a sophisticated, persistent long-term memory feature for the bot. It automatically captures, processes, and indexes conversations, enabling the bot to recall past interactions with high relevance and context.

Core Components

The system is built upon several key, interconnected components:

Data Flow: Storing a Message

  1. A new message is sent in a channel where the memory system is active.
  2. The Memory Manager receives the message.
  3. The message content and metadata are saved to the Database.
  4. The message is passed to the Segmentation Service, which determines if the message concludes a conversational segment.
  5. Once a segment is complete, its content is sent to the Embedding Service to be converted into a vector.
  6. The resulting vector is stored in a specialized index file by the Vector Manager.

Data Flow: Recalling a Memory

  1. The bot needs to recall a memory (e.g., to answer a question).
  2. A query is sent to the Memory Manager's search_memory method.
  3. The Search Engine uses the Embedding Service to convert the query into a vector.
  4. The Vector Manager finds the most similar conversation segment vectors.
  5. The Database retrieves the corresponding text messages for those segments.
  6. The Structured Context Builder formats the retrieved messages and user data into a clean block of text.
  7. This final context is provided to the LLM to inform its response.