Testing an AI workflow before deployment means running it against a fixed set of trusted test cases, scoring every output, and refusing to ship when the score drops below a threshold. The test set is the golden dataset, the scoring comes from evaluators, and the refusal is a regression gate in your CI pipeline. Together they answer a question a demo cannot: did this change break anything that already worked?
This guide is for practitioners who already have an AI workflow in production or close to it — a prompt chain, a retrieval pipeline, an agent, or an automation that calls a model — and who want a repeatable way to check changes before users see them. The concepts here are tool-agnostic; the implementation detail follows Langfuse’s published guidance, where datasets, experiments, and traces live in one place.
What a golden dataset is, and what makes it “golden”
A golden dataset (also called a gold set or reference set) is a collection of test cases where each item records an input your application should handle and, usually, a reviewed definition of what a correct response looks like. “Golden” means the items are curated and trusted: someone with domain knowledge confirmed the expected output, or deliberately decided the item does not need one because a reference-free check — format, safety, tone — is the pass criterion.
That trust is the entire value. When an experiment against the golden dataset shows a score drop, you want to act on it rather than argue about whether the test case was fair. A set assembled from whatever prompts happened to be lying around does not give you that, and neither does a set nobody has reviewed since it was written.
Scope the set to one behavior, then size it for its job
Good golden datasets are scoped to one component or behavior. A dataset that mixes summarization quality, tool selection, refusal behavior, and formatting into a single score produces a number nobody can act on, because a drop does not tell you which part broke.
Size follows purpose rather than ambition:
- Tens of items are enough for a fast pull-request gate — a check that runs in minutes and catches obvious breakage before a merge.
- Hundreds to a thousand items suit a full regression set that you run less often and trust more broadly.
Cover your known failure modes explicitly. The cases that already burned you once are the cheapest, highest-value items you can add, and they are the ones a synthetic generator is least likely to invent on its own.
Build it from production traces first
The recommended order of sourcing is real traces first, CSV imports and synthetic generation second. Real traces have two advantages: they reflect the inputs your users actually send, and they come with the surrounding context — retrieved documents, tool calls, intermediate steps — that you need to reproduce a failure.
A workable build sequence looks like this:
- Collect traces that represent the behavior you are testing, including the ones that went wrong.
- Redact or replace sensitive content before the items leave your environment.
- Write the reviewed reference output for each item, or record explicitly that a reference-free check is the pass criterion.
- Import the set as a versioned dataset so experiments can be pinned to it.
- Deduplicate, and validate the schema of every item as it enters the set.
Steps 3 and 5 are where most of the effort sits, and they are the reason a golden dataset is a maintenance commitment rather than a one-off script.
Choose evaluators that match the shape of the output
Once the dataset exists, every item needs a way to be scored. Langfuse’s regression-testing guidance splits evaluators into two families, and the split is practical rather than theoretical:
- Deterministic checks — exact-match or code-based assertions — for structured outputs and business rules, where there is one right answer or a checkable constraint.
- Semantic evaluation — including an LLM judge — when valid answers can differ in wording and a string comparison would produce false failures.
Most mature workflows use both. Deterministic checks are cheap, stable, and explain themselves when they fail. An LLM judge covers the cases where meaning matters more than phrasing, but it is itself a model, so it introduces its own variability and cost; keep it scoped to the items that genuinely need it.
Turn scores into a gate that can actually block a merge
An evaluation that nobody reads is not a test. The gate is what makes the dataset load-bearing: the workflow runs against the golden dataset, every output is scored, and the run raises a RegressionError when an aggregate score misses your threshold.
In GitHub Actions, langfuse/experiment-action runs that script against a Langfuse dataset, posts the scores as a pull-request comment, and fails the job on regression. If you already trace with Langfuse, the gate needs no new services — the same SDK and the same API keys cover it.
One scoping decision matters more than the tooling: test the application function or workflow that produces the behavior you care about, not a thin wrapper around the model. A gate that calls the model directly will pass while the real pipeline — retrieval, prompt assembly, post-processing — is broken.
Know which changes must trigger a run
A regression gate should run whenever any component that shapes outputs changes. The trigger list is broader than most teams assume:
- Prompt edits, including a new version of a prompt managed outside the codebase.
- Model swaps and provider model upgrades, where the same prompt can behave differently.
- RAG and retrieval changes, such as a new chunking strategy or embedding model.
- Tool and agent changes, where a reworded tool description shifts an agent’s behavior.
The last two are the ones people miss. A retrieval tweak that improves recall can still degrade answers if the newly retrieved chunks crowd out better context, and a tool description is effectively a prompt.
Compare prompt versions without fooling yourself
To compare two prompt versions, run one experiment per version against the same pinned dataset version and read the score deltas against a designated baseline. Pinning matters: if the dataset grows or changes between runs, a delta reflects the dataset edit as much as the prompt change, and the comparison becomes uninterpretable.
Designate the baseline explicitly rather than treating “last week’s run” as the reference. When a new version wins, promote it to baseline deliberately, so the history of what you consider acceptable stays readable.
Maintain the set or watch it decay
Building a golden dataset is not hard; keeping one representative for six months while prompts, models, and users all change is the part most teams get wrong. A frozen set slowly stops describing your application, and a set that quietly drifts stops being comparable across runs.
Three maintenance practices carry most of the weight:
- Schema validation on every item entering the set, so malformed cases fail loudly instead of scoring as zero.
- Deduplication, so near-identical items do not silently dominate the aggregate score.
- Item versioning, so you can tell whether a score change came from the system or from the test set.
Then grow the set from production failures instead of leaving it frozen. Every incident that reaches a user is a candidate item, and adding it is how the dataset stays aligned with what your application must handle.
An illustrative scenario
The following is a constructed example, not a reported test result. A team maintains a retrieval-augmented assistant that answers questions from internal documentation. Their golden dataset holds roughly forty reviewed items in the fast gate: questions with exact expected citations, questions where any correct paraphrase passes, and a handful of questions where the correct behavior is to say it does not know.
An engineer edits the system prompt to make answers more concise. The gate runs, deterministic citation checks pass, and the semantic score on paraphrase items holds steady — but the “does not know” items now produce confident invented answers. The aggregate score drops below threshold, the job fails, the scores appear as a pull-request comment, and the engineer sees which category moved. Without the dataset, that edit would have shipped as an improvement.
Where this fits for local and self-hosted workflows
The same structure applies when the model runs on your own hardware or inside an automation platform rather than behind a hosted API. If anything, the trigger list gets longer, because you control more of the stack: a quantized model file, a runtime upgrade, or a changed retrieval step are all changes that can shift outputs. The dataset, the evaluators, and the threshold travel with the workflow, and the gate runs wherever the workflow runs.
For automation platforms and WordPress-based workflows that call a model, the practical constraint is usually where the test set lives and how the gate is invoked. Keeping the dataset in the same place as your traces avoids a second source of truth, and keeping the gate script runnable from a command line means it can be called from CI, a scheduled job, or a pre-deploy hook.
Limitations and tradeoffs to plan for
A golden dataset is a measurement instrument, and like any instrument it has error. Reviewed reference outputs cost domain-expert time, which is the scarcest input in the process. An LLM judge adds cost and variance of its own. A single aggregate score can hide a regression concentrated in one subcategory, which is why scoping datasets to one behavior and reading per-category results matters more than tuning the threshold.
There is also a ceiling: passing the gate means the change did not degrade performance on the cases you thought to include. It is evidence, not proof, and it does not replace monitoring after deployment.
What to do next
Pick one workflow and one behavior. Pull a few dozen real traces, redact them, and write reviewed reference outputs or explicit pass criteria for each. Run your current version against that set and record the scores as your baseline. Then wire the same script into your CI pipeline so the next prompt edit has to earn its merge. If you get stuck on a specific step — choosing evaluators, pinning dataset versions, or getting the gate to run in your environment — share your workflow, your setup, and the exact error in the community so others can compare notes.
FAQ
How many test cases does a golden dataset need?
It depends on the job. Tens of items are enough for a fast pull-request gate that runs quickly, while hundreds to a thousand items suit a full regression set. Scope the set to one component or behavior so the score stays actionable.
Can I build a golden dataset from synthetic examples?
You can, but real traces should come first, with CSV imports and synthetic generation as secondary sources. Real traces reflect the inputs users actually send and carry the context needed to reproduce failures.
Do I need additional infrastructure to run the gate in CI?
Not if you already trace with Langfuse. The gate uses the same SDK and API keys, and in GitHub Actions the experiment action runs the script against a dataset, posts scores as a pull-request comment, and fails the job on regression.
What should trigger a regression run?
Prompt edits, model swaps and provider model upgrades, RAG and retrieval changes such as new chunking strategies or embedding models, and tool or agent changes including reworded tool descriptions.