Engineering

Zero-downtime memory re-indexing: blue/green for local vector indices

How Kiomon swaps vector models in-process without dropping a single query.

In a production AI agent infrastructure, memory is not static. Knowledge bases constantly evolve as new documentation is captured, obsolete rules are updated, and embedding models or tokenizers are upgraded.

Performing re-indexing across millions of memory records without interrupting live agent queries requires a dual-state, zero-downtime re-indexing architecture.

Live Queries Continuous MCP Active Index (v1) Serving 100% of Agent Traffic Read-Through Cached Atomic Pointer Re-Index Job Async Shadow Shadow Index (v2) Background Ingestion & Embed Zero Traffic Impact Agent Zero Stall

The Problem with In-Place Index Modification

When re-indexing a live knowledge base in place, traditional systems suffer from several critical vulnerabilities:

  1. Partial State Inconsistency: As records are re-chunked and re-embedded, search queries return a mix of old and new data representations.
  2. Lock Contention & Query Stalls: Bulk writes to full-text search tables or vector indices degrade read latency, causing agent timeouts.
  3. Rollback Friction: If a re-indexing task fails halfway through a large migration, restoring the previous search state requires restoring complete database backups.

The Dual-State Re-Indexing Pattern

To guarantee uninterrupted agent workflows, the re-indexing engine employs a shadow-swap pattern:

Active Read Path:   Agent Queries ──> [ Active Index (v1) ]

                                             │ (Atomic Pointer Swap)

Background Worker:  Re-Index Job  ──> [ Shadow Index (v2) ]

1. Isolated Shadow Build

When a re-indexing operation is initiated, worker tasks construct a secondary index structure asynchronously. Live agent queries continue accessing the primary index with zero resource contention.

2. Idempotent Delta Catch-Up

While the shadow index is building, newly captured notes and memory updates are applied to both the active and shadow stores, ensuring the shadow index is fully up to date upon completion.

3. Atomic Pointer Swap

Once validation tests confirm that the shadow index is complete and verified, the routing pointer switches atomically to the new index version.

4. Background Teardown

The previous index version is retired cleanly after all in-flight read operations resolve, completing the migration with zero downtime.

Resilience in High-Velocity Environments

By isolating write pipelines from live agent retrieval channels, knowledge architectures can evolve and compound without sacrificing uptime or latency.

Your agents continue querying uninterrupted — while the underlying memory engine updates smoothly in the background.

All field notes

Kiomon Engineering

We build persistent context, knowledge, and memory infrastructure for AI agents over native MCP.

Give your AI agent a brain that remembers

Stream persistent context to Claude Code, Cursor, and any MCP agent with zero setup friction.

Get started free View docs