Three-Dimensional Memory System
Overview
The workspace memory system adopts a three-dimensional architecture, storing and managing knowledge across three dimensions: account, enterprise, and session. Memory is deeply integrated with conversation — every conversation queries relevant memories to inject into the context, and new memories are automatically extracted after each interaction turn.
Technical foundation: mem0 REST API + Neo4j knowledge graph.
Three-Dimensional Architecture
| Dimension | Scope | Write Method | Management Permission | Conversation Injection |
|---|---|---|---|---|
| Account level | userId (cross-organization) | Manual addition + automatic extraction from conversation | Self-managed by user | "User Profile" injected into system prompt |
| Enterprise level | orgId (organization isolation) | Manually maintained by administrators | Workspace administrators only | "Enterprise Profile" injected into system prompt |
| Session level | runId (single session) | Automatic extraction each turn | Automatically managed | Semantic query within the session |
Account-Level Memory
- Cross-organization sharing: Bound to userId, available across all of the user's organizations
- Write methods:
- Manual: Add via commands in the memory management interface or in conversation
- Automatic: Automatically detects information worth remembering during conversation
- Management interface: APP Settings → Memory
- Detailed documentation: Memory Management
Enterprise-Level Memory
- Organization isolation: Bound to orgId, visible only to members of the current organization
- Management permission: Only workspace administrators can maintain it
- Management interface: Workspace Management → Advanced Settings → Enterprise Memory
- Detailed documentation: Advanced Settings — Enterprise Memory
Session-Level Memory
- Single session: Bound to runId, valid only within the current session
- Per-turn extraction: Automatically analyzes and extracts memory after each conversation turn
- No management needed: The system handles it automatically
Memory Extraction Mechanism
Explicit Commands (Confidence 0.99)
The user directly asks the Agent to remember or forget information:
| Operation | Trigger Keywords |
|---|---|
| Add memory | "记住", "记下", "保存记忆", "保存到记忆", "remember", "store in memory" |
| Delete memory | "删除记忆", "忘掉", "忘记", "forget this", "remove from memory" |
Implicit Detection (Confidence 0.5-0.93)
The system automatically detects persistent facts in conversation via regex patterns:
| Signal Type | Example | Confidence |
|---|---|---|
| Personal profile | "我叫张三", "我是前端开发", "my name is" | 0.93 |
| Personal possession | "我有一只猫", "我养了", "I own" | 0.90 |
| Personal preference | "我喜欢用 TypeScript", "I prefer" | 0.88 |
| Assistant style | "以后请用中文回复", "always use", "response format preference" | 0.86 |
Confidence Thresholds
| Mode | Threshold | Description |
|---|---|---|
| strict | 0.85 | Conservative mode, extracts only high-confidence memories |
| standard (default) | 0.65 | Balanced mode |
| relaxed | 0.50 | Aggressive mode, more content is remembered |
Automatic Exclusion Rules
The following content will not be extracted as memory:
- Pure questions (ending with a question mark, starting with an interrogative word)
- Small talk / greetings
- Content within code blocks
- Time-sensitive / time-bound information (dates, news, temporary states)
- Non-persistent topics (bug reports, error messages)
Knowledge Graph
Backend Storage (Neo4j)
Memory relationships are stored in the Neo4j graph database as triples:
(source entity) --[relationship]--> (target entity)
N-hop neighborhood query (1-4 hops):
MATCH path = (n {name: $entity})-[*1..depth]-(m)
WHERE ALL(node IN nodes(path) WHERE node.user_id = $user_id)
UNWIND relationships(path) AS rel
RETURN source, relationship, target
The Cypher query guarantees it never crosses user boundaries.
Frontend Visualization
Uses react-force-graph-2d to render a force-directed graph:
| Node Type | Color | Description |
|---|---|---|
| Hub | Purple #6d28d9 |
User / organization central node |
| Fact | Blue #2563eb |
Memory entry |
| Entity | Amber #f59e0b (default) |
Extracted entity; the specific color is mapped by a djb2 hash to a 10-color palette |
Graph Rendering Optimization (2026-04 Update) NEW
The new graph introduces two density gate thresholds to prevent label overlap caused by too many nodes:
| Threshold Constant | Value | Meaning |
|---|---|---|
PILL_READABILITY_MIN_SCALE |
1.5 | No text labels are rendered when zoom is below 1.5x |
PILL_MIN_SCREEN_AREA_PER_NODE |
3000 | No labels are rendered when the screen area per node is below 3000 pixels |
Labels are shown only when both conditions are met. When they are not met, only dots are rendered.
Entity Type Color Stabilization:
- Computes entity type → color index via a
djb2hash - Entities of the same type keep the same color across different views and different times
- The 10-color palette supports cyclic reuse for an unlimited number of types
Bug Fix: When mapping graph relationships, the sourceTypes / targetTypes fields were previously dropped, causing all nodes to fall back to the gray fallback color. This bug has been fixed (see sidecar/src/mem0Service.ts).
Multi-Level Drill-Down
Clicking a node expands its associated entities, drilling deeper into the knowledge network layer by layer. The graph engine supports:
neighborhood()— N-hop neighborhood queryshortestPath()— Shortest path between two entitiesextractEntitiesFromText()— Extract entity names from text
Synergy Between Memory and Conversation
Memory Query Timing
| Timing | Action |
|---|---|
| New conversation | Query account profile memory + enterprise profile memory, and concatenate them into the system prompt |
| User sends a message | The memory_query tool semantically retrieves relevant memories |
| Graph expansion | searchWithGraphExpansion — semantic retrieval + 1-hop graph expansion, returning relevant entities and edges |
Memory Injection Location
Two memory profiles are injected into the system prompt:
你是 GPTBots AI 助手...
## 用户概况
- 用户是前端开发工程师
- 偏好使用 TypeScript
- ...
## 企业概况
- 公司使用 React 技术栈
- 项目代号 Project Alpha
- ...
Memory Tools
The Agent can proactively query and manage memory through the following tools:
| Tool | Operations | Description |
|---|---|---|
| memory_query | list / search / graph_traverse | List, semantic search, graph traversal |
| memory_manage | add / update / delete | Add, modify, delete memory |
| conversation_search | search | Search historical conversations |
| recent_chats | list | List recent conversations |
Cross-Account Gateway Isolation NEW
When a node is invoked cross-account with enterprise scope:
- Account-level memory (userId-bound): ❌ Not accessible
- Enterprise-level memory (orgId-bound): ✅ Accessible
- Session-level memory (within this session): ✅ Accessible
Filtering is enforced during the mem0Service query phase via the isRemoteSession flag — a cross-account invocation cannot read the personal memory of the target node's owner.
Design purpose: Protect personal privacy while not affecting the collaborative sharing of organization-level knowledge. See Multi-Node Architecture for details.
mem0 Capabilities
The memory backend, based on mem0, provides the following automated capabilities:
| Capability | Description |
|---|---|
| Automatic update | New information overrides old information (e.g., "I like Python" → "I like TypeScript") |
| Automatic merge | Similar memories are merged into a more complete entry |
| Automatic forgetting | Contradictory information automatically cleans up the old version |
Timeout Protection
| Operation | Timeout |
|---|---|
| Memory query / management | 25 seconds |
| Session-level memory operations | 5 seconds (fast timeout, does not block the conversation) |
| Graph relationship retrieval | 3 seconds (gracefully degrades after timeout) |
What This Means for You
The memory system enables the Agent to "know you". Without memory, the Agent is like a stranger meeting you for the first time in every conversation; with memory, the Agent knows your preferences, project background, and work habits.
How the three dimensions manifest in practice:
- Account memory: "You said you like TypeScript" → the Agent prioritizes TypeScript in conversations across all organizations
- Enterprise memory: An administrator added "The company uses a PostgreSQL database" → when any member of the organization discusses databases with the Agent, the Agent recommends the PostgreSQL solution by default
- Session memory: You said "The current project is called Project Alpha" in this conversation → the Agent remembers it in this conversation, but not necessarily in a new one
You can manage memory in the following ways:
- For personal preferences: Say "记住 I prefer the dark theme" in conversation, or add it manually in APP Settings → Memory
- For enterprise knowledge: Contact an administrator to add it in Workspace Management → Advanced Settings → Enterprise Memory
- If you find a memory is incorrect: Say "忘掉 the previous preference about Python" in conversation, or delete it directly in memory management
- To view existing memories: APP Settings → Memory, where you can browse the list and the graph
Related Documentation
- Memory Management — Memory management interface on the APP side
- Advanced Settings — Enterprise Memory — Enterprise-level memory management
- Tool Management — Memory-related tools (memory_query, memory_manage)
- Multi-Node Architecture — Cross-account Gateway isolation mechanism
