← all posts
suites·Lukas Babaliauskas·Aug 7, 2026·updated Nov 17, 2026·14 min read

Build a golden dataset for LLM evals from production traffic

Build a golden dataset for LLM evals from real agent runs: record with the capture SDK, promote to golden JSONL, and know what the pipeline drops and why.

To build a golden dataset for LLM evals from production traffic, record real agent runs with every model call, tool call and tool result, and redact them in process before anything is written. Then turn each recorded turn into a test case, drop the duplicates and broken runs, tag the cases while you still know what they represent, and freeze the file before you compare models against it. The rest of this post calls that frozen file the golden suite.

The recordings matter more than the tooling. A suite written from memory tests the cases you already handle, and the cases that break a model change mostly exist only as traffic. This post covers what a case has to hold, how to record without risking production, how to keep personal data out, what to do with multi-turn conversations, what to throw away and how many cases you need.

A disclosure: I build EvalShift, a tool for testing model changes on agents, and its capture SDK and CLI are how I do this. They have a short section at the end. Everything before it works without them.

Why record traffic instead of writing cases from memory?

Because a suite written from memory covers the happy path, and real traffic does not stay on it. You sit down with a blank file, imagine your users, and produce twenty prompts that look like the only part of the system you have a clear mental model of. The turn where the model drops a constraint set nine turns earlier, the ticket in a language your template never anticipated, the refund request phrased as a complaint: none of those get written down, because nobody remembers them as text.

Public datasets of real chatbot traffic show how wide the spread is. WildChat holds 1 million ChatGPT conversations with over 2.5 million turns ↗; it contains 68 languages that each appear in more than 100 user prompts, and English accounts for only 53% of its turns. LMSYS-Chat-1M ↗, one million conversations with 25 models from 210K unique IP addresses, spans 154 languages.

Your product's traffic is narrower than a public chatbot's, but its long tail is the same kind of thing: inputs nobody on the team would have thought to write. So record the traffic.

What does a golden case need to hold?

Everything required to replay one turn against a different model and score what comes back. Each field comes from a specific part of the recorded run, which is why the recording has to capture more than the prompt and the reply.

Case fieldTaken from the recordingUsed for
InputThe first model input of the turnWhat the candidate model is sent
HistoryThe messages list before this turnMulti-turn context, verbatim
Tools offeredThe toolset passed to the model callOffering the candidate the same choices
Expected tool callsThe calls the model requested, per roundTool selection and argument checks
Tool resultsThe recorded result of each callReplaying later rounds without live tools
Expected replyThe final output the user sawOutput checks and judges
TagsAdded when you promote a batchPer-slice analysis

Record what the model requested, not only what your app executed. Executed calls have been through your app's retries, filtering and reordering, so they show what the app did. A golden case has to state what a model should produce.

How do you record traffic without risking production?

Make the recorder fail open, and switch it on at runtime instead of at deploy time. Your function call should be the only statement it does not guard: return values and exceptions propagate exactly as if the recorder were absent. Every failure in its own bookkeeping (opening spans, serializing, writing) becomes a dropped recording and a debug log line, never an exception in the request path.

Read the on/off switch live on every call, so you can turn capture on for an hour on one host and off again without a deploy. Leaving the instrumentation in production is the intended end state, not a debugging phase.

A long-running host also needs limits so recording does not fill its disk. Three compose well: skip a recording whose input hash the suite already holds, keep only the newest N files per suite, and sample a fraction of runs, deciding before any bookkeeping so unsampled runs cost nothing. On a host recording for evals, also drop runs that never reached a model call: there is no model output to score.

Redact before anything hits disk

Recordings hold the inside of a run (tool arguments, tool results, model inputs and outputs), and in a support agent that means personal data on nearly every line. Redact in process, before serialization; masking files after they are written means the raw data already sat on disk. Make the redaction choice explicit at every recording point, so "verbatim was fine" and "never thought about it" can't look the same in code review.

