My App
EvaluationLLM and Agent Evaluation

Classification Evaluation

The classification gate answers one yes or no question: is this message a question about the user's own pottery? The design of the gate is described in Classification Gate. It was evaluated in a loop: generate inputs, run the gate, label the results by hand, find the failure modes, fix the prompt, and run again.

1. Generate the inputs

  • 30 messages, generated synthetically.
  • 10 of them come with a short conversation before the message.

2. Run the gate

  • The real gate runs over every input with one prompt version.
  • Each result is saved as a trace: the message, the conversation, the yes or no answer, the reason, and the time taken.

3. Label by hand

  • One domain expert, the author, marks each result right or wrong. There is no score scale. A binary label forces a clearer decision and keeps the labeling consistent.
  • For each wrong result the expert writes a short free-text note about what went wrong.
  • Labels follow the product policy. When the policy changed, the affected labels were changed and checked again. This happened twice: the gate was made generous toward vague questions, and questions that read the user's own data were declared in scope.

4. Find the failure modes

  • The notes are grouped and counted. The failure modes come out of the notes and are not a fixed list chosen before labeling.
  • Follow-up refused: a vague follow-up with no pottery word, such as "And the next step?", was refused because the gate could not see the conversation.
  • Entry management accepted: "Can you delete my last logged entry?" was accepted. The chat only answers questions, so this is out of scope.
  • Data questions refused: questions that read or summarize the user's own entries, such as counts, were refused as not about pottery.
  • Off-topic history: the gate said yes to "How hot should it get?" after a conversation about a pizza oven. In the app that conversation would already have been refused on its first message, so 3 such inputs are not scored. The other 27 are.

5. Fix the prompt and run again

  • Each failure mode led to a new prompt version. The model stays the same.
  • Labels carry over to the new run, so only new or changed results need a review.
  • The score is the share of labeled inputs the gate got right. The number of labeled inputs grew as the set grew, so each row has a different size.
VersionFailure mode addressedCorrect
v1Original prompt12 of 15
v2Follow-ups refused, entry management accepted: lean toward yes for vague questions, entry management out of scope22 of 24
v3Data questions refused: questions that read the user's own data are in scope26 of 27
v4Follow-ups refused, at the root: the gate receives the conversation27 of 27
v5Off-topic history: read the conversation first, then apply the generous default27 of 27
  • Production runs v4. Version v5 exists only in the evaluation.
  • v2 passed the follow-ups only because it leaned toward yes on anything vague. It was not reading the conversation. The follow-up "How do I fix it?", added later, failed on v3 and passed on v4.
  • An extra class for "ambiguous" questions was considered and rejected. The gate stays narrow and lenient, and the answer step handles vague questions.

Repeat runs

  • The gate can give a different answer to the same input, so one run is a sample.
  • The four edge cases were run five times each on v4 and on v5. The pizza oven case was wrong all five times on both versions, so it is a consistent error. The extra rule in v5 did not change that.

Production checks

  • Real traffic has no labels. The checks run in Langfuse on the gate call.
  • A judge model reads the same message and conversation without seeing the gate's answer, so it cannot copy it. A disagreement goes to a person.
  • Three rule-based detectors each look for one known failure mode: a refused follow-up, an accepted entry-management request, and a refused data question. They flag traces for review and are not verdicts. On later versions some flagged traces were in fact correct.
  • A confirmed miss becomes a new input in the evaluation set and goes through the loop above. Judge scores never become labels.
  • The judge is switched on only after it reproduces the expert's labels on the evaluation set. No result of that check is recorded yet.

Comparison with a small classifier model

  • Typesafe's Jev model, called through OpenRouter, was run as the gate on the same 30 inputs and compared with the v5 prompt. This is an evaluation only. Production still uses the LLM gate.
  • Both got 27 of 27 scored inputs right. Jev was right on the pizza oven case, which is not scored, and v5 was wrong.
  • Median time was 295 ms for Jev and 1037 ms for the v5 prompt, from one run of each.
  • The inputs are easy enough that both get everything right, so the set cannot show which model is better. It shows that Jev matches the LLM gate here and is faster.