Skip to content

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_URL configured
  • Embeddings configured and working:
    • EMBEDDING_PROVIDER=oneapi (or gemini)
    • ONE_API_URL / ONE_API_KEY (if oneapi)
    • VECTOR_DIM matches your DB vector columns (default 1536)

Run the Backfill

Basic:

bash
ts-node backend/scripts/backfill-memory-chunks.ts --userId 27 --source conversation

Resumable (recommended for large datasets):

bash
ts-node backend/scripts/backfill-memory-chunks.ts --userId 27 --source conversation --batchSize 50 --checkpoint ./chunk_backfill_27.json

Resume after interruption:

bash
ts-node backend/scripts/backfill-memory-chunks.ts --userId 27 --source conversation --checkpoint ./chunk_backfill_27.json

Dry-run estimation:

bash
ts-node backend/scripts/backfill-memory-chunks.ts --userId 27 --source conversation --dry-run

What 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)

ASO Universal Consciousness System Documentation