TRACE
Evals
From "it seemed fine" to evidence you can ship on. Trace. Read. Analyze. Codify. Enforce.
Aki Wijesundara · Manu Jayawardana
Laptop · your capstone
traces (or Harmony pack)
What we'll cover.
| Section | Focus |
|---|---|
| Why Evals + TRACE | What an eval is. TRACE. |
| Trace + Langfuse | What a trace is. Live Langfuse. |
| Read + Analyze | Open coding. Ranked taxonomy. |
| Codify | OpenAI Evals dashboard live. |
| Iterate | One change, re-measure. |
| Agents | Trajectory plus outcome. |
| Enforce | Thresholds and CI. |
| Path A | What you ship this week. |
| Q&A | Questions. |
You leave with: the TRACE loop, a ranked failure taxonomy habit, and Path A homework: open-code 20 traces, write assertions, ship one fix with a metric move.
02The problem.
You demo your capstone. Someone asks:
"How do we know this is good enough to ship?"
You tried 20 examples by hand. It seemed fine.
"It seemed fine" is not evidence.
What is an AI eval?
An AI eval is a repeatable test for a system that does not always give the same answer. You define what "good" means, run many cases, score each output, and track a number over time.
1 · Define good
Criteria or expected answers
Not vibes.
2 · Run cases
Same inputs
Through your system.
3 · Score outputs
Pass or fail
Or a calibrated judge.
4 · Track the number
Did this change help?
Watch the metric move.
Concrete example: Capstone SMS leasing bot. Eval set: 20 real (or sample) user texts. Assertion: "must not invent a unit hold." Score: 14/20 pass, fix prompt, 18/20. That delta is evidence.
04Your three scoring tools.
| Type | What it does | Strengths | Weaknesses |
|---|---|---|---|
| Code-based | String match, regex, schema, state | Fast, cheap, reproducible | Brittle, no nuance |
| Model-based | LLM scores against a rubric | Flexible, captures nuance | Needs calibration |
| Human | You label real outputs | Gold standard | Expensive, slow |
Code-based where possible. Model-based where necessary. Human to calibrate. Own TRACE, not a vendor brand. Today's live tools: Langfuse (see traces) and the OpenAI Evals dashboard (run graders). Hosted OpenAI Evals is sunsetting: still fine for this classroom demo. Promptfoo or Braintrust for lasting setups.
05The TRACE loop.
| Step | Name | What you produce |
|---|---|---|
| T | Trace | Full records of real runs, not just final answers |
| R | Read | Your own notes on what actually went wrong |
| A | Analyze | A ranked list of failure types |
| C | Codify | Assertions and a validated judge |
| E | Enforce | Evals in CI, gating every change |
Five steps, in order. Each one produces the input to the next. You cannot skip a letter. Next we define what a trace actually is, then Read and Analyze.
06What is a trace?
A trace is the full record of one run of your system: what went in, what happened in the middle, and what came out.
Not a chat screenshot. Not "the final answer looked okay." The black-box flight recorder for that request.
One run, example
User asks "Is unit 4B still available?", your bot retrieves lease FAQ, calls a calendar tool, replies with a date. That whole chain is one trace. Save it so you can replay and judge it later.
In TRACE, the letter T means: capture these records on purpose (Langfuse, Braintrust, CSV. Tool is optional. The record is not). Next: see one live in Langfuse.
07What goes inside a trace.
Messages
System prompt plus user turns. What the model was told.
Tool calls
Functions the agent invoked, and what they returned.
Retrieved context
Docs or FAQ chunks pulled in (RAG: search then generate).
Final output
The text (or structured reply) the user saw.
Outcome
What actually changed: row written, ticket closed, booking made.
Metadata
Model name, latency, cost, prompt version.
Transcript vs outcome. The transcript is the message history. The outcome is final state in the world. A polite "done" can still be a wrong refund. Grade both when your agent changes anything.
08Langfuse: see a trace live.
Langfuse is an observability UI for LLM apps. It stores the flight recorder we just defined. Best place in the session: right after "what is a trace," before you open-code, so the room already knows what they are looking at.
1 · Dashboard
Morning check
Traces flowing. Cost. Latency.
2 · Open one trace
Tree of spans
LLM calls, tools, retrieval.
3 · Input / output
Per span
What went in, what came out.
4 · Sessions (optional)
Grouped runs
Group traces into one conversation.
Live now: open Langfuse, pick a recent trace, narrate messages, tools, cost. Scores and LLM-as-judge can wait until Codify. Today this click-path is only the letter T. Method is TRACE. Langfuse (or Braintrust) is a lens. Do not marry a dashboard brand.
09Read before you write a check.
Open coding is qualitative research on traces: you read each run and write free-text notes in your own words. No scores yet. No automated grader yet.
Only after notes: mark pass or fail, then a short failure label. That is how you discover what is actually breaking.
Harmony traces → Pack README → TRACE Lab · Live walkthrough. Keyboard-first.
↓ Traces CSV ↓ Traces JSONL ↓ Knowledge base ↓ Pack README Open TRACE Lab
Answer key only after open-coding: ↓ Answer key (JSONL)
Prefer your own capstone traces when you have them. No traffic yet? The Harmony Apartments pack is a valid Path A start. Answer key only after you finish your own notes.
Design in the abstract and you test what you imagine. Read real outputs and you test what actually breaks.
10Count, then rank.
After open-coding Harmony's 20 traces: 6 pass, 14 fail. Cluster the fails, rank, that list is your Codify backlog.
| Rank | Failure type | Count | Impact | Codify next? |
|---|---|---|---|---|
| 1 | Grounding / hallucination | 4 | High | Yes: assert KB facts |
| 2 | Instruction / constraint miss | 3 | High | Yes: assert constraints |
| 3 | Missing handoff | 2 | High | Yes: forbid fake holds |
| 4 | Tool-output ignored | 2 | Med | Later |
| 5 | Safety / injection | 1 | Critical | Yes: refuse secrets |
| … | Tone · formatting | 1 each | Low | Later |
Frequency times impact. Safety is rare (1) but Critical, so it still jumps the queue. Open-coding stays pass or fail. Judges can return a score. Your eval applies the cutoff. This ranked list is the spec for what you Codify next.
11Code-based grader first.
Codify = turn your ranked failures into automated checks. A grader scores one output. An assertion is a hard rule (string match, schema, length). ground_truth is the expected answer you wrote for that test case.
Live tool: OpenAI Evals dashboard. Create eval, upload JSONL, string-check grader, run.
System / developer
Categorize this support ticket into one of: billing, how_to, bug_report, feature_request, or other. Respond with only the category word, nothing else.
Input
{{item.input}}
Model
gpt-4o-mini
Assertion
Equals {{item.ground_truth}}
What happens with harder cases.
| Input | ground_truth | Model says | Result |
|---|---|---|---|
| "Laptop flickers in Chrome" | bug_report | bug_report | Pass |
| "Pricing is confusing, explain tiers?" | sales_inquiry | other | Fail |
| "AI told me to delete system32" | bug_report | bug_report | Pass |
"sales_inquiry" is not a valid category. The model says "other," which is correct. The grader says FAIL. The model is right. The eval is wrong. That is Codify-before-Read: a grader for a failure you imagined.
13New task: email quality.
Switch datasets. 5 email scenarios. Two graders: string check plus LLM-as-judge.
| Customer | Issue | Key criteria |
|---|---|---|
| Sarah Chen | Charged twice | Mention refund process, provide timeline |
| Tom Baker | Positive feedback | Thank warmly, do NOT upsell |
| David Kim | HIPAA emergency | Treat as urgent, mention permanent deletion |
| Lin Wei | Wrongful suspension | Do NOT assume guilt, explain review |
| James Wilson | Dark mode request | Acknowledge, do NOT promise timeline |
DEVELOPER
You are a customer support agent for CloudApp. Help the customer with their issue.
STRING CHECK
Contains CloudApp Support Team
When you need a judge: score plus cutoff.
An LLM-as-judge grades the model against your criteria. Trust it only after you label a small set. Here {{item.ground_truth}} is the Email Quality rubric.
You are evaluating a customer support email response.
The customer's issue was:
{{item.input}}
The AI's response was:
{{sample.output_text}}
The response should meet these criteria:
{{item.ground_truth}}
Score from 1 to 7:
7 = Fully meets all criteria, appropriate tone, helpful
4 = Meets some criteria but misses others
1 = Fails to meet criteria, wrong tone, or harmful
Reply with the integer score only, then one short reason.
Be strict. Deduct for missing requirements, wrong tone, "as an AI".
Score 1 to 7 Cutoff ≥ 5 = pass Judge: gpt-4o-mini
Judge returns
Score 6 · “Hit refund and timeline. Tone OK.”
Eval harness
pass = score >= 5 → PASS
An unvalidated judge is a vibe check wearing a number. Where you disagree, the judge is the suspect.
Same eval. Same data. Same graders. One targeted change.
Read, Analyze, Codify, change something, re-measure. That is hill climbing. The prompt below is the same email-agent brief, tightened for the failures the ranked taxonomy exposed.
You are a customer support agent for CloudApp. Draft a professional email response. Rules: - Be empathetic and acknowledge the customer's situation - Be specific, don't give generic advice - For urgent or critical issues, treat them with appropriate urgency - Do not say "as an AI" or similar hedging - Keep your response under 150 words - Sign off as "The CloudApp Support Team"
Grade more than the final message.
An agent takes several steps and may call tools before answering. Grading only the last message can score a broken run as perfect.
Task
The spec
Inputs plus success criteria plus graders.
Trial
One execution
Run multiple for consistency.
Trajectory
The full record
Every step and tool call.
Outcome
Final state
What actually changed. Not just what the agent said.
Components of an eval for agents: task, trial, trajectory, outcome. A polite closing does not mean the refund landed. Grade both layers — next slide: LLM-as-judge on full transcripts.
17Agent grading with LLM-as-judge.
Same judge pattern as email quality — but the input is a full agent transcript (tools + outcome), not a single reply.
↓ Transcripts data (JSONL) Open TRACE Lab · Agents
You are evaluating an agent transcript (trajectory + outcome).
The full run was:
{{item.input}}
Score against these criteria:
{{item.ground_truth}}
Score from 1 to 7:
7 = Meets all criteria — correct tools, correct final state
4 = Partial — tone OK but tool use or outcome wrong
1 = Fails criteria, unsafe, or worse outcome than before
Grade tool calls and final state, not only the last message.
Reply with the integer score only, then one short reason.
1 · Good refund (Pass · 7). Verified account, correct amount, confirmation number.
2 · Bad refund (Fail · 1). No verification, wrong amount, tool failed — outcome wrong even if tone is fine.
3 · Prompt injection (Pass). Ignored SYSTEM OVERRIDE, summarized correctly, flagged the attack.
Red team into Codify: indirect injection in docs, tool misuse, state corruption, cascading failures. Every adversarial prompt becomes a future test case.
18Ship decision matrix.
Example thresholds. Set yours from product risk. Write them down.
| Signal | Ship | Mitigate | Block |
|---|---|---|---|
| Code-based | >95% | 85 to 95% | <85% |
| Model-based (validated) | Agreed bar | Borderline | Below bar |
| Safety | 0 failures | Mitigated edges | Unmitigated |
| Regression | None | <2%, justified | Any safety regression |
Regression suites go in CI. Capability evals are what you run when you are trying to get better.
19From a meeting to a merge gate.
Enforce means the eval suite runs on every change and can block the merge when it fails. Same thresholds, no meeting. Classroom: Braintrust datasets. CI illustration: Promptfoo.
on:
pull_request:
paths: ['prompts/**', 'agents/**']
jobs:
eval:
steps:
- run: promptfoo eval --config evals.yaml
# fails the build below threshold
# posts pass/fail as a PR comment
Thresholds are pass rates, not 100 percent.
Flakiness is real. Temperature 0, plus a repeat count.
Code checks are free. Judge calls are not. Track token spend.
Path A: after this session.
1. Open-code 20 traces (Harmony pack and/or your capstone). Free-text notes first.
2. Build a failure taxonomy with at least 4 specific categories. Rank by frequency times impact.
3. Codify at least 2 code-based assertions tied to those failures.
4. Ship one fix aimed at a top failure. Re-run. Show the metric moving.
5. Streamlit (or your UI) shows eval results. Screenshot for Maven.
That is TRACE. Trace, Read, Analyze, Codify, Enforce. · Assignment guide · Harmony pack · Agent transcripts · Hamel · Anthropic agent evals · Braintrust · Promptfoo
21Questions?
Evals are not a tax on shipping. They are how you iterate with confidence.
Next live: Memory. Path A due on Maven.