Module 6 · Models, prompting and context · Chapter 20 · Free
Prompts as contracts: versioning, testing and change control
- A production prompt is a contract: stated inputs, a guaranteed output shape, an owner, a version.
- Changes are releases, gated by evals, never edited live on a Friday.
- Rollback to the previous version is a first-class operation, planned before you need it.
The picture: a contract amendment, signed and filed, not a sticky note on the original.
Models, Prompting and Context is 13 percent of the CCAR-P exam. You should be able to:
- Write a prompt contract: inputs, output schema, guarantees, non-guarantees, owner.
- Separate rules a prompt requests from rules code enforces.
- Gate prompt changes on eval results, including harm metrics, not acceptance alone.
- Run rollout and rollback as planned, reversible operations.
- By Monday, nurses report drafts promising things Relay cannot verify, like guaranteed callback times.
- Nobody knows exactly what changed: there is no version, no diff, no test run to point at.
- Restoring the old wording takes two days of guesswork, while Tom's pool edits around the problem by hand.
- What a prompt contract states, and what it cannot promise.
- How a change travels: proposal, eval gate, release or rejection.
- The warmer-prompt worked example: acceptance up, safety down.
- The lab: write Relay's prompt contract and change policy.
Next: what makes a prompt a contract.
Step 1: A contract states inputs, outputs and ownership
Think of a rental agreement: it names who provides what, what the other side can rely on, and who to call when something breaks. A production prompt deserves the same clarity, because other systems and people build on its behaviour.
Relay's drafting prompt contract states five things:
- Inputs: the message thread, the patient summary from
get_patient_summary, and the appointment facts fromlookup_appointment. Nothing else is promised to be present. - Output shape: a draft in the agreed schema, the same structured output discipline Foundations built in structured output and tool use. Downstream code parses it, so the shape is a guarantee, not a hope.
- Guarantees: what the surrounding system enforces, listed in Step 2.
- Owner and version: a named owner, a version number and a changelog entry for every change, however small.
- Non-guarantees: what the prompt asks for but cannot promise, stated honestly so nobody designs on it.
Where the picture breaks down: a paper contract binds both sides. A prompt binds only your side. The model can still drift, which is why the contract pairs every promise with either code or an eval.
Next: which rules the prompt merely requests.
Step 2: Requests in the prompt, guarantees in code
Foundations taught the pattern with a refund rule: a prompt is a request, hooks and permissions are guarantees. Relay repeats it one level up. Read the drafting prompt's anatomy with that split in mind:
- Role: you draft replies for nurse review, in Northgate's tone, for routine portal messages.
- Requested rules: be warm, be brief, cite only facts present in the inputs, never invent a callback time. The prompt asks; the model usually complies.
- Enforced rules: Relay never sends without a nurse approving. That rule is code, not a prompt line. The output schema is validated in code. Tool permissions in Atlas decide what the agent may call at all.
The contract's guarantee list may only contain the enforced kind. The moment a requested rule is written up as a guarantee, someone downstream designs on it, and the first model slip becomes their incident. Honest contracts list requests under non-guarantees, with the eval that watches them.
Next: how a change earns its release.
Step 3: Changes are releases, gated by evals
Press Next to walk a prompt change through the gate.
- A change request states the problem, the exact wording change and the expected effect.
- The edit gets the next version number, a diff and a changelog entry before anyone tests it.
- The 400-case golden set runs, as chapter 13, Evals in the pipeline, set up: acceptance, unsafe rate and the contract's watched metrics.
- One failing gate is a fail. Acceptance cannot outvote an unsafe or unverifiable-promise rise.
- Passing changes roll out in stages with the previous version ready to restore. Failing ones return with their numbers attached.
Rollback is part of the release, not an improvisation. The previous version stays deployable, the switch back is one operation, and the team has rehearsed it. If restoring the old prompt takes two days, you do not have rollback, you have archaeology.
Worked example. The warmer edit, judged by the gate. Figures are made up, on the 400-case golden set.
Proposal: add the line "be warmer and reassure the patient" to the drafting prompt.
Acceptance: version 7 scores 71 percent, that is 284 of 400 drafts accepted. Version 8, the warmer draft, scores 76 percent, that is 304 of 400. Gain: 20 more accepted drafts.
Unverifiable promises: version 7 has 3 cases with a promise Relay cannot verify, like a guaranteed callback time. Version 8 has 7 cases. That is more than double, 3 to 7 on the same set.
Unsafe rate: unchanged, and still under the 0.5 percent ceiling.
Gate verdict: reject. Acceptance rose 5 points, but a watched contract metric more than doubled. Vibes said warmer is better; the guarantee list said drafts must cite only verifiable facts, and the gate caught what vibes missed.
The fix that later passed: warmth aimed at wording nurses control, plus an explicit line that times and outcomes are stated only when present in the inputs. Same gate, both metrics green.
Reject. The gate checks every contract metric, not the friendliest one. A promise a patient relies on is a trust failure even when no clinical harm follows.
Next: who may change what, and how fast.
Step 4: The change policy around the contract
- Anyone may propose. Nurses, engineers and Marcus's clinicians all see failure modes the others miss. Proposals are cheap; releases are not.
- The owner decides. The prompt's named owner accepts or rejects after the gate, and owns the changelog.
- Some changes are not prompt changes. A new rule that must always hold belongs in code. A new tool instruction changes the tool contract too, and needs Atlas review with Priya's team.
- Timing is policy. No live edits on a Friday, no unversioned hotfixes. Urgent safety fixes use the same path, faster, with the gate run first and the steering group told the same day.
Next: the lab, where you write the contract.
Hands-on lab: the prompt contract and version policy
Part A: build it locally
Do this: copy this contract next to Relay's drafting prompt and keep both under version control together.
Lab: Part A of this chapter prints Relay's drafting prompt contract as a finished example. This lab runs in your browser and needs JavaScript enabled.
What to notice. The rejected version stays in the history. A changelog that only records successes teaches the next engineer to repeat the failure.
Part B: judge three change requests
Do this: work through the scenario and route each request the way the policy requires.
Mix-ups to avoid
- "It is just a wording tweak." Wording is behaviour. The warmer tweak doubled unverifiable promises.
- "Acceptance went up, so ship it." One green metric cannot outvote a failing guarantee metric.
- "The prompt says never, so it is guaranteed." A prompt is a request. Guarantees live in code, permissions and validation.
- "We can always roll back." Only if the previous version is kept, deployable and rehearsed. Otherwise rollback is archaeology.
Teams running prompts in production commonly adopt software habits for them: version control, review and staged rollout. Practitioner experience, not a measured statistic: the teams that skip the changelog are the ones who cannot answer what changed when behaviour shifts.
Chapter quiz
Five questions in the exam's style. Score 70% or more to finish.
Review this chapter in 5 minutes
Watch the whole chapter recapped: Prompt contracts, requests versus code guarantees, the eval gate that rejected the warmer edit, and rehearsed rollback.
- Contract: inputs, output schema, guarantees, non-guarantees, owner, version, changelog.
- Split: prompts request; code, permissions and validation guarantee.
- Gate: every change runs the 400-case golden set; one failing metric rejects it.
- Warmer edit: acceptance 71 to 76 percent, unverifiable promises 3 to 7 of 400: rejected.
- Rollback: previous version kept deployable, restore rehearsed, reason logged.
Decision rule: if a prompt change has no version, no gate result and no rollback, it is not a change, it is an incident waiting for a date.
Independent exam preparation. Not affiliated with or endorsed by Anthropic.
Review
Glossary
- Prompt contract
- The stated inputs, output shape, guarantees, owner and version of a production prompt.
- Changelog
- The dated record of every prompt version, including rejected ones and why.
- Eval gate
- The eval run a change must pass before release. Example: Relay's 400-case golden set.
- Non-guarantee
- Behaviour a prompt requests but cannot promise. Example: warm tone, watched by evals.
- Rollback
- Restoring the previous version as one planned operation. Example: v9 back to v7.
- Staged rollout
- Releasing to part of the traffic first. Example: one pilot clinic before both.
Next: "Context architecture: what the model sees, in what order, and why".