Your AI feature gave good answers in the demo. Then a real user asked something nobody tried. The answer read well, and it was wrong. Nothing raised an error.
Most teams check an AI change the same way. Someone asks five questions, reads five answers, says "looks fine" and ships it. That misses the answer that breaks.
An eval is a test for an AI feature. You build it from real answers your app gave. A person marks each one pass or fail, and writes why. Some cases must pass before any release.
In this workshop you build one for a real app. Today's change is a cheaper model, but the same test checks any change: a new prompt, a new tool or new data. At the end, one command says yes or no. A no names the case that broke.
- Product managers. You wrote "the assistant answers accurately", and nobody can say if one answer meets it. Here you turn that line into cases that pass or fail.
- Engineers. Today each model or prompt change is a guess. Here you get a test that says what got worse, and in which case.
- Not for you if you want one score, such as "helpful: 4.2 out of 5". A score like that does not tell you what to fix.
| App | What it does | Where its traces and tests live |
|---|---|---|
| Marketplace analyst | Answers questions about a shop's orders by writing SQL | Langfuse |
| Expense agent | Reviews expense claims of $100 or more, then waits for a person | Google ADK's own tools |
Both apps go through the same five steps. First you look at real answers and name the ways they fail. Then you define what a good answer must do, as yes or no. You measure how many cases pass on each setup. Last, the gate says no if a case that must pass has failed.
With the analyst you go one step further. A trace is the record of one run: each step, its time and its cost. You watch live traces after a release, and add each new failure to the test set.
| Part of the loop | Where you do it |
|---|---|
| Trace each run | Steps 4 and 15 |
| Build a test set from failures | Steps 5, 6 and 12 |
| Try a change and score it | Steps 7 to 10, then 13 |
| Deploy and compare | Step 14 |
| Watch live answers | Step 11 |
- Docker, running.
- Bun 1.3 or newer.
- uv for the Python app.
- A provider key (Anthropic or OpenRouter). You put it in
.env, and setup copies it into Langfuse.
Every model call costs money. The prices of the runs below are what they cost us.
- Clone the repo and install the packages.
git clone https://github.com/learnwithparam/ai-evals-workshop.git
cd ai-evals-workshop
bun installExpect: the install ends with no error.
- Set up Langfuse, the gateway and the database.
bun run setupExpect: the first time, it writes .env and stops. Put your key in .env as ANTHROPIC_API_KEY (or OPENROUTER_API_KEY with MODEL_PROVIDER=openrouter).
Run setup again. In Langfuse it makes the gateway connection, a gateway key and the AI judge's connection, workshop-judge. It also adds the prices of the two models. It ends with Done. If Langfuse is ever reset, run setup again and it makes them anew.
If a Langfuse already runs on your machine with the gateway on port 3031, setup uses it. Put that project's keys in .env.
- Run every check that needs no model.
bun run checkExpect: All checks passed.
Read these beside the steps. Each one shows what you should see and why it matters.
The candidate is a cheaper model with two shorter prompts. These two settings pick it:
export ANALYST_MODEL=claude-haiku-5-5 ANALYST_PROMPTS=short- Look. Ask the candidate 18 questions and put the answers in a review queue.
bun run reviewExpect: 18 answers are in the queue "analyst-review". Ours cost about US$0.08.
- Name and define. In Langfuse, open Human annotation, then
analyst-review. Read each answer.analyst-mark: pass or fail. Then press the speech bubble beside it and write one line on why.analyst-blocks: true if this case must pass before any release.analyst-failure-mode: for a fail, a short name for the way it failed.
Mark at least 10 answers, or the AI judge in step 7 cannot be trusted.
No time to mark? bun run marks adds the marks for the faults we found, and they replace your own. Your answers differ a little from ours, so read them anyway.
- Turn the marks into a test set.
bun run datasetExpect: 18 marked answers and 3 safety cases are in "analyst-gold". Then the count of each way it failed.
- See if the AI judge agrees with you. It is a Langfuse evaluator that reads each answer that ran a query.
bun run judgeExpect: The judge agrees on N of 18. It counts in the gate only if it catches every answer you failed and agrees on at least 9 in 10. Its rules are in judge.md. Change that file, not the copy in Langfuse. Find it under Evaluators as analyst-judge.
- Measure and gate the candidate.
bun run gateExpect: NO, do not ship., the cases that block it and a link to the run. Ours blocked the monthly orders chart and the top categories.
- Gate today's setup the same way.
unset ANALYST_MODEL ANALYST_PROMPTS
bun run gateExpect: YES, safe to ship.
Each gate is a Langfuse experiment on the dataset analyst-gold. Open Experiments, pick both runs and press Compare. Each case shows code_checks and judge_verdict side by side.
- Fix and run it again. Add these two lines to the end of sql-agent.short.md.
- Label a month as YYYY-MM.
- Do not filter out rows the question did not ask to leave out.
ANALYST_MODEL=claude-haiku-5-5 ANALYST_PROMPTS=short bun run gateExpect: YES, safe to ship. Ours passed 18 and then 20 of 21. A model varies, so read any case that still blocks.
Put the prompt back when you are done:
git checkout 13-marketplace-analyst/agent/prompts/sql-agent.short.md- Monitor live answers. Start the app on the setup the gate refused, as if someone had shipped it.
ANALYST_MODEL=claude-haiku-5-5 ANALYST_PROMPTS=short bun run devOpen http://localhost:3112, create an account and ask How many orders were purchased each month in 2018?
Expect: in Langfuse, under Scores, a new analyst-judge row for your question. Ours was False: each month showed as a date and time. The judge reads every live question that ran a query. Under Scores, then Analytics, pick analyst-judge to see pass and fail over time.
- Add the failure to the test set. Open the trace from its score row. Press
Add to, then Dataset, thenanalyst-gold. The form fills Expected output with the answer you just saw fail, so clear that box. PressAdd to dataset.
Expect: analyst-gold has one more item, with your question.
- Gate again. Stop the app, then run the candidate and today's setup on the larger test set.
ANALYST_MODEL=claude-haiku-5-5 ANALYST_PROMPTS=short bun run gate
bun run gateExpect: your case shows as live- and eight characters. Ours blocked the candidate, with 16 of 22 passed, and passed today's setup with 22 of 22.
A case you add must pass. With no reference query, a query must run, code checks the numbers and the judge reads the answer. If the judge is not trusted yet, the case fails. If you know the right query, write {"sql": "SELECT ..."} as the Expected output.
- Deploy the setup that passed, ask the same question and compare.
bun run devExpect: the new trace has the tag claude-sonnet-5-5, full prompts, and the earlier one claude-haiku-5-5, short prompts. Ours went from False to True. Stop the app when you are done.
All of this uses ADK's own tools.
cd ambient-expense-agent
uv sync- Look at one run.
uv run adk web expense_agent --port 8213Open http://localhost:8213 and send this message:
{"data": {"amount": 480, "submitter": "dana@example.com", "category": "travel", "description": "Flight to Berlin for the 12 Nov customer review, receipt attached", "date": "2026-11-20"}}Expect: the run stops and asks for a manager. The Traces view shows each step and its time.
-
Save that run as a test case. Open the Evals tab, then
expense_reviews. PressFrom Current Session, type a name such asmy_flightand pressCreate.Expect: your case joins the five in expense_reviews.evalset.json. Step 17 then runs six. To go back to five, run
git checkout expense_agent/expense_reviews.evalset.json.
- Run the saved cases on today's setup. Stop
adk webfirst.
uv run pytest -m paidExpect: 1 passed.
- Run the same cases on the candidate.
EXPENSE_MODEL=claude-haiku-5-5 EXPENSE_PROMPT=short uv run pytest -m paidExpect: 1 failed. The cheaper setup still raises the alert, but its reply drops the risk level and often the recommendation.
The rules are in test_config.json:
| Rule | Checked by | Question |
|---|---|---|
tool_trajectory_avg_score |
Code | Did it call the alert tool, then ask a person? |
rubric_based_final_response_quality_v1 |
AI judge, asked 3 times | Does the reply give a risk level, a recommendation and a real reason, and decide nothing by itself? |
One trap. uv run adk eval prints Overall Eval Status: PASSED even when the judge could not run. Its details say NOT_EVALUATED. The pytest file fails in that case, so use it for a release.
On 1 December 2026, with Anthropic models through the gateway. A model varies from run to run, so your numbers will differ.
| Today's setup | Cheaper setup | |
|---|---|---|
| Analyst: 26 cases passed on the first run | 25 | 23 |
| Analyst: cost per question | US$0.0099 | US$0.0005 |
| Analyst: gate on 21 cases | YES, 20 of 21 | NO, 17 of 21 |
| Analyst: gate after the two added lines | not run | YES, 18 and 20 of 21 |
| Analyst: gate with the question added from the app | YES, 22 of 22 | NO, 16 of 22 |
| Expense agent: 5 cases passed | 5 | 0 |
The gate ran several times. Today's setup passed 20 or 21 and the cheaper one 16 or 17, and the same two answers blocked it each time.
The judge agreed with 17 of the 18 marks it was written against, and missed no fail. On 18 new answers it had never seen, it agreed with all 18.
Two red tests were wrong tests, not wrong apps: one reference query in the analyst, and one judge rule in the expense agent. Read a failed case before you blame the model.
Every call the apps make goes through the Langfuse AI gateway. MODEL_PROVIDER=anthropic or openrouter in .env picks the connection. The analyst's AI judge runs inside Langfuse and uses the workshop-judge connection. The two places that build the call are model.ts and gateway.py. The numbers above are from Anthropic only.
A test that runs before each change. A case that must pass and fails means no.
bun run checkTypes, lint and tests for both apps. It calls no model.
- We wrote
judge.mdagainst 18 marks and checked it on 18 more. That is a small sample. Check yours on answers it has not seen. - The judge reads only answers that ran a query. Refusals are checked by code.
- The app runs on your machine, so deploy here means a restart with the new settings.
- Nothing alerts you. You open Scores and look.
- The five expense cases are a start. Add a case each time a real claim goes wrong.
