ADR: Preserve Original Memories During Chunking
Decides to keep original memory content unchanged during chunking, storing summaries and chunks as separate linked memories.
What this file does
Decides to keep original memory content unchanged during chunking, storing summaries and chunks as separate linked memories.
When to use it
- Designing a chunking system that must preserve original user content
- Reviewing an existing chunking implementation that overwrites source data
- Planning relationship models for chunked memory storage
- Evaluating trade-offs between storage cost and data integrity
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
What's inside
Context, decision, relationship diagram, implementation changes, consequences, and a 6-step implementation plan.
Change this for your project
- Replace
ChunkingQueue.PerformChunking()with your own chunking method name - Replace
ChunkingCompletedevent with your own event class name - Replace
ContainerMemoryIdwith your own container identifier property
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Use separate memory types like
-summaryand-chunksuffixes to avoid modifying originals - Model bidirectional relationships (
summarizes,chunk-of) for traceability
Related Documents
基于命题分块以增强RAG
Implements proposition chunking for RAG: decomposes documents into atomic facts, evaluates quality, and compares retrieval against standard chunking.
TileMap Chunk Manager
Divides a large tilemap into fixed-size chunks, loading and rendering only those visible to reduce memory and draw calls by over 99%.
Message Chunking for MCP stdio Transport
Explains macOS 64KB pipe write limit and provides a chunking layer for MCP stdio transport that splits and reassembles large messages transparently.
🤖 n8n AI Agent Mastery Course 2025
Serves as the main README for an n8n course repository, listing 10+ AI agent workflow projects with links to YouTube tutorials and Docker setup instructions.