Fail closed: a redactor that raises should drop the whole recording rather than write a half-masked one, and the agent itself should be unaffected. Pattern masking of emails, API keys and bearer tokens is a floor, not a PII scrubber. Even Microsoft's Presidio, a library built for this job, states ↗ that "there is no guarantee that Presidio will find all sensitive information", so structured secrets in your domain need a redactor written for them.

How do you record multi-turn conversations?

Record each turn as its own case, linked by a conversation ID and a turn index, and keep the full messages list. A multi-turn agent evaluated one isolated turn at a time is not being evaluated, and multi-turn is where models are weakest.

Laban et al. (2025) ↗ split fully specified tasks into pieces revealed over several turns and ran 15 LLMs through more than 200,000 simulated conversations. Every model did worse, with an average drop of 39% across six generation tasks. Aptitude fell by 16% on average while unreliability rose by 112%: once a model takes a wrong turn early, it gets lost and does not recover.

Three details decide whether the recordings are usable. Record the messages list rather than only the latest user string, so history replays verbatim instead of being reconstructed from sibling turns, which loses the intermediate tool exchanges. Fold the conversation identity into the key you deduplicate on, or short repeated turns like "yes" and "1pm" from different conversations collide. And check that the key varies at all: if every recording hashes the same empty input, dedup silently drops everything after the first.

How do you turn recordings into test cases?

Promote each recorded turn into a case using the mapping in the table above, then decide how much of the run each case replays and how strictly it is scored. Both are easier to start loose and tighten later than the reverse.

An agent turn is usually several rounds: the model calls tools, reads the results, calls more, then answers. Replaying only the first round is cheap and covers the opening tool choice. Replaying every round needs the recorded tool results, fed back teacher-forced: round k sees the prompt and the recorded rounds before it, never the candidate's own calls, so both models and the recording share identical context.

Each replayed round is another model call per case, so reach for full replay when the second round is the one you are worried about. For tool calls, you can match names only, names and arguments, or exact arguments plus the total number of calls. Start loose: a suite that fails on argument formatting teaches your team to ignore it.

What should promotion throw away?

Duplicates, crashed turns and turns that can't be replayed honestly. None of these drops is a bug, and they are the reason the resulting statistics mean anything.

DropWhy
Content-duplicate recordingsTwenty copies of "where is my order" make a comparison look far more certain than it is.
Turns that hit an errorA turn that died before the agent acted is not ground truth; promoting it asserts "no tool needed" on a question that needed one.
Replies claiming a tool action never taken"I've checked your order" with no lookup call would make a hallucinated action the expected answer.
Images, documents or audio in the inputA text replay can't carry them, so the case would test a different input.
Retried turns (same conversation and turn)Keep one, but warn rather than guess which retry is canonical.

Duplicates are the drop people argue with, and real traffic has plenty of them: LMSYS-Chat-1M's authors note ↗ that their unfiltered data contains "a significant amount of low-quality and duplicate data". Identical cases are a cluster with perfect correlation, and in Miller (2024) ↗ a perfectly correlated cluster "acts as a single independent observation". Count it twenty times and the error bars come out too narrow.

Miller measured how far off naive error bars get on real evals with grouped questions, scored on Anthropic models: clustered standard errors "can be over 3X larger than naive standard errors". Turns from one conversation are grouped the same way, which is one more reason not to inflate them.

Eval (Miller 2024, Table 4)Naive SEClustered SERatio
DROP0.441.343.05
MGSM0.86%1.62%1.88
RACE-H0.46%0.51%1.10

Seed dedup from the cases already in the suite, so it holds across promotion runs rather than resetting each time. That is what makes "capture for a week, promote daily" work.

How should you slice the suite?

Tag each batch when you promote it, because that is the moment you actually know what it represents; tagging later means reading JSONL and guessing. Then analyse every check once overall and once per tag, so "the migration regressed" becomes "the migration regressed on the multilingual cases and is flat everywhere else."

One trap before you tag six slices: two slices holding exactly the same cases restate one result as two findings. Under a multiple-comparison correction such as Benjamini-Hochberg, the extra copies of a p-value shrink every adjusted p-value in the family, which makes the correction anti-conservative. Collapse identical slices to one before any test runs.

