← Back to learning path
Chapter · Published

RAG production pipeline: updates, cache, and rollback

Version the ingestion and index pipeline so updates are observable, caches stay isolated, and an incomplete index cannot become current.

Source: knowledge/p24-b/collection_6e8fbe1e8b1ea569a539e8a5/tutorials/rag-production-pipeline-and-cache.mdRAG knowledge engineering
Chapter progress 0%Learning path progress 0% · 0/10 chapters completedContinue learning path →

Production RAG coordinates document ingestion, embeddings, indexes, query caches, and rollback. Build a new version, run health checks, and switch an explicit pointer instead of mutating the live index in place.

Core concepts

An index manifest should record the source snapshot, chunking rules, embedding model, and build result. Cache keys must include normalized query, tenant, permission summary, and index version.

from dataclasses import dataclass

@dataclass(frozen=True)
class IndexRelease:
    version: str
    document_count: int
    embedding_model: str
    status: str

def cache_key(query: str, tenant: str, role_hash: str, index_version: str) -> str:
    return '|'.join((tenant, role_hash, index_version, query.strip().lower()))

Steps and use cases

  1. Freeze a document snapshot and build a new index while the old one serves traffic.
  2. Check document counts, vector dimensions, sample retrieval, and permission regressions.
  3. Switch the current pointer once the health checks pass; keep the old pointer for rollback.
  4. Bind cache keys to index version and permission summary so releases cannot reuse stale results.

This suits continuously updated help centers, policy libraries, and production systems that need quick rollback.

Common questions

In-place updates can be fine for a small experiment, but production generally benefits from versioned builds. A cache without tenant and permission fields can leak evidence and must not be shared across boundaries.

Official references

OpenAI production best practices and OpenAI embeddings.

Last checked: 2026-11-16. Validate new documents with a fixed question set before promotion.

Related practical cases

KnowledgeCase study: blue-green RAG index release and rollback

Further reading

KnowledgeRAG for Enterprise Knowledge: Architecture and PracticeKnowledgeStructured Outputs and Tool Contracts for Safe AgentsKnowledgeAI Agents: From Core Concepts to Production
Product Hub Demo · V0.3