Sub topic 10
Reviewing and Releasing a New Version
This chapter assumes you can already render templates from files, that each version lives at prompts/<name>/<version>.yaml with a changelog, and that you have a small regression suite like the one from the testing chapter. Python 3.11 or later is needed for the code below.
Why a release workflow
A prompt change can alter every output your application produces. A one-line edit can break a downstream parser or change the tone for all users. Treat each prompt change like a code change. It should be reviewed, tested, and released on purpose, and it should be easy to undo.
The key idea is to separate three steps that are easy to blur together:
- Adding a new version file.
- Approving it.
- Switching the application to use it.
Adding a file changes nothing in production. Only changing the pin does.
The release flow
Automated checks before review
Reviewers should not spend time on mistakes a script can find. A pre-merge check can confirm that the file is well-formed, that the changelog is not empty, and that the declared variables match the variables used in the template.
import yaml
from pathlib import Path
from string import Template
def check_release(name, new_version, pinned_version):
path = Path("prompts") / name / f"{new_version}.yaml"
prompt = yaml.safe_load(path.read_text())
problems = []
if prompt.get("version") != new_version:
problems.append("version field does not match file name")
if new_version == pinned_version:
problems.append("new version equals the pinned version")
if not prompt.get("changelog", "").strip():
problems.append("changelog is empty")
used = set(Template(prompt["template"]).get_identifiers())
declared = set(prompt["variables"])
if used != declared:
problems.append(f"variables differ: used={sorted(used)} declared={sorted(declared)}")
return problems
if __name__ == "__main__":
issues = check_release("summarize", "1.3.0", "1.2.0")
print("OK" if not issues else "\n".join(issues))Run this in your continuous integration job together with the regression suite. Block the merge if either one fails.
What a reviewer looks at
A prompt review is a diff review plus a judgment about behavior. Ask these questions:
- Does the changelog explain why the change was made, not only what changed?
- Did the version number change by the right amount? A new required variable is a breaking change and needs a major bump. A reworded instruction is usually a minor or patch bump.
- Do the regression results show a difference from the previous version? Read the failing cases, not only the pass count.
- Does the change touch how untrusted input is placed in the template?
- Is the change small enough to understand? Several unrelated edits in one version make a bad result hard to trace.
Releasing by changing the pin
After the merge, the release itself is a small edit to the pin:
PINNED = {"summarize": "1.3.0"} # previously "1.2.0"Keep this edit in its own commit, or its own pull request, so it can be reverted without touching the new version file. The old version file stays in the repository. Rolling back means setting the pin to 1.2.0 again and deploying. No file is deleted or rewritten.
For riskier changes, release in stages. Pin the new version for a small share of traffic or for an internal environment first. Compare logged results, then widen the rollout.
Watching the release
Once the pin changes, use the logged prompt version and model settings to compare the new version against the old one. Look for changes in output length, error rates in your parser, and user complaints. Decide ahead of time what counts as a problem, so rollback is a quick decision and not a debate.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| Editing an existing version file | Logs for that version no longer match what ran | Treat released files as immutable and add a new version |
| Merging and pinning in one step | No chance to observe or stage the change | Merge first, then change the pin |
| Skipping the changelog | Reviewers and future readers cannot tell the intent | Make an empty changelog fail the check |
| Deleting the old version | Rollback is no longer possible | Keep every released version |
Exercise
A teammate fixes a typo in prompts/summarize/1.2.0.yaml, which is the version currently pinned in production, and merges it directly. Name two problems with this and say what they should have done instead.
Show answer
Editing a released file breaks traceability, because logs that say "1.2.0" now refer to text that differs from what earlier calls used. It also skips review, the regression suite, and a separate pin change, so the change goes live immediately and cannot be reverted by changing the pin. They should have added 1.2.1.yaml with a changelog entry, run the checks and regression suite on a branch, gotten a review, merged, and then changed the pin to 1.2.1 in a separate step.