Sub topic 2
What changes: prompts, model versions, parameters, and context
This chapter assumes you can call an LLM API, write a prompt, and read a basic pytest file. It also assumes you can read a GitHub Actions workflow. The previous chapter explained why LLM features regress silently. This chapter lists what can change, so you know what to track and which edits should trigger your eval suite.
An LLM feature is a function with more inputs than the code suggests. The visible input is the user's text. Several other inputs sit in config files, prompt templates, retrieval indexes, and the provider's servers. Any of them can change the output. If your tests only run when Python files change, most of these changes slip through.
The surfaces that can change
Group the inputs into five surfaces. Each has a different owner, a different change cadence, and a different way of showing up in your repository.
| Surface | Example change | Who makes it | Visible in a pull request? |
|---|---|---|---|
| Prompt text | Rewording an instruction, adding a rule, reordering examples | Developers, prompt authors | Yes, if prompts live in the repo |
| Model version | Switching `model-a` to `model-b`, or a provider updating an alias | You, or the provider | Only if you change the string |
| Parameters | Temperature, top-p, max tokens, stop sequences, response format | Developers | Yes, if kept in code or config |
| Context | Retrieved documents, tool results, conversation history, system data | Data pipelines, content teams | Often no |
| Surrounding code | Output parsers, pre-processing, truncation, retry logic | Developers | Yes |
The last row is easy to forget. A parser that trims whitespace differently, or a truncation helper that now cuts at 3,000 characters instead of 4,000, changes what the model sees or what your users receive. Treat that code as part of the prompt pipeline.
Prompt changes
Prompt edits are the most frequent source of regressions, and they feel harmless because they are plain text. Common patterns:
- Fixing one case breaks another. You add "Always answer in two sentences" to fix a verbose reply. A different case that needs a numbered list now gets a cramped paragraph.
- Instruction conflicts. A new rule contradicts an old one. The model picks one at random, and the choice varies by input.
- Example drift. Few-shot examples teach format as well as content. Changing one example can change the output shape for every request.
- Template variable errors. A renamed placeholder such as
{customer_name}becomes{name}in one place. The model receives a literal brace string and tends to carry on without complaining. - Whitespace and ordering. Moving the user's question above the instructions, or changing delimiters, can shift behavior more than rewording does.
The last two are why a "small cleanup" of a prompt file still needs a suite run. Review the rendered prompt, not only the template. Your tests should send the same fully rendered text that production sends.
Model version changes
There are two kinds of model change, and they need different defenses.
Deliberate changes happen when you edit the model name. You might upgrade for quality, switch to a cheaper tier, or move to another provider. These show up in a pull request, so CI can run on them. Expect shifts even on a "better" model. A newer model may follow instructions more literally, add more caveats, return slightly different JSON formatting, or refuse requests the old one accepted.
Silent changes happen when you did not edit anything. Two common causes:
- You use a floating alias such as
latestor a name without a date. The provider repoints it to a new snapshot. - The provider retires a snapshot and forwards requests to a successor.
Silent changes are why a suite that passed on Friday can fail on Monday with no commits in between. The remedy is to pin a dated snapshot where the provider offers one, and to run the suite on a schedule so you notice when behavior moves anyway. A later chapter covers pinning and drift detection. For now, record the exact model identifier with every run so you can tell which kind of change you are looking at.
Parameter changes
Parameters change how the model samples and formats its answer. They rarely get the review that prompts do.
- Temperature and top-p control randomness. Raising temperature from 0 to 0.7 for "more natural" replies increases variance. A check that passed every time may now pass 90% of the time.
- max_tokens caps output length. Lowering it to save money truncates long answers. Truncated JSON fails to parse, which a format check will catch only if you include long-output cases.
- Stop sequences end generation early. A stop string that appears inside legitimate output cuts the reply short.
- Structured output or JSON mode settings change how strictly the format is enforced. Turning them on or off changes failure modes.
- Seed, where supported, reduces variation but does not guarantee identical output. Providers state that determinism is best-effort. Do not rely on a seed to make a test exact.
Parameters often live in a config file or an environment variable. Include that file in the CI path filter, or a change to temperature: 0.2 will never trigger a run.
Context changes
Context is everything you insert around the user's request: retrieved passages, tool results, account data, conversation history, and system messages built at runtime. It can change without anyone touching the prompt or the model.
- A retrieval index is rebuilt with new documents, so the model sees different passages for the same question.
- A knowledge-base article is edited, and the answer that quoted it changes.
- An upstream API adds a field to its response, and your formatter passes it into the prompt.
- Conversation history grows until older turns are truncated, and the model loses an instruction that sat near the top.
For retrieval-based features, decide what your regression suite is testing. If you want to isolate prompt and model behavior, store the retrieved context inside each test case as a fixed snapshot. If you want to test the whole pipeline, run real retrieval, accept more variance, and tag those cases so you can read their failures separately. Many teams do both: a fixed-context suite on every pull request and an end-to-end suite on a schedule.
Surrounding code changes
Code around the call also counts. Examples are a refactor of a message builder, a new input sanitizer, a changed retry policy, or a switched JSON library. Your model call may be identical, but the text sent in or the way the response is read has changed. Running the suite through the same wrapper function production uses (the run_prompt function in the golden-dataset test) means these changes are covered. A test that calls the provider SDK directly bypasses them.
Recording what a run used
When a failure appears, the first question is "what changed?" You can answer it quickly if every run saves a manifest of its inputs. The script below hashes the prompt file and any context files, records the model and parameters, and compares two manifests.
import hashlib
import json
import tempfile
from dataclasses import asdict, dataclass
from pathlib import Path
@dataclass(frozen=True)
class RunConfig:
model: str
temperature: float
top_p: float
max_tokens: int
prompt_path: str
def sha256_file(path):
return hashlib.sha256(Path(path).read_bytes()).hexdigest()[:12]
def build_manifest(config, context_files=()):
manifest = asdict(config)
manifest["prompt_sha256"] = sha256_file(config.prompt_path)
manifest["context_sha256"] = {
str(p): sha256_file(p) for p in sorted(context_files)
}
return manifest
def changed_fields(old, new):
keys = sorted(set(old) | set(new))
return {k: (old.get(k), new.get(k)) for k in keys if old.get(k) != new.get(k)}
if __name__ == "__main__":
with tempfile.TemporaryDirectory() as tmp:
prompt = Path(tmp) / "summarize.txt"
prompt.write_text("Summarize the text in two sentences.", encoding="utf-8")
before = build_manifest(
RunConfig("model-a-2025-01-15", 0.0, 1.0, 400, str(prompt))
)
prompt.write_text("Summarize the text in one sentence.", encoding="utf-8")
after = build_manifest(
RunConfig("model-a-2025-01-15", 0.7, 1.0, 400, str(prompt))
)
print(json.dumps(changed_fields(before, after), indent=2))Running it prints two differences: the temperature changed from 0.0 to 0.7, and the prompt hash changed. If both changed in one pull request and the pass rate dropped, you cannot tell which one caused it. That leads to the main working rule of this chapter.
Change one surface at a time
When a pass rate drops after a change, you want to attribute it to a cause. Attribution is easy when only one surface moved and hard when several moved together.
- Run the suite on the unchanged base commit to get a current baseline. Do not trust an old number, because silent model changes may have moved it.
- Apply a single change, such as the new prompt with the old model and parameters.
- Run again and compare.
- If you need several changes, apply them in separate commits, each with its own run.
A model upgrade combined with a prompt rewrite is the usual trap. The rewrite may have been needed to fix the upgrade's side effects, so the combined result looks fine and hides which part did the work. When you must change both, record the pass rate for each step.
Making CI notice every surface
CI only helps if it runs when something relevant changes. The workflow in the spine triggers on prompts/**, evals/**, and app/**. Check that this list covers all five surfaces:
- Prompt templates: covered by
prompts/**. - Model name and parameters: covered only if they live under one of those paths. A top-level
config.yamlorsettings.tomlneeds its own entry. - Context files or retrieval configuration: add the directory that holds fixtures or index settings.
- Dependency changes: a bumped SDK version in
requirements.txtcan change defaults, such as the default model or retry behavior. Addrequirements.txtas a trigger.
A path filter cannot detect provider-side changes. For those, you need the scheduled run described in a later chapter.
Common errors
- Testing a different configuration from production. The suite hard-codes temperature 0 while production uses 0.7. The suite passes and users see failures. Read settings from the same source.
- Forgetting indirect edits. Context files, config, and dependencies sit outside the usual code directories and never trigger a run.
- Trusting an old baseline. The stored pass rate was measured on a model snapshot that no longer exists. Re-measure before comparing.
- Bundling changes. Several surfaces change in one commit, so a regression cannot be attributed.
- Reviewing templates, not rendered prompts. A variable fails to substitute and nobody sees the literal placeholder in the model input.
Exercise
A teammate opens a pull request that changes temperature from 0 to 0.8 in settings.toml and rewords one sentence in prompts/support.txt. The CI workflow triggers on prompts/**, evals/**, and app/**. The pass rate drops from 96% to 88%. Name two problems with how this change is set up for regression testing, and say what you would do about each.
Show answer
First, the change bundles a parameter edit and a prompt edit, so the drop cannot be attributed to either. Split it into two commits and run the suite after each, starting from a fresh run on the base commit. Second, settings.toml is outside the path filter. This run only triggered because the prompt file also changed. A parameter-only pull request would not run the suite, so add settings.toml to the workflow's paths list. You should also consider that temperature 0.8 raises variance, so the suite may need repeated runs, which a later chapter covers.
Exercise
Your suite passed on Friday. On Monday it fails on several cases, and git log shows no commits. Which surface is the most likely cause, what in your setup makes it possible, and what should you record in each run to confirm it?
Show answer
The model version is the most likely cause. The model string is probably an alias such as latest or has no date, so the provider can repoint it to a new snapshot. Pin a dated snapshot where one exists. To confirm the cause, record the exact model identifier returned with each response, along with parameters and prompt hashes, then compare Friday's manifest with Monday's. If the prompt and parameter hashes match and only the model identifier differs, the model changed.