Persistent Memory
Persistent Memory
Section titled “Persistent Memory”LingXiao has a two-layer memory architecture: long-term memory (FTS5 + BM25 full-text search engine) and short-term skill injection (execution knowledge injected at Worker dispatch time). Together they form a complete memory system.
Long-Term Memory
Section titled “Long-Term Memory”Full-Text Search Engine
Section titled “Full-Text Search Engine”Based on SQLite FTS5 + BM25 ranking:
- FTS5: SQLite full-text search extension with Chinese tokenization support
- BM25: Probabilistic relevance ranking algorithm, sorts by keyword match score
- Search interface:
memory(action="search", query="keywords")
4 Memory Types
Section titled “4 Memory Types”| Type | Identifier | Description |
|---|---|---|
| User preferences | user | User’s coding style, tech preferences, work habits |
| Feedback guidelines | feedback | Agent working principles, best practices, lessons learned |
| Project knowledge | project | Project architecture, tech stack, key decisions, module relationships |
| External references | reference | Documentation links, API references, tool usage |
Storage Locations
Section titled “Storage Locations”| Scope | Path | Description |
|---|---|---|
| Project-level | .lingxiao/memory/ | Project-specific memory, travels with the project |
| User-level | ~/.lingxiao/memory/ | Global user memory, shared across projects |
Memory Operations
Section titled “Memory Operations”// Save memorymemory(action="save", name="user-preferences", type="user", description="User preferences", content="Prefers React + TypeScript...")
// Search memorymemory(action="search", query="frontend framework preferences")
// Load specific memorymemory(action="load", name="user-preferences")
// List all memoriesmemory(action="list", scope="project")
// Delete memorymemory(action="delete", name="outdated-memory")Auto Distillation (Distill)
Section titled “Auto Distillation (Distill)”DistillCommand automatically distills valuable memories from session history:
- Scans completed sessions
- Identifies reusable knowledge, patterns, and lessons
- Auto-categorizes into 4 memory types
- Deduplicates before saving to the long-term memory store
Associative Memory (Dream)
Section titled “Associative Memory (Dream)”DreamCommand performs associative memory maintenance during idle time:
- Discovers implicit associations between memories
- Merges duplicate or similar memory entries
- Updates status markers for outdated memories
- Optimizes search index performance
Maintenance Pipeline
Section titled “Maintenance Pipeline”The memory system has an automatic maintenance pipeline:
- Index rebuild:
memory(action="rebuild")rebuilds FTS5 index - Expiry cleanup: Automatically marks and cleans expired memories
- Relationship updates: Cross-references between memories are auto-maintained
- Capacity control: Project-level and user-level memory capacity monitoring
Short-Term Skill Injection
Section titled “Short-Term Skill Injection”At Worker dispatch time, the Leader injects relevant Skill content into the Worker’s prompt based on task type and role bindings:
- Skill source priority: Project-level > Plugin-contributed > User-level > Built-in
- Only Skill phases relevant to the current task are injected
- Skill content serves as execution knowledge guiding the Worker’s workflow
This complements long-term memory: long-term memory provides cross-session knowledge accumulation, while short-term skill injection provides execution guidance for the current task.