Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

AI Engineering
  • The AI Stack in One Picture: Six Layers Every AI Product Is Built From
  • Tokenization: What an LLM Actually Sees When You Type
  • LLM Tokens, Context Windows and Cost: What One Question Really Costs
  • What an LLM Can and Cannot Do: One Prediction Loop, Its Strengths and Its Gaps
  • Structured LLM Output with Pydantic: Describe the Shape Once, Check Every Reply
  • Temperature, Top-p and Sampling: Why the Same Prompt Gives a Different Answer
  • Open vs Closed LLMs: Cost, Control, Privacy and Capability, Decided per Workload
  • Streaming and Error Handling for LLM Calls: Show the First Word Early, Retry Politely, Fail Calmly
  • Practice: Build a CLI Chat Tool with Memory, Commands, Error Handling and a History Cap
  • Explicit Criteria vs Vague Prompts: Turn Every Adjective Into a Check a Script Can Run
  • Few-Shot Prompting Done Right: How Many Examples, How Different, What Order, and the Leak That Lies
  • Prompt Caching: Keep the Start of Every Request Identical and Pay for the Long Part Once
  • Prompt Versioning and Testing in a Repo: Prompt Files, a Registry, a Hash per Answer and Tests That Gate
  • Context Engineering: What Belongs in the Context Window, Turn by Turn
  • Context Engineering for a Long-Running Agent: Clear, Compact, Take Notes, Prove It
  • What an Embedding Actually Is: Meaning as Numbers, Search by Closeness, and Where Hand-Made Numbers Break
  • The RAG Pipeline Explained: 7 Stages From Documents to a Cited Answer
  • Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors
  • Why RAG Exists: The Problem It Solves, Compared With Pasting Everything and Fine-Tuning
  • Real Embedding Models: an Open Model or a Provider API, Then Search, Duplicates and Recommendations
  • Chunking Strategies for RAG: Fixed Size, Sentences or Headings, Measured on One Handbook
  • Vector Databases Hands-On: The Same Search in Chroma and pgvector
  • RAG Prompt Assembly and Citations: Number the Blocks, Fit a Token Budget, Check Every Claim
  • Hybrid Search: BM25 Plus Dense Embeddings, Merged With Reciprocal Rank Fusion
  • Reranking With a Cross-Encoder: When the Second Pass Helps, and When It Doesn't
  • Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
  • Choosing a Vector Index: Flat, HNSW or IVF-PQ, a Memory Estimate, and Filters That Starve Small Customers
  • Citations and Abstention in RAG: What a Citation Proves, and When the Right Answer Is "It's Not in the Documents"
  • Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  • Cosine, Dot Product or Euclidean Distance: Why Three Measures Pick Three Winners, and the One Fix
  • Choosing an Embedding Model: Dimension, Context Length, Domain and Cost, Tested on Your Own Questions
  • Loading and Parsing Real Documents for RAG: PDF Headers, Wrapped Lines, Tables and HTML Chrome, Scored
  • Where Naive RAG Fails: Five Ways the Simplest Retriever Hands the Model the Wrong Pages
  • RAG Generation Metrics: Faithfulness, Groundedness and Relevance, One Claim at a Time
  • Capstone: A Production RAG Service Over the Python Standard Library, With an Eval a Hiring Manager Can Rerun
  • Context Engineering for a Long-Running Agent: Clear, Compact, Take Notes, Prove It
  • What LangChain Is For, and When to Skip It: Five Standard Parts, One Pipe, and a Decision Table
  • Why Chains Break: No Branch, No Retry, No Pause, and the Same Refund Assistant as a LangGraph Graph
  • LangGraph Nodes, Edges and State: Build Your First Graph, Route With a Conditional Edge, and Read the Run Three Ways
  • Human-in-the-Loop and Checkpointing in LangGraph: interrupt, a SQLite Save Slot and Command(resume=...)
  • Multi-Agent Patterns: Hub and Spoke in LangGraph, With Short Briefs, Owned Tools and a Retry the Hub Decides
  • A Research Agent in LangGraph: Plan, Search, Read, Write, and a Check Node That Rejects Citations Nobody Read
  • What Is MCP? One Plug Between AI Apps and Tools: Host, Client, Server and the Three Messages
  • Configuring MCP Servers in Claude Code: A Command or a URL, Three Scopes, and Three Moves When One Breaks
  • Workflow or Agent: Decide Who Picks the Next Step, Then Let the Constraints Choose the Design
  • Custom Agent Loops and Harnesses: A Dispatch Table, an Approval Hold, Error Results and a Turn Budget
  • Building an MCP Server: Tools, Resources and Prompts in Python and TypeScript
  • MCP Transports: stdio or Streamable HTTP, and Who Starts the Server
  • Deploying and Authenticating an MCP Server: Environment Keys for stdio, Bearer Tokens and Scopes for HTTP
  • From ML Metrics to LLM Evals: Same Ruler, New Targets
  • Why You Cannot Ship an LLM Feature Without an Eval: Five Parts, Three Graders, One Tiny Eval
  • Building a Golden Dataset for LLM Evals: Cases, a Schema, a Coverage Table and a Seeded Split
  • Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
  • Regression Testing an LLM Bot in CI: A Golden Set, Two pytest Gates and GitHub Actions
  • Testing a RAG Bot Before It Ships: Slices, a Release Gate per Slice, and the Week After
  • RAG Generation Metrics: Faithfulness, Groundedness and Relevance, One Claim at a Time
  • LLM-as-Judge: Write a Rubric, Check Every Verdict, and Trust the Grader Only After Kappa Says So
  • RAGAS and Custom Evals: Framework Faithfulness Plus Your Own Citation and Required-Fact Checks, Behind One Gate
  • Which Test Layer Owns the Failure? Unit, Functional, Integration and End-to-End Tests for a Claude App
  • Six Ways a 200 Can Still Be Wrong: Hallucination, Refusal, Under-Acting, Context Loss, Format Drift and Inconsistency
  • Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
  • Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
  • Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
  • Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
  • A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
  • Caching for AI Apps: Four Layers, What Goes in Each Key, and How a Delete Travels
  • Semantic Caching: Why a Similarity Threshold Can't Stop Confident Wrong Answers
  • LLM Model Routing: Rules, a Classifier or a Cascade, Judged on Cost per Win and Every Topic
  • Cutting p95 and Cost in Half for an LLM App: Read the Bill, Match the Lever, Guard Success
  • Observability and Tracing for LLM Apps: A Span per Stage, Redaction First, Bad Traces Become Tests
  • Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  • Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  • Design a Multi-Tenant RAG Assistant, Part 1: Requirements, Rough Numbers and a Contract
  • Design a Multi-Tenant RAG Assistant, Part 2: Tenant Isolation, a Scoped Cache and Walking an Outage
  • A 500 MB PDF Takes 50 s to Answer, Get It to 2 s: Measure First, Then Promise Per Path
  • A 500 MB PDF From 50 s to 2 s, the Fast Path: Queue, Status, Streaming and an Acceptance Test That Fails
  • FastAPI for AI Services: Schemas at the Door, Load Once in the Lifespan, Depends, and def vs async def
  • Streaming LLM Answers From FastAPI: Sources First, Token Events Over SSE, and the Same Events Over a WebSocket
  • Docker for AI Apps: Bake the Model Weights In at Build Time, Use CPU-Only PyTorch, and Run Offline
  • Deploy a RAG Service: A Service Key, Health and Ready Checks, Caddy in Front and a Smoke Test
  • Cost Tracking and Budget Guards for an LLM App: Count the Tokens, Log Every Call, Check Before You Spend
  • Versioning Prompts, Models and Indexes: Three Moving Parts, One Release File and a One-Line Rollback
  • Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  • The Agent Attack Surface: Blast Radius, Narrow Tools, Scoped Keys and the Dangerous Three
  • Prompt Injection, Jailbreaks and Untrusted Input: Label What Comes In, Gate What Goes Out
  • Injection Exposure Review for an Agent: Map Inputs, Data and Effects, Layer Every Path, Retest the Job
  • Data Leakage and PII in LLM Apps: Redact, Minimize, Log Safely and Count Every Place
  • Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
  • Claude API Keys: Keep the Key on a Server Proxy, One Key per Environment, Rotate and Scope It
  1. Blog
  2. /
  3. AI Engineering
  4. /
  5. AI System Design

