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.
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…"
- In git, so every change has a diff and a reviewer.
- A version number: support_answer v7, not "the new one".
- Logged with every call, so
prompt_version: 7sits 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:
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
- Change one part. For example, prompt v7 becomes v8.
- Run the eval set, the same questions as last time.
- Compare the scores against the current release.
- 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
| Part | Version it as | Logged as |
|---|---|---|
| Prompt | a file in git with a version number | prompt_version: 7 |
| Model | a dated snapshot, plus its settings | model: gpt-5-2025-08-07 |
| Index | a name that carries its recipe | index: help_docs_v12 |
| All three | one release.yaml | release: 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.
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.