Prompt & Configuration Release Management
Lesson opener
In one line: A prompt is production code in disguise: version it, test it, review it, promote it through environments and keep a one-step rollback.
Why it matters: Changing one sentence in a prompt can change tone, accuracy, format and cost for every user at once. If prompts live in code strings, shared documents or a person's memory, nobody can say which version produced a given answer or restore the last good one. Release management makes prompt changes boring and safe.
Before this lesson: Model Access, Selection & Routing.
Northline Consumer Goods (illustrative) uses an LLM to draft the commentary section of the monthly management report. An analyst edited the prompt directly in the production configuration to "make it sound more confident." The next report described a 2% revenue dip as "a strong recovery." Nobody could say which prompt text had produced the previous month's version, whether the change was tested, or who approved it. The team now needs a prompt-release workflow across development, staging and production.
What you will be able to do
- Treat prompts, templates, output schemas and model settings as versioned, reviewable assets.
- Separate prompt text from application code and from environment-specific configuration.
- Define structured outputs and validate them before they reach downstream systems.
- Design a registry with version numbers, content hashes, approvals and an audit trail.
- Promote prompts through dev, staging and production with gates, and roll back in one step.
- Keep sensitive data and secrets out of prompts, templates and logs.
Deliverable: a prompt-release workflow for the monthly-report prompts: asset inventory, environment rules, promotion gates, approval roles, rollback procedure and an audit-log format.
Prerequisites
| Prerequisite | Why it matters |
|---|---|
| Model Access, Selection & Routing | A prompt is tied to a model and settings; changing either is a release. |
| Structured Outputs | Output schemas and parsing are introduced there. |
| Prompt Engineering for Agents | Prompt design techniques; this lesson covers how to release them. |
| Calling an LLM API | Request parameters such as temperature and maximum output tokens. |
| MLflow tracking | Shows experiment tracking and registries for classical models; the registry idea carries over. |
| Copilot Prompt Engineering | Prompt-writing habits for business users. |
Plain English
A prompt asset is more than one block of text. In production it includes:
- The template: instruction text with named variables such as
{report_month}. - The variables: what data fills the slots, and what is never allowed to fill them.
- The output schema: the exact structure the model must return (for example fields
headline,drivers,caveats). - The model and parameters: model identifier and version, temperature, maximum output tokens, stop settings.
- The evaluation set: the test cases this version must pass before release.
- The metadata: version number, author, reviewer, date, change reason and a content hash.
A prompt registry is the controlled store for these assets. It might be a database, a git repository with review rules, or a feature of an LLMOps platform; the principle is framework-neutral: versions are immutable, and environments point at a specific version. Product features for prompt registries vary by tool and are provider-dependent.
Environment separation means development, staging and production have separate configuration, credentials and data, and a prompt version must pass through them in order. Development is for experiments with synthetic data. Staging runs the full test set against realistic but non-sensitive data. Production serves users and is changed only through the release path. Environment-specific values (endpoints, keys, quotas) live in configuration or a secrets manager, not in the prompt text.
Structured outputs reduce parsing errors. Many providers offer a way to request JSON that follows a schema, but support and guarantees are provider-dependent. Regardless, validate the output in your own code: parse it, check required fields and types, check value ranges, and treat failure as a handled case (retry once, then fall back or route to a person).
No sensitive data in prompts. Prompt templates are stored, versioned, copied and often logged. They must not contain API keys, passwords, personal data, customer names, unreleased financials or internal links that grant access. Runtime data sent to a model should be minimised: send what the task needs, mask or replace identifiers, and respect the data classes approved for the model. Keep secrets in a secrets manager and inject them at call time into the HTTP client, never into prompt text.
Rollback means setting the production pointer back to the previous known-good version, without editing the prompt. It must take minutes and require no code deployment.
Teacher walkthrough
Design the release path for the monthly-report commentary prompt.
- Business owner. The Finance Controller (illustrative) owns the report content and approves production prompt versions. A technical owner maintains the registry and pipelines.
- Approved users. Report drafts are generated for the Finance reporting team only. Access is by group and is enforced by the application, not by the prompt.
- Sources. The prompt receives only approved, aggregated figures from the finance data mart (revenue, margin, variance by region). It never receives individual customer data, payroll or unreleased board material.
- Permissions. Dev uses synthetic figures. Staging uses prior-period figures already published. Production uses the live close data. Credentials differ per environment and are held in a secrets manager.
- Asset definition. Register template, variables, JSON output schema (
headline,drivers,risks,caveats), model and version, temperature, and the evaluation set (30 past months with expected driver lists). - Validation in dev. Run a handful of cases. Deterministic checks: output parses, required fields present, no field is empty, every figure in the commentary appears in the supplied input.
- Validation in staging. Run the full 30-case set and compare with the current production version on the same cases. Gate: no drop in task success; zero invented figures; refusal when data is missing. Record scores against the version hash.
- Human review. A finance analyst reads a sample of staging outputs side by side with the production version and signs off in the registry.
- Approval. The Controller approves promotion to production. Approval is recorded with name, date and version. Promotion without it is blocked.
- Escalation. If production monitoring shows invented figures or validation failures above the threshold, the on-call engineer rolls back first and then informs the Controller.
- Monitoring. Per version: schema-validation failure rate, figures-not-in-input rate, human edit rate, tokens and cost. Alert on change after promotion.
- Fallback. If the structured output fails validation twice, the application shows the raw figures table and a message that commentary is unavailable, and notifies the reporting team.
- Stop condition. Any production output containing a figure not present in the input pauses generation until a reviewed fix is released.
Worked example
This stdlib-only registry demonstrates immutable versions, content hashes, a secret scan, ordered promotion, gating by evaluation and approval, an audit trail and rollback. It models the idea only; real systems add storage, authentication and access control.
import hashlib
import json
import re
from string import Formatter
ENVS = ["dev", "staging", "prod"]
SENSITIVE = [
re.compile(r"sk-[A-Za-z0-9]{16,}"),
re.compile(r"(?i)(password|secret|api[_-]?key)\s*[:=]"),
re.compile(r"\b[\w.]+@[\w.]+\.[A-Za-z]{2,}\b"),
]
class PromptRegistry:
def __init__(self):
self.versions = {} # name -> list of immutable version records
self.active = {} # (name, env) -> version number
self.history = {} # (name, env) -> stack of previous version numbers
self.audit = []
def register(self, name, template, variables, author):
for pattern in SENSITIVE:
if pattern.search(template):
raise ValueError("sensitive pattern found in template")
declared = {field for _, field, _, _ in Formatter().parse(template) if field}
if declared != set(variables):
raise ValueError(f"declared variables {sorted(variables)} do not match template {sorted(declared)}")
items = self.versions.setdefault(name, [])
number = len(items) + 1
digest = hashlib.sha256(template.encode("utf-8")).hexdigest()[:12]
items.append({"number": number, "template": template, "variables": set(variables),
"sha": digest, "author": author})
self.audit.append(("register", name, number, author))
return number
def promote(self, name, number, env, eval_passed=False, approved_by=None):
index = ENVS.index(env)
if index > 0 and self.active.get((name, ENVS[index - 1])) != number:
raise PermissionError(f"v{number} must be active in {ENVS[index - 1]} first")
if env in ("staging", "prod") and not eval_passed:
raise PermissionError("evaluation set must pass before promotion")
if env == "prod" and not approved_by:
raise PermissionError("production needs a named approver")
key = (name, env)
if key in self.active:
self.history.setdefault(key, []).append(self.active[key])
self.active[key] = number
self.audit.append(("promote", name, number, env, approved_by))
def rollback(self, name, env):
stack = self.history.get((name, env), [])
if not stack:
raise LookupError("no previous version to roll back to")
restored = stack.pop()
self.active[(name, env)] = restored
self.audit.append(("rollback", name, restored, env))
def render(self, name, env, **values):
record = self.versions[name][self.active[(name, env)] - 1]
if set(values) != record["variables"]:
raise ValueError("variables do not match the registered set")
return record["template"].format(**values), record["sha"]
def validate_output(raw, required):
data = json.loads(raw)
missing = [key for key in required if not data.get(key)]
if missing:
raise ValueError(f"missing or empty fields: {missing}")
return data
reg = PromptRegistry()
v1 = reg.register("monthly_commentary", "Write commentary for {report_month} using only: {figures}", ["report_month", "figures"], "analyst_a")
v2 = reg.register("monthly_commentary", "Write cautious commentary for {report_month} using only: {figures}. Flag missing data.", ["report_month", "figures"], "analyst_b")
for env in ENVS:
reg.promote("monthly_commentary", v1, env, eval_passed=True, approved_by="controller")
for env in ENVS[:2]:
reg.promote("monthly_commentary", v2, env, eval_passed=True)
try:
reg.promote("monthly_commentary", v2, "prod", eval_passed=True)
except PermissionError as err:
print("blocked:", err)
reg.promote("monthly_commentary", v2, "prod", eval_passed=True, approved_by="controller")
print("prod active:", reg.active[("monthly_commentary", "prod")])
reg.rollback("monthly_commentary", "prod")
print("after rollback:", reg.active[("monthly_commentary", "prod")])
text, sha = reg.render("monthly_commentary", "prod", report_month="2026-09", figures="revenue -2.0% vs plan")
print(sha, "|", text)
try:
reg.register("bad", "Use api_key = ABC for {x}", ["x"], "someone")
except ValueError as err:
print("rejected:", err)
print(validate_output('{"headline":"Revenue 2.0% below plan","caveats":"Preliminary close"}', ["headline", "caveats"]))
print(len(reg.audit), "audit entries")Running it shows the promotion to production blocked without an approver, then allowed with one, a rollback restoring v1, a rejected template containing a secret-like pattern, and a validated structured output. The audit list is the evidence trail. In a real system the final render would feed the model call; the registry returns the content hash so that every response can record which prompt version produced it.
A second workplace case
Northline's customer service team keeps an email-reply prompt in a shared document. Four people edit it. A reply went out with an internal escalation phone number. The team moves the prompt into the registry, splits the template from a team_contact variable populated from configuration per environment, and adds a rule that production prompts cannot contain phone numbers or email addresses (the secret and PII scan above, extended). Edits now arrive as proposed versions with a reviewer. The shared document becomes read-only documentation that links to the registry entry.
Failure example
Symptom: Commentary calls a 2% revenue dip "a strong recovery." Another month, the output has a different structure and the report builder crashes.
Diagnosis: The prompt was edited in place in production by one analyst. There was no version, no evaluation, no approval and no output validation. The wording change was untested against past months, and the builder trusted the model's format.
Correction: Restore the last version known to be good by pointing production back to it; move all prompts into the registry; require evaluation plus Controller approval for promotion; add schema validation and a "figures must appear in the input" check; block direct edits in production.
Validation: Re-run the 30-case set against the restored version; check the "strong recovery" case now produces cautious wording; confirm schema validation rejects a deliberately malformed output; attempt a direct production edit and confirm it is refused.
Prevention: Require registry-only changes, make evaluation and approval gates mandatory, log prompt hash on every output, and review the audit log monthly.
Guided practice
Scenario: Northline's Sales Operations wants an LLM to summarise weekly pipeline notes per region for the sales director. The first prompt draft contains the line Use token: EXAMPLE-NOT-A-REAL-TOKEN so the model can "fetch more data." Design the release workflow and fix the draft.
Hints:
- What is wrong with having a token inside a prompt?
- Which values belong in configuration and which in the template?
- What gates must a new version pass before staging and before production?
- Who approves production and who can roll back?
- How would you find which version produced a specific summary last Tuesday?
Complete solution:
- Fix the draft: remove the token. Credentials belong in a secrets manager and are injected by the application's HTTP client at call time, and the model should not call endpoints directly with raw credentials. Rotate the exposed token because it has been written into a prompt history.
- Template and variables: template text with
{region}and{notes}; variables are validated at render time. The template contains no URLs with access tokens, names of customers or phone numbers. - Output schema:
region,top_risks(list),next_steps(list),data_gaps. Validate by code; two failures route to the plain-notes view. - Environments: dev with synthetic notes; staging with last quarter's anonymised notes and the 25-case set; production with live notes.
- Gates: dev to staging requires schema and deterministic checks passing; staging to production requires evaluation at or above the current production score, zero invented figures, a human sample review and approval from the Sales Operations Manager.
- Rollback: the on-call engineer or the technical owner may restore the previous version; they inform the manager afterwards.
- Traceability: every summary stores the prompt name, version number and hash plus the model identifier, so last Tuesday's output is traced by lookup in the audit and response log.
- Stop condition: pause generation if invented figures or restricted content appear in any output.
Independent practice
Design a prompt-release workflow for one prompt you use or can imagine (for example "weekly stock-exception summary for the warehouse team").
Acceptance criteria
- Lists all assets that make up the prompt release (template, variables, schema, model and parameters, evaluation set, metadata).
- Describes dev, staging and production, including data used and where credentials are held.
- Defines promotion gates with at least one deterministic check and one human sign-off.
- Names the approver for production and who may roll back.
- Includes a rollback procedure that takes minutes and does not edit the prompt.
- States how each output can be traced to a prompt version and model.
- Contains no secrets, personal data or customer names, and describes how sensitive data is kept out of prompts and logs.
- Marks any provider-specific feature (structured-output mode, prompt-registry product) as provider-dependent.
Common mistakes
- Editing production prompts in place "just this once."
- Storing prompts in code strings, shared documents and chat messages at the same time, so nobody knows which is current.
- Changing the template without re-running the evaluation set, because the change "looked small."
- Embedding secrets, internal links with tokens, or personal data in templates.
- Using the same credentials and data in development and production.
- Trusting the model's output format without validating it in code.
- Not recording the prompt version on responses, which makes incidents untraceable.
- Treating rollback as a rewrite instead of a pointer change to a known-good version.
- Letting the author of a change also be its only approver.
- Changing model or temperature settings outside the same release process as the prompt text.
Quick check
- List four things that make up a prompt asset beyond the instruction text.
- Why must environment-specific values be kept out of the template?
- What should happen if a structured output fails validation twice?
- Why is rollback a pointer change rather than an edit?
- Why is a token in a prompt a problem even if only developers see the file?
Answers:
- Variables, output schema, model and parameters, evaluation set, version, hash, author and approval metadata.
- The same template must move through dev, staging and production unchanged; endpoints, keys and quotas differ per environment and belong in configuration or a secrets manager.
- Use the designed fallback, such as showing the raw figures and notifying the reporting team, rather than passing malformed output downstream.
- Immutable versions mean the previous good version already exists; switching the pointer is fast, needs no code deployment and does not introduce a new untested edit.
- Prompts are stored, copied and logged, so the token spreads and persists in history; it must be removed, rotated and moved to a secrets manager.
Quiz alignment
The quiz (QUIZ_LLMOPS3) covers prompt assets, registries and versioning, environment separation, structured-output validation, promotion gates, approvals, rollback, traceability and keeping secrets and sensitive data out of prompts. Provider features are described as provider-dependent, as in the lesson.
Lesson summary
Version prompts, schemas, model settings and evaluation sets together. Keep them in a registry with immutable versions, hashes and an audit trail. Promote through dev, staging and production with deterministic and human gates and a named approver. Validate structured outputs in code, keep secrets and sensitive data out of prompts, log the version on every response, and make rollback a one-step pointer change.
Bridge to the next lesson
With models routed and prompts released safely, the next question is what the model sees. The next lesson goes deeper than basic RAG: enterprise retrieval with ingestion governance, hybrid search, reranking, access-aware filtering, citations, authority and freshness.
Sources
- OpenAI, Structured Outputs guide (provider-dependent example of schema-constrained output; check the current documentation): https://platform.openai.com/docs/guides/structured-outputs
- JSON Schema specification: https://json-schema.org/specification
- MLflow documentation, Model Registry and Prompt Registry (features vary by version; check the current documentation): https://mlflow.org/docs/latest/
- The Twelve-Factor App, "Config": https://12factor.net/config
- OWASP, Top 10 for Large Language Model Applications (sensitive information disclosure, prompt injection): https://owasp.org/www-project-top-10-for-large-language-model-applications/
- Python 3 standard library
hashlib,json,re,string: https://docs.python.org/3/library/ (example tested with Python 3.11+)
Northline Consumer Goods, names of people and roles, figures and thresholds are illustrative. The token string in the practice scenario is a fake placeholder for teaching; never put real credentials in lesson material.