ADR: Preserve Original Memories During Chunking
*Status: Accepted – 2025-01-27*
ADR: Preserve Original Memories During Chunking
Status: Accepted – 2025-01-27
Context
The current chunking implementation has a critical design flaw: it destroys the original memory content by replacing it with an LLM-generated summary. This violates the principle of data preservation and creates potential information loss.
Current Problematic Flow
- User stores large memory content
- Chunking system analyzes content and generates summary + chunks
- Original memory content is replaced with summary (data loss!)
- Container and chunk memories are created with complex relationships
- Original detailed content is permanently lost
Problems with Current Approach
- Data Loss: Original complete content is destroyed and cannot be recovered
- Violates ADR Principles: The plain-text memory column ADR established that chunking should "rely on" the text column, not modify it
- User Trust: Users lose confidence when their original content disappears
- Debugging Difficulty: Cannot compare chunks back to original source
- Relationship Complexity: Creates confusing "container" memories that serve no clear purpose
Decision
Preserve original memories completely unchanged during chunking. Instead of modifying the original memory:
- Keep Original Memory Intact: Never modify the original memory's content, type, or core properties
- Create Summary Memory (Optional): If LLM generates a useful summary, store it as a separate memory with
type: "{original-type}-summary" - Create Chunk Memories: Store each chunk as separate memories with
type: "{original-type}-chunk" - Use Clear Relationships: Establish bidirectional relationships for discoverability
New Relationship Structure
Original Memory (unchanged)
├── summarizes ← Summary Memory (optional)
├── chunk-of ← Chunk Memory 1
├── chunk-of ← Chunk Memory 2
└── chunk-of ← Chunk Memory N
Summary Memory
└── summarizes → Original Memory
Each Chunk Memory
├── chunk-of → Original Memory
└── part-of-sequence → Next/Previous Chunks (optional)
Implementation Changes
- Remove
UpdateMemorycall from chunking process - Add optional summary creation with proper relationship
- Simplify relationship structure - no "container" memory needed
- Update chunk type naming to be more descriptive
- Preserve all original metadata (tags, confidence, etc.)
Consequences
Positive
- Zero Data Loss: Original content always preserved and accessible
- Clear Semantics: Relationships clearly indicate purpose (summarizes, chunk-of)
- Better Debugging: Can always trace chunks back to original
- User Trust: Users' content is never modified unexpectedly
- Simpler Architecture: No confusing "container" memories
Considerations
- More Storage: Keeps original + summary + chunks (acceptable trade-off)
- Relationship Updates: Need to update relationship queries in UI
- Migration: Existing chunked memories may need data recovery
Breaking Changes
ChunkingCompletedevent no longer includesContainerMemoryId- Chunked memories will have different relationship patterns
- Tests expecting content replacement will need updates
Implementation Plan
- Update
ChunkingQueue.PerformChunking()to preserve original - Add optional summary memory creation
- Update relationship creation logic
- Update tests to expect preservation behavior
- Update UI to handle new relationship patterns
- Consider migration strategy for existing chunked memories
Related Documents
基于命题分块以增强RAG
命题分块技术(Proposition Chunking)——这是一种通过将文档分解为原子级事实陈述来实现更精准检索的先进方法。与传统仅按字符数分割文本的分块方式不同,命题分块能保持单个事实的语义完整性。
TileMap Chunk Manager
**Category:** Performance - 2D Rendering & Memory Management
🤖 n8n AI Agent Mastery Course 2025
Welcome to the most comprehensive n8n AI Agent course! Build powerful automation workflows and intelligent AI agents using n8n's visual workflow builder.
How to recursively split text by characters
keywords: [recursivecharactertextsplitter]