KatInterview

Versioned Prompt and Config Control for a Production RAG Service

System DesignModel answer
HardModel answerSystem Designllm-opsragconfig-management

Last updated

Design a system that versions LLM prompts, models, retrieval and decoding settings, rolls changes out gradually, traces every request to its exact config, and rolls back instantly.

Context

Your team runs a retrieval-augmented generation (RAG) assistant on top of a hosted LLM. Engineers regularly tweak the system prompt, point traffic at a different model endpoint, change how documents are retrieved, or adjust sampling settings such as temperature and top-p. Last week, a small edit to the system prompt made the assistant refuse far more requests than before. Nobody noticed for about a day.

Task

Propose a design that stops this kind of silent regression. Cover these four areas:

  1. Versioning. Where and how do you store prompt templates, model metadata and hyperparameters so that each request maps to one immutable identifier for the exact configuration it ran with?
  2. Gradual release. How do you ship a new system prompt to 5% of traffic and judge its effect on downstream signals such as faithfulness, latency and token cost before widening the rollout?
  3. Traceability. Given one production log entry for a hallucinated answer, how do you rebuild precisely what happened, including the retrieved context and the prompt that was used?
  4. Recovery. How do you revert to the last known good configuration quickly, without shipping new application code?

Constraints

  • Throughput of thousands of requests per second.
  • User data that appears in prompts must follow privacy rules, for example PII masking in stored logs.
  • The configuration system must be highly available and must not be a single point of failure for inference.

State your assumptions, sketch the architecture, and discuss trade-offs and failure modes.

Hints

Hint 1

Treat prompts, model choices, retrieval settings and sampling parameters as release artifacts: immutable, content-addressed bundles, with a separate small mutable pointer that decides which bundle serves which traffic.

Hint 2

Keep the config service off the hot path: push snapshots to each serving pod, cache them in memory and on disk, and let pods keep serving the last snapshot if the control plane is down.

Hint 3

For rollouts, compare canary and control over the same time window using behavioral metrics (refusal rate, faithfulness sample scores, latency, cost), and use thresholds that trigger automatic rollback.

Hint 4

For debugging, log a structured record per request (bundle ID, index snapshot ID, chunk IDs, rendered-prompt hash, model version, params) and keep retrieval indexes versioned so chunk IDs stay resolvable.