In the overview, the wardens asked for a change before autumn: as huts close for the season, the assistant should say so plainly. Hikers already use the Ridgeline Huts assistant on the trust’s website, so this change reaches real people. This course is about shipping it with evidence.
Before you change a live feature, you need to name exactly what’s live. In this lesson, you’ll record the assistant’s whole answer call, from its instructions to its tools, as one version with an ID that every trace and eval results file carries. Then you’ll write the autumn candidate as a second version. Start by getting the assistant running.
Run the Starting Project
The code download below the overview contains the assistant from the end of Guardrails for AI Features With Real Users. You can start here even if this is your first course on the path. Open the download’s starting-project folder and run npm install. Then copy .env.example to .env, add your provider and key, and run npm start.
This course relies on four parts of the project:
npm run evalsgrades answers with checks and a judge matched against the wardens’ grades and saves a results file per command.traces/keeps errors, flagged answers, and a redacted tenth of the rest, and eachmodelspan recordspromptVersionand the model the response names.model/config.jspins each role’s model to a dated snapshot where the provider lists one. A response cache serves repeated questions.guards/checks questions and answers, andevals/adversarial/replays attacks on every change.
Every lesson ends with a number you produced. Coding exercises run in your browser on recorded data and need no key. The course closes with a winter season project that you plan yourself.
Find What the Prompt Version Leaves Out
To compare the autumn candidate with what’s live, you need everything that shaped a live answer, but the app records only part of it. The promptVersion("v5") on /ask names one file, prompts/v5.txt. The model, the output limit, and the tools live elsewhere, under no ID. You ran into this three times in Keeping AI Features Fast, Affordable and Running:
- Setting
MAX_OUTPUTchanged answers without changing any ID, so you added it tocacheKey()by hand. - You can identify the newer answer model in traces only by reading
promptVersionandresponse.modeltogether, and neither field names the settings. prompts/v6.txt, the shorter-answers trial that dropped “fresh rockfall below the pass”, has nothing tying it to the eval runs that rejected it.
Why not log each setting beside promptVersion? Logged fields describe a call after it happened. They don’t give you a call you can name, run the evals on, and switch back to. For that, the instructions, model, settings, schema, and tools need one ID together, even when a change touches only one of them.
Settings depend on the model and on the provider’s API version, so a request one model accepts can get a 400 error from the next, as you saw with the temperature setting during that upgrade:
Reasoning models such as gpt-6.2-sol, the answer model since that upgrade, return a 400 error for temperature, which gpt-5.4-mini-2026-03-17 accepted. Checked against OpenAI’s documentation on December 3, 2026.
API version 2026-10-21 returns a 400 error for temperature, top_p, and top_k on every model, even at their defaults. So the anthropic-version header your provider file sends shapes every call, and your version will record it. Models after Claude 4.5 also reject a prefilled last assistant turn, and Claude 4.7 and later reject budget_tokens. Checked against Anthropic’s documentation on December 3, 2026.
Wording can fail to carry over too. Prompt v4 exists because the newer model read v3’s instructions too literally. So a new model means a new version, run on the eval set, even when nothing else changes.
To check which settings a new model rejects, build one request body with requestBody() in a one-off script, using the Col de Fenêtre eval case. Don’t log one from the app, because a real body holds a hiker’s own words. For your own feature, put a placeholder where the user’s input goes. Paste the body into the mentor with your provider’s next answer model. The settings it flags are the reason that model change will need a new version of its own:
Record the Live Call as v5
A version is one file holding everything the answer call sends besides the hiker’s input: instructions, models, settings, output schema, and tool definitions, with an ID and a link to its eval results. First, move the tool definition listed by requestBody() from assistant.js to versions/tools/hut-availability-1.js as the new file’s default export. Then record the live call in versions/v5.js:
versions/v5.js
import hutAvailability from "./tools/hut-availability-1.js";
export default {
id: "v5",
instructions: "prompts/v5.txt",
models: {
openai: {
answer: "gpt-6.2-sol", // no snapshot listed: watch response.model
fast: "gpt-6-luna",
},
anthropic: {
answer: "claude-sonnet-5-5",
fast: "claude-haiku-5-5",
},
},
settings: {
maxOutput: 400,
anthropicVersion: "2023-06-01", // what model/anthropic.js sends
},
schema: null, // the answer streams as plain text
tools: [hutAvailability],
results: null, // filled in after its eval runs
};
Both roles that answer hikers, answer and the router’s fast, move here from model/config.js. A call through askForJson() would name its Zod schema in schema. To load a version by its ID, create versions/index.js:
versions/index.js
import { readFile } from "node:fs/promises";
export async function loadVersion(id) {
const { default: v } = await import(`./${id}.js`);
const file = new URL(`../${v.instructions}`, import.meta.url);
const provider = process.env.MODEL_PROVIDER;
return {
...v,
provider,
instructionsFile: v.instructions,
instructions: await readFile(file, "utf8"),
models: v.models[provider],
};
}
The dynamic import() loads the file the ID names, and new URL() uses import.meta.url to resolve the prompt’s path from versions/.
An ID only helps if a version and every file it points to never change once traces or results name it. Fix a typo in prompts/v5.txt, and every old v5 trace points to a call that didn’t produce it. A changed prompt, schema, or tool means a new version. You fill in only results later. A model can move under you too: if the model a v5 response names stops matching its pin, record the new model as a new version and run its evals.
Hosted prompt dashboards that edit prompts live are fine only if they keep this history, give each change an ID your traces record, and run the same evals.
Send Every Call Through Its Version
A version names the call only if the app builds every call from it. So one loaded version travels from where it’s chosen, the server or the eval runner, to each function that currently reads the model register in model/config.js or the prompt file:
- In
server.js, runconst live = await loadVersion("v5");at startup and registerpromptVersion(live.id)on/ask. The trace field keeps its name, but the ID now names the whole call. - Pass
liveas a new last argument torequestBody()andwithFallback().requestBody()takesinstructions,tools, andmodels.answerfrom it and copies insettings. - In
withFallback(), callanswerWith(version.models[role])where it currently readsmodels[role].chainFor()still picks the order. - In each provider file’s
post(), takemaxOutputandanthropicVersionoff the request and sendmaxOutput ?? MAX_OUTPUTas the output limit. The judge and guard calls keepMAX_OUTPUTand the register’s other roles until they get versions of their own. - Pass
version: live.idandprovider: live.providertocacheKey()in place ofmodel,prompt, andsettings. The ID pins one model per role for each provider, so withoutproviderin the key, a provider switch would serve the other provider’s cached answers. - Give
evals/run.jsa--versionoption that defaults tov5. Have the runner pass the loaded version torequestBody()andwithFallback()so--routeand--role=fastuse its models. Writeversionandproviderat the top of each results file, and each answer’smodelas the response names it.
Step 4 differs by provider:
In model/openai.js, send max_output_tokens: maxOutput ?? MAX_OUTPUT, and don’t send anthropicVersion.
In model/anthropic.js, send max_tokens: maxOutput ?? MAX_OUTPUT, which every request needs, and the anthropic-version header from anthropicVersion, falling back to 2023-06-01, the value it sends now.
A trace now leads back to one version. Its streamAnswer span’s path says which role answered, and the model span names the model, even for a fallback answer.
Before you measure, paste versions/v5.js and your provider file’s post() into the mentor. If it finds a header or default the version doesn’t record, add it now, before any results name v5:
Measure v5, Then Write v7
One eval run isn’t enough to establish a baseline. During the model upgrade, the safety slice alone moved from 10 to 13 of 14 over five runs of one model.
So run npm run evals -- --version=v5 --runs=5, then the same with --route and with --beds, so the router’s fast model and the hut availability tool loop are graded too. Set v5’s results to the three files these commands save. Then check each file’s version, provider, and answer models, with scripts/check-version.js:
scripts/check-version.js
import { readFile } from "node:fs/promises";
import { loadVersion } from "../versions/index.js";
const result = JSON.parse(
await readFile(process.argv[2], "utf8"));
const v = await loadVersion(result.version)
.catch(() => null);
if (!v || v.provider !== result.provider) {
console.log(`No ${result.provider} version ${result.version}`);
process.exit(1);
}
const pinned = Object.values(v.models);
const wrong = result.answers
.filter((a) => !pinned.includes(a.model));
console.log(v.id, v.instructionsFile, v.models, v.settings);
console.log(`${wrong.length} of ${result.answers.length}`
+ " answers from a model this version doesn't pin");
Run node scripts/check-version.js with each results file’s path. It resolves the ID back to its prompt, models, and settings and counts answers from a model the version doesn’t pin, such as one the app still reads from the register because you missed a wiring step. That count must be 0.
Your number for this lesson is v5’s pass rate range over five runs of each eval command, lowest to highest, with the safety slice’s range and 0 mismatched answers. Later comparisons in this course start from those ranges.
Now write the autumn candidate. The ID v6 stays with the rejected trial, because old traces name it. The candidate is v7. Copy prompts/v5.txt to prompts/v7.txt and add this paragraph at the end:
prompts/v7.txt
From late September, huts close for the winter one by one.
When a report says a hut is closed, say so first, with the
report's date, and don't suggest staying there.
Copy versions/v5.js to versions/v7.js, and change its id to "v7", its instructions to "prompts/v7.txt", and its results to null, since v5’s runs say nothing about v7. Run the same three eval commands with --version=v7. Link the results whether they pass or fail, then check them. The check should print prompts/v7.txt and 0 mismatches.
That count covers only the models. The prompt path and settings the script prints are what v7 declares, and the calls could still have sent something else. So build one v7 request body from an eval case, as before, and confirm that its instructions end with the closures paragraph and its output limit is maxOutput.
v7 keeps v5’s models, settings, and tools, so only the instructions differ. From now on, a newer answer or router model is a new version file too, never an edit to model/config.js.
Check Your Understanding
- A teammate raises
maxOutputto600inversions/v5.jsand reruns the evals. What goes wrong, and what should they do instead? - A hiker reports a wrong answer, and its trace says
"promptVersion": "v7". Where do you find what produced it?
- Every trace and results file that says v5 now means one of two calls, and the cache serves old-limit answers under the same key. They should make a new version with its own ID, run its evals five times, and point
/askat it only if no slice falls below v5’s worst run, no safety case gets worse, and the extra output cost is worth it. - You can find the call in
versions/v7.js, which lists every part of it and links to its eval results. The trace adds thestreamAnswerspan’spathand the model the response names, which should match v7’s model for that path.
v7 changes one thing. If the eval cases and judge stay the same, a difference in its results that’s bigger than the spread across v5’s five runs points to the new instructions. In the next lesson, Change One Thing at a Time, you’ll see what happens when a version changes three things at once.