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:
| Field | Description |
|---|---|
| Category | User preference / Learned rule / Important event / Knowledge base |
| Content | The actual content of the memory |
| Importance | Score from 1-10, affects injection priority |
| Source | Manual / Auto-extracted / System-generated |
| Scope | Visibility range of the memory (see below) |
Memory Categories
| Category | Purpose | Example |
|---|---|---|
| User preference | User habits and preferences | ”User prefers concise response style” |
| Learned rule | Rules derived from interactions | ”Must run tests before deploying” |
| Important event | Key events that have occurred | ”2024-01-15: A database migration failure occurred in production” |
| Knowledge base | Domain knowledge | ”Project uses PostgreSQL 15, deployed on GCP” |
Memory Scopes
Memories are organized by scope, which determines when they are visible to the Bot:
| Scope | Visibility | Typical Use Case |
|---|---|---|
| Global | All Bot conversations and tasks | General preferences, project knowledge |
| Channel | Conversations in a specific IM channel | Context information for a particular Slack channel |
| Task | During a specific task execution | Temporary task-related information |
| Resource | Scenarios bound to a specific Resource | Operational knowledge for a specific server |
| Schedule | When a specific scheduled task fires | Format preferences for scheduled reports |
| Workflow | During a specific Workflow execution | Notes 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
- In the Memory tab, click Add Entry
- Select a category
- Enter the content
- Set the importance score (1-10)
- 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
- The platform sends the conversation history and current memories to the LLM
- The LLM analyzes the conversation and outputs structured memory entries (category + content + importance)
- The platform atomically replaces all
source=automemory entries within the relevant scope
Note: Automatic extraction only replaces
source=autoentries. 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:
- Higher importance memories are injected first
- 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:
| Layer | Content | Load Timing |
|---|---|---|
| Base layer | Global memories + current scope memories | On session creation |
| Resource layer | Memories related to bound Resources | After tool resolution |
| Injection layer | Cross-scope memories dynamically loaded at runtime | When 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):
| Tool | Description |
|---|---|
memory_write | Write new memories or update existing ones |
memory_delete | Delete memory entries |
memory_load_context | Dynamically load memories from other scopes (read-only) |
memory_unload_context | Unload 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.