Long-Term Memory
Long-term memory gives Digital Employees the ability to retain information across sessions—what you tell it today, it remembers when you ask again next week. This is one of the core capabilities that distinguishes Digital Employees from standard agents.
How Memory Works
The fundamental principle of long-term memory is extracting key information from conversations as structured memory entries and storing them in a vector database. When a user initiates a new conversation, the system retrieves the most relevant historical memories based on the current query and provides them to the LLM as part of the context.
This process has two phases:
Real-Time Memory Extraction
During conversations, the LLM automatically identifies information worth recording. Extracted memories are classified into four types:
- Fact: Objective background information about the user—occupation, location, family status, etc. Note that facts record only objective information with no subjective commentary. For example, "the user works in Shanghai" is a fact, while "the user thinks Shanghai is great" is a preference.
- Preference: Stable tendencies—work style, communication preferences, hobbies, thinking patterns, etc. The key distinguishing criterion is stability: long-formed habits are preferences; one-time requests are not.
- Constraint: Hard behavioral boundaries set by the user—"don't do X", "absolutely never Y", "must Z". Unlike one-time instructions, constraints are red lines that remain effective across conversations.
- Skills: Demonstrated or self-reported abilities—tech stack, language proficiency, domain expertise, etc.
This classification is not arbitrary. During retrieval, different memory types carry different weights and processing logic. Constraint-type memories have the highest priority because they directly affect security and compliance.
Memory Retrieval
When a user initiates a new conversation, the system vectorizes the current query and searches for the most relevant historical memories in memory vector space. This process depends on two key models:
- Embedding Model: Responsible for converting memory content into vector representations. A high-quality embedding model captures the deep semantics of memory entries.
- Rerank Model: Performs secondary precision ranking on candidate memories returned by the embedding model, filtering noise and ensuring the most relevant memories appear at the top.
This two-stage retrieval architecture (embedding coarse filtering + rerank precision ranking) significantly improves memory recall relevance.
The Dream System: Offline Memory Consolidation
Memory extracted during real-time conversations has an inherent problem: conversations are fragmented. A user might mention in the morning "I'm preparing the Q3 financial report" and in the afternoon "that PPT needs another page of data"—both pieces are valid memories individually, but only together do they form complete understanding. More problematically, as conversations accumulate, the memory base gradually develops redundant entries, outdated information, and even contradictory items.
The Dream System is designed to solve this problem.
Design Philosophy
The name "Dream System" draws from cognitive science's memory consolidation theory: during sleep, the human brain sorts, filters, and integrates the day's experiences, converting short-term memories into long-term memories, discarding irrelevant information, and strengthening important associations.
In the AI Agent field, similar design philosophies have become a consensus. Claude's memory system employs periodic background consolidation strategies. MemGPT proposed the concept of "self-editing memory", allowing agents to proactively review and optimize their memory base during idle time. The core idea across these approaches is consistent: real-time memory is the most basic record; offline consolidation produces high-quality knowledge.
What distinguishes the Dream System is that it is not a simple "re-organization", but a two-stage AI processing pipeline—extraction first, then consolidation, with the LLM deeply involved at each stage.
Stage One: Memory Extraction
Every early morning, the Dream System reviews all of that day's conversations between the user and the Digital Employee. Unlike real-time extraction, the Dream System has two unique advantages:
No conversational pressure. During real-time extraction, the AI's primary task is answering questions, with memory extraction as a secondary function. The Dream System can examine each conversation segment methodically, calmly judging whether information has long-term value.
The Longevity Test. During extraction, the Dream System follows a core principle: before extracting, ask "will this information still be useful a month from now?" If the answer is no—for example, the user saying "I'm feeling a bit down today", which is a transient emotion—it is not extracted. This principle ensures the memory base retains only information with cross-temporal value, avoiding noise from casual daily chat.
During extraction, the system also follows several key rules:
- Better to miss than to over-extract: When unsure whether to extract, don't. Missing one piece of information can be corrected next time, but extracting incorrect information continuously contaminates subsequent conversations.
- One idea per memory: Each memory expresses exactly one complete, independent information point. "The user is a frontend engineer" and "the user has a cat" are kept as separate memories, even if they belong to the same category.
- De-subjectivize facts: For fact-type memories, subjective commentary is strictly excluded. If the information found is "the user thinks Beijing is great", it should be classified as preference, not fact.
Stage Two: Memory Consolidation
After extraction completes, the newly obtained memory fragments must be integrated with the existing memory base. This is not a simple "append new memories after old ones"—it is a deep fusion process.
The consolidation stage handles three types of operations:
Add: When new information is unrelated to all existing memories, a brand new memory is created. For example, the user mentions "I'm learning Rust" for the first time, and the memory base has nothing about Rust or programming languages.
Update: When new information relates to an existing memory, they are fused into a more complete single memory. For example, if the existing memory is "the user likes coffee" and new information is "the user drinks a latte every morning"—the fused result becomes "the user likes coffee, especially lattes, and drinks one every morning."
The most elegant aspect of this stage: it doesn't just check new information against old memories—it proactively checks whether existing memories themselves are redundant. Even without new information triggering it, the system will discover that "the user is good at Python" and "the user excels at Python backend development" are clearly duplicative—and fuse them into one entry, deleting the redundant one. This "self-auditing" mechanism prevents the memory base from bloating over time.
Delete: When a memory's information has been fully absorbed into another memory, the original entry becomes redundant and the system removes it.
Conflict Resolution: When new information contradicts old memories—for example, the user previously said "works in Shanghai" but recent conversations mention "moved to Beijing"—the system takes the latest information as authoritative and updates the memory content. This ensures the memory base always reflects the user's current state.
Why Two-Stage Design
Separating extraction and consolidation into two stages rather than one is a deliberate design choice:
- If a single prompt tried to simultaneously "judge what's worth remembering" and "how to integrate into existing memories", the AI would struggle to do both well. Separated, each stage focuses on one goal, dramatically improving accuracy.
- A quality checkpoint can be inserted between stages. If the extraction stage produces clearly unreasonable information, the consolidation stage can reject it.
- Extraction is an information filtering problem (what's worth remembering); consolidation is a knowledge orchestration problem (how to organize existing knowledge). These are two different cognitive tasks, and separate processing better aligns with AI capabilities.
| Real-Time Extraction | Dream Extraction | Dream Consolidation | |
|---|---|---|---|
| Timing | During conversation | Off-peak hours | After extraction |
| Goal | Quickly record key info | Filter for valuable long-term info | Dedup, merge, conflict resolution |
| Unique Rules | Immediate response | Longevity test, better-to-miss | Proactive self-audit of existing redundancy |
| Cost | Shared conversation context | Independent context window | Independent context window |
Simply put: real-time extraction ensures "not forgetting"; dream extraction ensures "remembering correctly"; dream consolidation ensures "remembering well".
Memory Isolation
Digital Employee long-term memory is isolated per user. Each user has a completely independent memory space and cannot access other users' memories. This is achieved through the vector database's partition key mechanism—each Agent-User pair has an independent partition.
This design guarantees:
- Private information User A tells the Digital Employee will never leak to User B
- The same Digital Employee can serve different users without memory confusion
- A specific user's entire memory can be individually deleted for compliance requirements
Managing Memory
Viewing User Memory
The memory management page first displays a list of all users who have had conversations, including each user's total memory count and last update time. Click into a user's detail page to view all their memory entries.
Each memory entry displays: content, category, and creation time. The user's conversation history with the Digital Employee is also shown, making it easy to understand the source of memories in context.
Editing Memory
Memory entries support manual editing. You can modify both content and category. Manually edited memories are marked as "edited" status and will not be overwritten by subsequent automatic extraction or dream consolidation.
Deleting Memory
Two granularities of deletion are supported:
- Delete individual memory entries: For correcting erroneous or inaccurate memories
- Delete all user memory: For employee departure or data cleanup scenarios
Note: Deletion is irreversible. It is recommended to export a backup first in production environments.
Enabling and Configuration
Long-term memory must be manually enabled on the Digital Employee's memory page. When enabling, configure:
- Embedding Model: Determines semantic retrieval quality of memories. For Chinese-language scenarios, choose models optimized for Chinese semantics.
- Rerank Model: Determines the precision ranking quality of retrieval results.
- Dream System Toggle: Determines whether offline memory consolidation is enabled. Recommended for scenarios where:
- The Digital Employee serves users frequently, generating many conversations daily
- A high-quality, low-redundancy memory base is needed
- Users expect the Digital Employee to form long-term, coherent understanding
Model configuration should not be changed casually after saving—switching models causes already-vectorized memory entries to require re-vectorization.