Lesson 25 / 29

Versioning and Change Control for Prompts

Track which prompt produced which result.

Prompts are production code

Keep prompts in version control as files with names and versions, not scattered strings. Record, for every request, the prompt version, model name and settings (temperature, max tokens) so results are reproducible and regressions can be traced. Review prompt changes like code, run the test set in CI, and roll out gradually (a small percentage of traffic, then more) with a quick rollback. Pin the model version where the provider allows it, since silent model updates can change behaviour; re-run your tests when you change or upgrade models.

A prompt registry, run

I ran this plain-Python (standard library only) example. Each prompt text gets a short hash and size so you can tell exactly which version produced a result; changing even one character changes the hash.

import hashlib, json

prompts = {
    "v1": "Summarise the text.",
    "v2": "Summarise the text in 2 sentences for a manager. Say 'unknown' if unsure.",
}
registry = {}
for name, text in prompts.items():
    registry[name] = {"sha": hashlib.sha256(text.encode()).hexdigest()[:8], "chars": len(text)}
print(json.dumps(registry, indent=1))

Output:

{
 "v1": {
  "sha": "f4b75c21",
  "chars": 19
 },
 "v2": {
  "sha": "300246f4",
  "chars": 73
 }
}

Pin the model version

Use a dated model identifier where available so a silent provider update does not change your results overnight.

Quick check: What should be logged with each model call?

  • Only the date
  • Nothing
  • Prompt version, model name and settings
  • The user's password
Answer

Prompt version, model name and settings — Reproducibility requires knowing exactly what produced each output.