Versioning Prompts, Models and Indexes: Three Moving Parts, One Release File and a One-Line Rollback

On Monday the assistant says 30 days with the receipt; on Thursday it can't find a return policy, and no code was deployed. The prompt was edited, the model alias moved, or the index was rebuilt. Version each one, pin all three in one release.yaml, log the release on every call, and rolling back becomes a one-line change.

Chaand Sheikh

·27 November 2026AI System Design

What you will learn

  • Explain why the prompt, the model and the vector index drift on their own and break answers together
  • Give each part a version: a prompt file in git, a dated model snapshot, an index named by its recipe
  • Pin all three in one release file and log the release on every call
  • Change one thing at a time behind an eval, and roll back by pointing the release file back

Before you start

  • Prompt Versioning and Testing in a Repo
  • The RAG Pipeline Explained

An LLM app has three moving parts besides your code: the prompt, the model and the vector index. Each changes on its own schedule, and when one changes, your answers change with it. In this article we give each part a version and pin all three in one place, so that any answer can be traced back to exactly what made it, and so that undoing a bad change takes one line.

This lesson is about a habit rather than a library, so the examples are short config files and log lines.

Monday fine, Thursday wrong

On Monday a customer asks "How long do I have to return a laptop?" and the assistant says thirty days, with the receipt. On Thursday the same question gets "I could not find a return policy." Nobody deployed any code. (Both replies are illustrative.) Three suspects:

  • The prompt. Someone edited it in a dashboard and shortened the instructions.
  • The model. The alias you call moved, and now points to a newer snapshot.
  • The index. It was rebuilt overnight with a new chunk size, and the policy page got split in two.

