Memory System

Prerequisites: Before reading this guide, we recommend familiarizing yourself with the memory system section in Core Concepts.

Monstrum provides a partitioned memory system for each Bot, allowing Bots to retain important information across multiple conversations. Memories can be added manually or extracted automatically by the LLM.


Overview

Bot memory addresses a fundamental limitation: LLMs have no persistent memory across sessions. Each time a new session begins, the Bot’s context starts empty. The memory system enables Bots to remember user preferences, learned rules, important events, and domain knowledge.

Memories are stored as entries in a database (not files). Each memory entry has a category, content, importance score, and scope. When a session or task begins, the platform automatically injects relevant memories into the system prompt.


Memory Entries

Each memory entry contains the following information:

FieldDescription
CategoryUser preference / Learned rule / Important event / Knowledge base
ContentThe actual content of the memory
ImportanceScore from 1-10, affects injection priority
SourceManual / Auto-extracted / System-generated
ScopeVisibility range of the memory (see below)

Memory Categories

CategoryPurposeExample
User preferenceUser habits and preferences”User prefers concise response style”
Learned ruleRules derived from interactions”Must run tests before deploying”
Important eventKey events that have occurred”2024-01-15: A database migration failure occurred in production”
Knowledge baseDomain knowledge”Project uses PostgreSQL 15, deployed on GCP”

Memory Scopes

Memories are organized by scope, which determines when they are visible to the Bot:

ScopeVisibilityTypical Use Case
GlobalAll Bot conversations and tasksGeneral preferences, project knowledge
ChannelConversations in a specific IM channelContext information for a particular Slack channel
TaskDuring a specific task executionTemporary task-related information
ResourceScenarios bound to a specific ResourceOperational knowledge for a specific server
ScheduleWhen a specific scheduled task firesFormat preferences for scheduled reports
WorkflowDuring a specific Workflow executionNotes for Workflow steps

Global memories are always injected. Memories in other scopes are only injected in their corresponding scenarios.


Manual Memory Management

Viewing Memories

Navigate to the Bot detail page and select the Memory tab to view all memory entries for the Bot.

Features include:

  • Keyword search
  • Filter by category
  • View memory source (manual / auto)

Adding Memories

  1. In the Memory tab, click Add Entry
  2. Select a category
  3. Enter the content
  4. Set the importance score (1-10)
  5. Save

Manually added memories are tagged as source=user and will not be overwritten by automatic extraction.

Editing Memories

Click the edit button on a memory entry to modify its content, category, or importance.

Deleting Memories

Click the delete button on a memory entry. This action is irreversible.

Clearing All Memories

Click the Clear button to remove all memories for the Bot. This action is irreversible.


Automatic Memory Extraction

When automatic memory extraction is enabled in the Bot’s runtime configuration (under the Bot Settings tab), the platform automatically extracts memories at these points:

  • On task completion: Analyzes the task’s conversation content to extract important information
  • On session expiration: Analyzes the entire session’s conversation content to extract important information

Extraction Process

  1. The platform sends the conversation history and current memories to the LLM
  2. The LLM analyzes the conversation and outputs structured memory entries (category + content + importance)
  3. The platform atomically replaces all source=auto memory entries within the relevant scope

Note: Automatic extraction only replaces source=auto entries. Manually added memories (source=user) are never overwritten.

Extraction Quality

The quality of automatic extraction depends on:

  • The LLM’s comprehension ability
  • The information density of the conversation
  • The extraction prompt configuration (customizable in Prompt Templates)

Memory Injection

When a session or task begins, the platform automatically injects relevant memories into the ## Bot Memories section of the system prompt.

Injection Priority

Memories are injected in the following order:

  1. Higher importance memories are injected first
  2. Among memories with equal importance, more recently updated memories take priority

Token Budget

If the total memory volume exceeds the token budget, lower-priority memories are evicted. The platform uses recency decay scoring to determine eviction order — the longer a memory has gone without updates, the lower its score.

Three-Layer Cache

In session mode, memories are managed through a three-layer cache:

LayerContentLoad Timing
Base layerGlobal memories + current scope memoriesOn session creation
Resource layerMemories related to bound ResourcesAfter tool resolution
Injection layerCross-scope memories dynamically loaded at runtimeWhen the Bot invokes the memory load tool

During a conversation, the Bot can use the memory load/unload tools to dynamically access memories from other scopes (read-only) without restarting the session.


Bot Memory Tools

When automatic memory is enabled, the Bot can use the following built-in capability tools during conversations (no Resource binding required):

ToolDescription
memory_writeWrite new memories or update existing ones
memory_deleteDelete memory entries
memory_load_contextDynamically load memories from other scopes (read-only)
memory_unload_contextUnload previously loaded scope memories

These tools bypass permission checks as they are Bot-owned capability tools — the data belongs to the Bot itself.


Common Use Cases

Remembering User Preferences

Tell the Bot your preferences during a conversation (e.g., “Reply in Chinese from now on”). If automatic memory is enabled, the Bot will automatically extract this preference when the session expires. You can also add it manually in the Memory tab.

Pre-loading Knowledge

Before deploying a Bot, manually add project-related knowledge entries:

  • Project architecture information
  • Common commands and operational procedures
  • Team conventions and standards

Per-Channel Memories

When the same Bot is connected to multiple IM channels, each channel accumulates independent memories. For example, operational knowledge from the #ops channel will not pollute development knowledge in the #dev channel.


FAQ

Too many memories making the prompt too long

The memory system has a token budget limit and automatically evicts lower-priority memories. You can also manually delete memory entries that are no longer needed.

Auto-extracted memories are low quality

  • Check the memory extraction prompt configuration (customizable in Prompt Templates)
  • For important information, consider adding it manually rather than relying on automatic extraction

My manually added memories were overwritten

They were not. Automatic extraction only replaces source=auto entries. Manually added memories (source=user) are always preserved.