How much traffic is enough?

Enough that every comparison you plan to read has enough paired cases, which is a smaller number than people fear and a larger one than a first week of capture usually gives. Run both models on the same cases and compare per case: pairing removes the variation between cases from the difference you measure.

Miller's paper gives the arithmetic. In its worked example, with model scores correlated at 0.5, paired differences cut the variance of the estimate by 1/3. Detecting a 3-point difference 80% of the time at a 5% false-positive rate then takes about 969 independent questions, which is why the paper suggests new evals contain "at least 1,000 questions". A migration gate looking for larger regressions gets by with fewer, but the arithmetic only runs one way: smaller effects need more cases.

The trap is that slicing multiplies the number of comparisons without adding cases. Six slices over sixty cases can leave every slice too small to test while the overall numbers look fine: a suite that appears to say nothing, when it is actually saying you cut it too thin. Add a slice when it has cases to fill it, not when the category feels important.

When do you freeze the suite?

Before the comparison starts, and again for every new batch. If cases are still being edited while two models run against them, the diff between the models is contaminated by the diff between the suites, and no amount of statistics separates those afterwards.

Commit the JSONL, review changes to it like code, and treat a new capture batch as a new version of the suite rather than a patch to the running one. The reward is that the suite outlives the migration it was built for: the next model bump, the prompt rewrite two quarters from now and the vendor's silent alias update all get measured against the same frozen set of real cases. That is the only way those comparisons are comparable to each other.

Doing this with EvalShift

Disclosure again: I'm the founder. EvalShift splits the job across two packages with one directory between them:

your agent (+ evalshift-sdk)  →  .evalshift/captures/<suite>/cap_<hex>.json
                                            │
                                  evalshift capture sync
                                            ▼
                              .evalshift/suites/<suite>/golden.jsonl

They never call each other: the SDK writes files and the CLI reads them. pip install evalshift brings evalshift-sdk along (import evalshift is the SDK; the CLI imports as evalshift_cli), so one environment can instrument the agent and run evals. A production agent that only records installs evalshift-sdk alone.

Recording. @capture.agent makes one invocation one capture file, and @capture.tool records each tool as a timed span that becomes a tool_call and a tool_result event. Both detect async def, and session state lives in contextvars, so tools under asyncio.gather keep the right parent.

python
from evalshift import capture, record_model_call

SUPPORT_TOOLS = [{"name": "lookup_order", "description": "Fetch one order by id.",
                  "input_schema": {"type": "object",
                                   "properties": {"order_id": {"type": "string"}}}}]


@capture.tool
def lookup_order(order_id: str) -> dict:
    return db.orders.get(order_id)


@capture.agent(suite="support", redact=True, tools=SUPPORT_TOOLS)
def handle_ticket(query: str) -> str:
    reply = call_model(query)
    record_model_call(model_id="claude-sonnet-5", tools=None,  # None: the decorator's toolset
                      input=[{"role": "user", "content": query}], output=reply)
    return reply

tools= is required on both and records what the model was offered; pass requested_tool_calls= to record_model_call too, and promotion scores against what the model asked for rather than what your app executed. Nothing is recorded until EVALSHIFT_CAPTURE is truthy (1, true, yes, on), read live on every call. Dedup on (suite, input_hash) is on by default, each suite directory keeps the newest 200 captures (capture_ttl adds age-based eviction), sample_rate is off by default, and configure(require_model_call=True) drops captures with no model_call.

Redaction. Since 0.3.0 redact= is a required keyword at every capture point, with no default and no process-wide setter. A redactor that raises drops the capture.

python
@capture.agent(suite="support", redact=True, tools=[])      # default_redactor
@capture.agent(suite="fixtures", redact=False, tools=[])    # verbatim, on purpose
@capture.agent(suite="clinical", redact=scrub, tools=[])    # your own callable

default_redactor masks emails, sk--style and AKIA keys, and Bearer tokens, and leaves structural metadata (tool names, model_id, token counts, timestamps) alone. Details in /docs/sdk-redaction.

