Testing Prompts and AI Models in CI/CD
This lesson explains AI testing frameworks that combine deterministic checks with scored evaluations, so prompt and model changes can be tested automatically despite variable outputs.
Learning outcomes
After completing this lesson, you will be able to:
- Build a golden dataset.
- Combine deterministic checks with scored evaluations.
- Run prompt tests in the pipeline.
Golden datasets
Testing prompts and models starts with a golden dataset: representative inputs, including edge cases, each with an expected output, a reference answer or a scoring rubric. It is the fixed yardstick against which every candidate prompt or model is measured.
The golden dataset is versioned, so results can be compared over time; it grows as real failures from production are added, so the same mistake cannot return unnoticed; and it is kept separate from any data used for fine-tuning, because a model tested on its own training examples looks better than it is.
Golden datasets
Kinds of checks
Deterministic checks assert things that must always hold: output parses as JSON and matches a schema, required fields are present, classification labels are from the allowed set, responses stay under a length limit and contain no forbidden strings. Scored checks use metrics (exact match, ROUGE, semantic similarity) or LLM-as-a-judge rubrics for correctness, faithfulness and tone, with thresholds on the average and on failure rates. Safety tests run adversarial prompts for prompt injection, jailbreaks and data leakage, and check that guardrails intervene. Operational checks verify latency and token usage stay within budget.
The following diagram shows a response that broke a downstream JSON parser after a small prompt change, and the check that would have caught it.

Prompt test checks
Running tests in the pipeline
A CodeBuild step or Step Functions workflow runs the golden dataset through the candidate, or starts a Bedrock evaluation job with the dataset and judge metrics, then compares results with the current version. The pipeline fails if scores drop beyond a tolerance, so regressions are caught before release. Low temperature and several runs per test reduce noise. The following table summarises the checks.
| Check | Example assertion |
|---|---|
| Format | Valid JSON matching the schema in 100% of cases |
| Correctness | Judge correctness score >= 0.85 average |
| Regression | No more than 2% drop vs. current version |
| Safety | All injection prompts refused or blocked by guardrail |
| Cost and latency | Average output tokens <= 300; p95 latency <= 4 s |
A prompt change that broke parsing
An engineer adds "Be friendly" to an extraction prompt. In production, 6% of responses now start with "Sure! Here is the JSON:", which breaks the downstream parser.
A deterministic schema check on a 300-item golden dataset in the pipeline would have failed the change immediately. The team adds the check, plus an assertion that responses begin with {, and uses a structured output or tool-use schema to constrain the format. A judge-only evaluation would not have caught this, because the extracted values were still correct.
Why include adversarial prompts in a prompt test set?
Show answer
To check resistance to injection and jailbreak attempts.
Exam Tips
Remember for the exam
- Test prompts and models against a versioned golden dataset.
- Combine deterministic checks (schema, labels, length) with judge scores.
- Include adversarial prompts for injection and jailbreak resistance.
- Fail the pipeline on regressions beyond a tolerance.
- Add production failures to the golden dataset.