Backfill Memory Chunks (Chunk Store)
Last Updated: 2026-02-06
Content-Type: How-to
Audience: Developers, Operators
Overview
If you imported a lot of chat history or changed embedding providers, you should rebuild memory_chunks so chunk retrieval works well.
Prerequisites
DATABASE_URLconfigured- Embeddings configured and working:
EMBEDDING_PROVIDER=oneapi(orgemini)ONE_API_URL/ONE_API_KEY(ifoneapi)VECTOR_DIMmatches your DB vector columns (default 1536)
Run the Backfill
Basic:
bash
ts-node backend/scripts/backfill-memory-chunks.ts --userId 27 --source conversationResumable (recommended for large datasets):
bash
ts-node backend/scripts/backfill-memory-chunks.ts --userId 27 --source conversation --batchSize 50 --checkpoint ./chunk_backfill_27.jsonResume after interruption:
bash
ts-node backend/scripts/backfill-memory-chunks.ts --userId 27 --source conversation --checkpoint ./chunk_backfill_27.jsonDry-run estimation:
bash
ts-node backend/scripts/backfill-memory-chunks.ts --userId 27 --source conversation --dry-runWhat it does
- Iterates user memories in batches
- Chunks each memory and writes rows to
memory_chunks - Generates embeddings for each chunk (fails fast if embeddings are not working)