A test suite only covers the questions you thought to write down. Your users ask other ones. The fastest way to close that gap is to build LLM test cases from production: capture real conversations, pick the ones that matter, and add them to the suite so every later pull request is checked against them. Drift-CI now does this end to end. drift-ci.com captures conversations from your app, and a selection becomes either a pull request against your repository or a JSONL file for drift-ci import.
Why build LLM test cases from production
Hand-written cases drift away from reality. They reflect what the team expected people to ask when the suite was written, phrased the way engineers phrase things. Production is messier: long rambling messages, typos, two questions in one, topics nobody planned for. Those are exactly the inputs where a prompt edit or a model upgrade breaks something.
A golden dataset built partly from production fixes that, as long as you keep three things in mind:
- Pick, don't dump. A thousand near-identical "where is my order?" conversations make a slow, expensive suite that tests one thing. Choose a spread: common requests, awkward phrasing, edge cases, and replies that went wrong.
- The production reply isn't automatically right. Each imported case stores the reply your app actually gave as its
expectedanswer. Where that reply was wrong, editexpectedto what it should have said before you accept the baseline. - Conversations contain personal data. Secrets are redacted automatically; names, emails and addresses are not. Review every case before it lands in your repository.
Step 1: send conversations to drift-ci.com
Create a Production traces token for the project. It can only post traces, so it's safe to give your app. Then post each conversation once the model has replied. The Traces tab shows snippets for JavaScript, Python and curl; in JavaScript, after an OpenAI call:
const completion = await openai.chat.completions.create({ model, messages });
const reply = completion.choices[0].message.content;
// Fire and forget: a failed post never affects your app.
fetch("https://drift-ci.com/api/v1/traces", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DRIFT_TRACES_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
messages: [...messages, { role: "assistant", content: reply }],
model: completion.model,
tags: ["production"],
}),
}).catch(() => {});A trace is a chat conversation in OpenAI shape (messages with system, developer, user and assistant roles) or Anthropic shape (a top-level system plus messages), with optional model and tags. You can send one per request or up to 100 as { "traces": [...] }, each up to 64 KB. The same conversation posted twice is stored once.
Each trace is converted to a test case the moment it arrives, and common secret formats are redacted then: AWS access keys, Anthropic and OpenAI API keys, GitHub and Slack tokens, JWTs and PEM private keys become [REDACTED:<kind>]. Traces are kept for 30 days, up to a per-project cap that depends on your plan.
Step 2: pick the conversations worth keeping
The Traces tab lists captured conversations newest first, with the first user message, the reply, tags, model and how many secrets were redacted. Search across the conversation text, filter by tag, model and time range, and open any trace to read the whole conversation.
Good candidates:
- Requests your suite doesn't cover yet, such as a new product area or a kind of question support keeps seeing.
- Awkward inputs: very long messages, several questions at once, mixed languages, an ID buried in a paragraph.
- Bad replies. A conversation where the model got it wrong is a valuable test, once you've fixed its
expectedanswer. - Replies you want to protect. A tricky question the model currently handles well is worth pinning, so a future change can't quietly break it.
Tick the ones you want. From there you can open a pull request, download them as JSONL, or copy them as suite YAML.
Step 3: open a pull request with the new cases
If the project is linked to a GitHub repository, Open PR adds up to 100 selected traces to your suite in one step. drift-ci.com reads .drift/config.yaml from your default branch to find the suite (or uses .drift/suite.yaml), appends the new cases, and opens a pull request from a drift-ci/traces-… branch. Comments in your existing suite are kept, and cases already in it are skipped, so selecting the same trace twice is harmless.
Each case looks like this:
- id: prod-3f9a1c0e7b2d
systemPrompt: You are the support assistant for an online shop. …
input: "hi, i ordered a kettle last week (ORD-48213) and it still hasn't come, can i cancel and get a refund??"
expected: "Sorry it hasn't arrived yet. I've checked ORD-48213 and it hasn't shipped, so I can cancel it…"
tags: [imported]The ID is a hash of the conversation, the system prompt becomes systemPrompt, and the final assistant reply becomes expected. A conversation with more than one user turn becomes a messages case instead of input.
The PR description lists the added case IDs and reminds the reviewer to check for personal data. From there it's an ordinary Drift-CI pull request:
- Review the cases. Fix any
expectedanswer that's wrong, and remove anything you shouldn't store. - CI runs the suite. The new cases have no baseline yet, so they're marked "no baseline" rather than counted as regressions.
- Record their scores with
drift-ci baseline accept .drift/suite.yaml --alland commit.drift/baseline/in the same PR.
Imported cases are scored against the production reply, so the suite needs an evaluator that compares with expected usefully: llm-judge or cosine-similarity. A new suite is created with llm-judge, and the PR description warns you when your suite's evaluators won't use the reply.
Or import from the command line
You don't need the GitHub link, or drift-ci.com at all. Download JSONL gives you one conversation per line, which the open-source CLI turns into cases:
drift-ci import traces.jsonl --dry-run # print the YAML that would be added
drift-ci import traces.jsonl --evaluator llm-judge # add the cases to your suitedrift-ci import reads the same OpenAI and Anthropic shapes, so it also works with logs exported from any other tool. It applies the same redaction and the same hashed IDs, so importing a file twice adds nothing new. Conversations it can't use, such as ones with tool calls or images, are skipped and listed with their line numbers.
Keeping the suite useful
Capture is cheap; suite runs aren't free. Every case costs a model call, and a judge call if it uses llm-judge, on every pull request. A few habits keep a production-fed suite healthy:
- Add in small batches after reviewing them, not hundreds at once.
- Tag by source or topic in your traces, so you can filter for the area you're working on.
- Delete cases that stop earning their place, such as duplicates of a pattern you already cover.
The LLM regression testing guide covers building and maintaining a golden dataset in more depth. Prompt regression testing shows what the pull-request check looks like once the cases are in, and the GitHub Actions tutorial sets the workflow up.