Three things drift on their own and they break together. Without versions you can't tell which one it was.

Think of a restaurant whose best dish suddenly tastes wrong. Maybe a line on the recipe card changed (your prompt), maybe the oven was replaced (your model), maybe the pantry was restocked with another brand of flour (your index). A good kitchen writes down which recipe, which oven and which pantry batch made each plate. That's what we'll do.

Prompts: files with a version

Treat a prompt like code, not like a note in a dashboard. It lives in a file with an id, a version number, a short line about what changed, and the text:

# prompts/support_answer.yaml
id: support_answer
version: 7
changed: "added: always quote the policy name"
text: "You answer return questions using only…"
  1. In git, so every change has a diff and a reviewer.
  2. A version number: support_answer v7, not "the new one".
  3. Logged with every call, so prompt_version: 7 sits in each log line.

If you can't say which prompt produced an answer, you can't fix it. The full workflow for prompt files, a registry and tests that gate a change is in prompt versioning and testing in a repo.

Models: pin a snapshot, not an alias

Most providers give a model two kinds of name. An alias, like gpt-5 or claude-sonnet-5-5, is a moving pointer: the provider can point it at a newer model. A snapshot is the exact model, with a date in its name, like gpt-5-2025-08-07, and it stays put.

  • In production, pin the snapshot, and pin its settings with it: temperature and max tokens.
  • Snapshots get retired after some time, so watch the retirement dates.
  • Upgrade on purpose, after your evals pass.

The model is part of your release. Upgrade it like a library, not by surprise. A worked upgrade with a golden-set replay and a staged rollout is in pinning model IDs and upgrading safely.

Indexes: a version for the vectors

An index is data plus the recipe that made it. The recipe has three parts, and all three go into the index's name:

An index is data plus its recipe source docssnapshot of 1 Nov chunking512 characters, 50 overlap embedding modelall-MiniLM-L6-v2 help_docs_v12 one version, one recipe
Change any one of the three and you have a new index, with a new version.

Here's the trap. If you switch the embedding model for the questions but search vectors made by the old model, the numbers no longer mean the same thing, and search quietly returns the wrong chunks. No error, just bad answers. So never mix two embedding models in one index; build a new index next to the old one. How to do that switch without downtime is in embedding migration with zero downtime.

One file pins all three

Now bring the three together in a release manifest, the label on every plate:

# release.yaml
release: support-r42
prompt: support_answer v7
model: gpt-5-2025-08-07
temperature: 0.2
index: help_docs_v12
embedding: all-MiniLM-L6-v2

And every log line carries the release:

trace_id: c41f09aa
release: support-r42
prompt_version: 7
model: gpt-5-2025-08-07
index: help_docs_v12