Conversations. Since schema 1.1.0 the envelope carries conversation_id, turn_index and parent_capture_id. Decorator kwargs are fixed at decoration time, so every call would stamp the same turn_index; open one agent_session per turn instead.

python
conversation_id = f"conv_{uuid.uuid4().hex}"

for turn_index, user_text in enumerate(user_turns):
    messages.append({"role": "user", "content": user_text})
    with capture.agent_session(suite="scheduler", agent_input=messages, redact=True, tools=[],
                               conversation_id=conversation_id, turn_index=turn_index):
        reply = run_model(messages)
        record_model_call(model_id="claude-sonnet-5", tools=[], input=messages, output=reply)
    messages.append({"role": "assistant", "content": reply})
+

Always pass agent_input= to agent_session. It defaults to None, and the dedup registry keys captures on (suite, hash(agent_input)) — leave it unset and every session in the process hashes identically, so dedup silently drops every capture after the first.

Promotion.

bash
evalshift capture list          # what got recorded
evalshift capture sync          # promote everything → suites + wire config

sync groups captures by conversation_id, orders them by turn_index and builds one example per turn: first model input → inputs (a bare string lands under --input-var, default input), requested (else executed) tool calls → expected_tools, final output → expected, messages list → history. It writes golden.jsonl and rewrites the managed suites: block in evalshift.yaml between the >>> evalshift suites markers, so evalshift compare --suite-name <suite> finds it unwired.

Every round lands in expected_tool_rounds; --rounds first (the default, or captures.rounds in evalshift.yaml) replays round one and warns on multi-round captures. --rounds all writes tool_result_fixtures and replays teacher-forced. --strict-args demands exact arguments, --names-only ignores them, and --tool-count pins the total number of calls.

What sync skipsOpt-out
Content-duplicate captures--keep-duplicates
Turns with an error event--allow-errored, never asserting expected_no_tools
Replies claiming a tool call never made--allow-unbacked-claims
Image, document or audio contentNone
A first model_call with no recorded toolsetNone; re-capture
Duplicate (conversation_id, turn_index)Warning only; you pick the retry

Slices and thresholds. capture sync --tag refunds tags at promotion, every tag becomes a slice, and config adds a budget keyed by the tag:

yaml
migration_policy:
  slices:
    refunds:                 # an example tag
      max_overall_regression_rate: 0.0

Deltas are grouped per (prompt_id, evaluator_name, slice_name): fewer than 5 paired observations and a group is skipped as insufficient, between 5 and 20 it runs but is flagged uncertain, and Benjamini-Hochberg runs at 0.05 across every testable comparison. Identical slices collapse first: all and names under migration_policy.slices always survive, the provenance tag captured loses to an ordinary tag, then alphabetical order decides, and drops appear as collapsed_slices in analysis.json.

FAQ

What is a golden dataset for LLM evals? A golden dataset is a fixed set of test cases, each with an input and the expected behavior, that every model or prompt change is scored against. For an agent, each case also records the conversation history, the tools offered, the tool calls the model made and their results, so the turn can be replayed against another model.

How do you build an eval dataset from production logs? Record real runs with every model call, tool call and tool result, redacting before anything is written. Turn each recorded turn into a case, drop duplicates, errored turns and turns that can't be replayed, tag each batch, and freeze the file before comparing models.

How do you keep PII out of an eval dataset built from production traffic? Redact in process before a recording is serialized, make the redaction choice explicit at every recording point, and drop the whole recording if the redactor fails. Pattern masking catches emails and keys but not everything, so domain-specific secrets need a redactor written for them.

Should you deduplicate an eval dataset? Yes. Duplicate cases are not independent observations, so counting them more than once makes error bars too narrow and a comparison look more certain than it is. Deduplicate across every promotion run, not only within one.

How many examples does a golden eval suite need? It depends on the size of the difference you need to detect. Miller (2024) works through an example where detecting a 3-point difference 80% of the time takes about 969 independent questions; larger regressions need fewer cases, and every slice you analyse separately needs enough on its own.

Keep reading