Sub topic 2
What changes: prompts, model versions, parameters, and context
This chapter assumes you can call an LLM API, write a prompt, run pytest, and read a GitHub Actions workflow. It names the four things that can change an LLM feature's behavior. It also shows how to make each one visible to your tests.
The four change surfaces
An LLM feature is a function with hidden inputs. The visible input is the user's text. Four other inputs shape the output, and any of them can change without a change to your application logic.
| Surface | Example change | Typical symptom |
|---|---|---|
| Prompt | Reworded instruction, new example, edited system message | Missing JSON keys, different tone |
| Model version | Alias moves to a newer snapshot, or you upgrade on purpose | Longer answers, new refusals, format shifts |
| Parameters | Temperature, max tokens, stop sequences, response format | Truncated output, more variance |
| Context | Retrieved documents, tool results, conversation history | Wrong facts, ignored instructions |
Prompts
Prompts change most often because editing them is easy. A one-line edit to fix one case can break ten others. Treat prompt files as code. Keep them in the repository, review them in pull requests, and trigger evals when they change.
Prompts are also assembled at runtime. A template that inserts a user field or a list of examples produces different final text for each input. Test the rendered prompt as well as the template.
Model versions
Many providers offer aliases such as a "latest" name that point to a new snapshot over time. If your code uses an alias, the model can change under you with no commit in your repository. Your tests then fail on a day when nobody touched the code.
A dated snapshot name stays fixed until the provider retires it. Retirement still forces an upgrade, so plan for it. Later chapters cover pinning and drift detection. For now, make the model name an explicit setting, and record it with every result.
Parameters
Parameters change the output without touching the prompt. Lowering max_tokens can cut a JSON object in half. Raising temperature increases variance, which affects how you set pass thresholds. Changing the response format setting can alter how strictly the model follows a schema.
Because these values often live in config files or environment variables, a deploy can change them without a code review. Put them in one place and include them in your test run.
Context
Context is whatever your code adds to the prompt: retrieved passages, tool output, prior messages, and system-level data such as the current date. A change to the search index, chunk size, or history truncation changes what the model sees. Failures from context changes often look like model errors, so check the inputs first.
Making changes visible
Build one configuration object that holds every surface. Your wrapper reads it, and your tests log it.
import hashlib
import json
from dataclasses import dataclass, asdict
from pathlib import Path
@dataclass(frozen=True)
class RunConfig:
model: str
temperature: float
max_tokens: int
prompt_path: str
retrieval_top_k: int
def prompt_text(self) -> str:
return Path(self.prompt_path).read_text(encoding="utf-8")
def fingerprint(self) -> str:
payload = asdict(self) | {"prompt": self.prompt_text()}
blob = json.dumps(payload, sort_keys=True).encode("utf-8")
return hashlib.sha256(blob).hexdigest()[:12]The fingerprint covers the prompt text, not only its path. Edit the prompt and the fingerprint changes. Store it next to each result. When a pass rate shifts, compare fingerprints between the good run and the bad run to see which surface moved.
The fingerprint does not cover the provider's silent model updates behind an alias. That is why you pin a dated model name, as described above.
A practical checklist
- Keep prompts in version-controlled files.
- Set the model to an explicit name, not an alias, where the provider allows it.
- Keep parameters in one config and log them.
- Make context sources testable with fixed inputs.
- Run evals when any of these files change.
Exercise
A test that passed yesterday fails today. No prompt file changed, and the code uses the model alias "latest". Name two change surfaces that could explain it and one way to tell them apart.
Show answer
The alias may now point to a newer model snapshot (model version), or a config or environment change may have altered temperature or max tokens (parameters). Context from retrieval could also have changed. Compare the logged RunConfig fingerprints and model names between the passing and failing runs. A different model name or parameter value identifies the surface, and an identical fingerprint with a different result points to an alias that moved or to changed context.