When a bad answer is reported, you find its trace, read the release from it, and know exactly which prompt, model and index made that answer. Back on Thursday, that turns three suspects into one line to read.

Change one thing at a time

  1. Change one part. For example, prompt v7 becomes v8.
  2. Run the eval set, the same questions as last time.
  3. Compare the scores against the current release.
  4. Ship it only if it's better. Otherwise drop it.

Change the prompt and the model on the same day, and when quality drops you have two suspects again. The gate itself is covered in regression testing an LLM bot in CI.

Rolling back is a one-line change

Say you shipped prompt v8 together with index v13, and Thursday happens again. Rolling back means pointing the release file back:

# release.yaml, after the change
prompt: support_answer v8
index: help_docs_v13
# release.yaml, rolled back
prompt: support_answer v7
index: help_docs_v12
  • Keep the old index. Don't delete help_docs_v12 the day v13 ships, or the rollback needs a rebuild.
  • Send a little traffic first. A few percent of users get the new release, then everyone.
  • Watch the numbers by release: eval scores, thumbs down, and cost per answer.

If rolling back needs a rebuild, it's too slow for a bad Thursday.

Common mistakes

  • Editing the live prompt in a dashboard. No diff, no reviewer, no version to go back to.
  • Calling an alias in production. The provider can change your model without a deploy.
  • Rebuilding an index in place. The old version is gone, and so is your rollback.
  • Logging the answer but not the release. Then a bad trace can't tell you what made it.

Recap

PartVersion it asLogged as
Prompta file in git with a version numberprompt_version: 7
Modela dated snapshot, plus its settingsmodel: gpt-5-2025-08-07
Indexa name that carries its recipeindex: help_docs_v12
All threeone release.yamlrelease: support-r42

Try it yourself

Write down where your prompt, your model id and your index name sit today. Put all three in one release file and add the release to your log line. Then practise a rollback: point the release back one version, and time how long it takes until answers come from the old setup.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in AI Engineering · 82 of 89

Previous
Cost Tracking and Budget Guards for an LLM App: Count the Tokens, Log Every Call, Check Before You Spend
Next post
Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out

Related course on Udemy

Become an AI Engineer: LLMs, RAG, Agents and MCP

Build real AI systems in Python: LLM APIs, RAG, evals, agents and MCP.View on Udemy ↗: Become an AI Engineer: LLMs, RAG, Agents and MCP (paid course, opens in a new tab)

Related posts

Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed

When the main model goes down, the backup has to be allowed to take the data, able to read the whole request and tested before the bad day. A simulated four-model chain for an EU customer: a 6,000-token request lands on mid-eu, flagged degraded; a 10,000-token request is served by nobody, on purpose.

Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves

A bulk upload buries the chat. In a small simulation, one shared queue grows to 199 waiting and the middle chat answer takes 80.2 s. A bound plus a chat lane brings it to 0.35 s while 178 bulk jobs are told to retry in 10 s, and cancelling abandoned calls saves 21,000 wasted tokens.

Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys

Six GPU replicas, two at 95% and four at 30%: round robin counts requests, and requests aren't equal. In a small simulation, least outstanding requests cuts p95 from 6.52 s to 3.05 s, prefix affinity lifts cache hits to 95% but pushes p95 to 11.45 s, a real health check takes errors from 48 to 2, and draining cuts 0 answers instead of 4.

A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue

A queue doesn't lose a document, but it can hand one out twice. In a small simulation, a worker crash makes document two go from 3 to 6 chunks and the index holds 11 when the documents hold 8. An idempotent consumer brings it back to 8 with the same two deliveries, and a limit of three tries moves a poison file to a dead letter queue.

On this page

  • Monday fine, Thursday wrong
  • Prompts: files with a version
  • Models: pin a snapshot, not an alias
  • Indexes: a version for the vectors
  • One file pins all three
  • Change one thing at a time
  • Rolling back is a one-line change
  • Common mistakes
  • Recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Become an AI Engineer: LLMs, RAG, Agents and MCP

Build real AI systems in Python: LLM APIs, RAG, evals, agents and MCP.View on Udemy ↗: Become an AI Engineer: LLMs, RAG, Agents and MCP (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.