Learn › Testing & Evaluating AI Agents and RAG › Build a Golden Test Set

Build a Golden Test Set

Intermediate 🕐 16 min Lesson 3 of 11
What you'll learn
  • Collect realistic test cases from logs, tickets, and manual checks
  • Cover typical, edge, adversarial, and negative cases
  • Write tasks that two experts would grade the same way
  • Maintain, version, and hold out part of a test set
  • Use a coverage grid to find untested areas

Start Small and Real

Teams often delay evals because they imagine they need thousands of perfect examples. Anthropic's engineering guidance says the opposite: 20 to 50 simple tasks drawn from real failures is a great start. Early in a project each change has a large effect, so even a small set reveals a lot. Anthropic's roadmap begins with the work you already do, such as the manual checks before each release, the bug tracker, and the support queue.

Where Test Cases Come From

  • Bug reports and support tickets — every complaint is a ready-made test case
  • Production logs — OpenAI's guidance says to log everything as you develop so you can mine the logs for good eval cases
  • Manual checks you already do — turn the questions you ask by hand before each release into tasks
  • Experts — ask the people who know the domain what hard questions look like
  • Synthetic cases — have a model draft variations, then review them by hand before trusting them

OpenAI lists these same sources as production data, expert-written data, synthetic data, and historical data. Never paste private user data into a shared test set. Remove names, emails, and account details first.

Mirror the Real Distribution

Anthropic's documentation says evals should be task-specific and reflect your real mix of inputs, including edge cases such as irrelevant input, very long input, and ambiguous cases where even humans disagree. OpenAI adds adversarial cases and gives concrete examples: ambiguous tool outputs, circular handoffs, jailbreak attempts, and prompt conflicts. If 70% of real traffic is simple lookups, most of your set should be simple lookups, with a deliberate slice of hard ones.

A quick way to check coverage is a grid with your task categories down the side and difficulty across the top. Empty cells show what you have not tested.

Test Both Directions

A set containing only "the system should do X" cases rewards a system that always does X. Anthropic calls out class imbalance and recommends balanced problem sets that include cases where a behavior should happen and cases where it should not. A RAG test set should include questions the documents cannot answer, where the correct behavior is to say so. An agent set should include requests the agent must refuse or must not act on.

Make Each Task Unambiguous

A good task has a clear input and a clear success condition, ideally with a reference solution that proves the task is solvable. Anthropic's test: two domain experts looking at the same output should reach the same verdict. If they disagree, the task is underspecified, not the model.

Anthropic's documentation shows what task-specific sets look like in practice. A sentiment eval uses 1,000 human-labeled tweets with deliberately hard cases such as sarcasm and mixed sentiment. A consistency eval uses 50 groups of paraphrased FAQ questions, including typos, rambling questions, and irrelevant information, to check that the answers stay the same. Notice that the hard cases are chosen, not left to chance.

Task fields to record: id, input, expected facts or expected source, forbidden behaviors, category tag, difficulty, and where the case came from.

Volume Versus Polish

Anthropic's guidance on design is to prioritize volume over quality: more questions graded by a slightly noisier automated method usually beat a handful graded perfectly by hand. The exception is the first 20 or so tasks. Write those carefully, because they define what "correct" means for the whole suite.

Keep It Alive

  • Store the set in version control, and tag versions so results stay comparable
  • Add every new production failure as a task, with its source
  • Keep a held-out slice you never tune against, so you can notice over-fitting to your own tests
  • Remove duplicates and tasks whose correct answer has changed

LangSmith's dataset features reflect the same ideas: examples with inputs and optional reference outputs, named splits for subsets, and automatic versions you can tag.

Try This

Create a file with 20 tasks for one feature: 12 typical, 5 edge cases, and 3 that should be refused or answered with "I don't know". Give each task an id, a category, and a source. Ask a colleague to answer five of them without seeing your expected answers. Where you disagree, fix the task. You will use this set for the rest of the track.

Key takeaways
  • 20 to 50 tasks from real failures is a strong start
  • Include cases where the right behavior is to decline or say I don't know
  • Balance should-happen and should-not-happen cases
  • Version the set, hold some back, and add every new production failure
Learn more every week Get 5 hand-picked prompts + new AI tools every Monday. Free.