The idea: some qualities of an answer only show when someone reads it, so a second model reads it and gives a score. That score is a model's output too. Test the judge on answers you wrote, give it what it needs to know, and read its scores as a comparison between runs, not as a verdict.

The tests and pass rates post checks what the agent did: which tools it called and what ended up on the shopping list. Ask the kitchen assistant "What can I cook tonight?" and the questions that matter are different. Does the answer suggest a dinner, or only recite the pantry? Can the household cook it with what it has, or does it need salmon nobody bought? A string match can't answer either. An eval with a judge can: a second model reads the question and the answer and scores them from 1 to 5. Agent Framework 1.24 has an EvaluateAsync extension on every agent that runs it against a list of questions and hands the answers to an evaluator, either checks in code or the quality evaluators of Microsoft.Extensions.AI.Evaluation. Below, the kitchen assistant gets both, with Claude Haiku 5.5 as the judge, and the judge is tested on answers written by hand before its scores on the agent count for anything.

Versions: Microsoft Agent Framework 1.24.0, Microsoft.Extensions.AI.Evaluation.Quality and Microsoft.Extensions.AI.Evaluation.Reporting 10.10.0, .NET 10.

Code: samples/agent-framework/16-evals, a runnable version of this post with its tests.

Who this is for: C# developers who have given an agent tools, as in Agent Framework tool calling in C# with Claude, and tested it with pass rates, as in Agent Framework tests and pass rates in C# with Claude.

Note

The code runs on Claude Haiku 5.5, but it depends only on IChatClient: the first post shows the swap to OpenAI or Ollama.

The judge's chat client removes two options that Claude Haiku 5.5 rejects; another judge model may accept them, or reject others. The costs use Haiku's list prices. The output limit of 4,096 tokens is sized for Haiku, which counts its reasoning as output.

An eval measures your product, not the model

Inference Engineering by Philip Kiely separates the two. A public benchmark such as MMLU or SWE-bench measures a model on shared tasks. It helps to shortlist models, but the book warns that they are saturated or even gamed, since every lab wants a record score for its next release. An eval is built for one product, aimed at the hardest problems the model has to solve there, because, in the book's words, "there is no substitute for directly measuring how a model performs for your application." The book also says how to read a result, when it checks a quantized model against the original: compare against a baseline, and treat a difference no larger than the noise between two runs as no difference. Its first tip for eval work is to look at your data and check results against your own sense of the problem (p. 32).

For this kitchen the eval set is three questions a household asks, and the hardest problem is staying inside the pantry.

A kitchen assistant with one pantry tool

A console app with the agent packages and two evaluation packages. Version 10.10.0 is the one Microsoft.Agents.AI 1.24.0 itself depends on:

dotnet new console -n KitchenEvals cd KitchenEvals dotnet add package Microsoft.Agents.AI --version 1.24.0 dotnet add package Microsoft.Agents.AI.Anthropic --version 1.24.0 dotnet add package Microsoft.Extensions.AI.Evaluation.Quality --version 10.10.0 dotnet add package Microsoft.Extensions.AI.Evaluation.Reporting --version 10.10.0 

The pantry is a constant and a tool that returns it:

Pantry.cs

using System.ComponentModel; static class Pantry { public const string Contents = "rice 1 kg, eggs 6, onions 3, spinach 200 g, feta 150 g, " + "canned tomatoes 2 tins"; [Description("Lists everything in the household's pantry.")] public static string ListPantry() => Contents; } 

KitchenAgent.cs

using Microsoft.Agents.AI; using Microsoft.Extensions.AI; static class KitchenAgent { public static AIAgent Create(IChatClient chatClient) => chatClient.AsAIAgent( name: "kitchen-assistant", instructions: """ You suggest dinners for one household. Check the pantry with list_pantry before you answer. Suggest one dish that uses what is in the pantry, and name anything the household would have to buy. Answer in at most three sentences. """, tools: [ AIFunctionFactory.Create( Pantry.ListPantry, name: "list_pantry"), ]); } 

Program.cs creates one chat client for Claude and puts a TokenCounter in front of it twice, one for the agent and one for the judge. TokenCounter is a DelegatingChatClient from the sample that adds up the Usage of every response that reaches Claude:

Program.cs

IChatClient claude = new AnthropicClient(new ClientOptions { ApiKey = apiKey }) .AsIChatClient("claude-haiku-5-5", 4096); var agentTokens = new TokenCounter(claude); var judgeTokens = new TokenCounter(claude); AIAgent agent = KitchenAgent.Create(agentTokens); ChatConfiguration judge = Judge.Create(judgeTokens); string[] questions = [ "What can I cook tonight?", "I have 20 minutes. What's a quick vegetarian dinner?", "Can I make lasagne tonight?", ]; 

Checks in code come first

The pass rates post built this by hand: a runner that runs each scenario several times and counts the passes. Agent Framework 1.24 has it built in, so this post uses the built-in types.

Agent Framework's evaluation types live in Microsoft.Agents.AI itself. A LocalEvaluator runs checks in code, and each check returns pass or fail. EvalChecks has ready-made ones, and FunctionEvaluator.Create turns a function into a check:

Checks.cs

using Microsoft.Agents.AI; static class Checks { static readonly string[] InThePantry = ["rice", "egg", "onion", "spinach", "feta", "tomato"]; public static LocalEvaluator Create() => new( EvalChecks.ToolCalledCheck("list_pantry"), FunctionEvaluator.Create("names a pantry item", NamesAPantryItem)); static bool NamesAPantryItem(string answer) => InThePantry.Any(item => answer.Contains(item, StringComparison.OrdinalIgnoreCase)); } 

Program.cs

AgentEvaluationResults checks = await agent.EvaluateAsync( questions, Checks.Create(), numRepetitions: 3); Console.WriteLine($"Checks in code: {checks.Passed}/{checks.Total} passed"); 

EvaluateAsync runs the agent once per question and repetition, each time in a new conversation, wraps every answer in an EvalItem with the question, the answer's text and the whole conversation, and hands the nine items to the evaluator in one batch. The pantry tool only reads, so one agent can serve every run; the pass rates post needed a new kitchen per run because its tool wrote to a list.

Checks in code: 9/9 passed 

Nine passes say that the agent looked in the pantry and mentioned something from it. "Make salmon teriyaki and serve it with rice" passes the second check too, and one of the sample's tests proves it. Whether the dinner fits the pantry is a question about meaning, and that is the judge's job.

A judge on Claude Haiku

The quality evaluators in Microsoft.Extensions.AI.Evaluation.Quality each send the judge model a prompt with the question and the answer, and turn its reply into a score from 1 to 5 with a reason. RelevanceEvaluator asks whether the answer addresses the question. GroundednessEvaluator asks whether the answer is supported by a context you supply. There are more, such as coherence, completeness and fluency; TaskAdherenceEvaluator, IntentResolutionEvaluator and ToolCallAccuracyEvaluator are marked experimental (AIEVAL001). A third family, the safety evaluators in Microsoft.Extensions.AI.Evaluation.Safety, doesn't use the judge at all: they call the Azure AI Foundry Evaluation service, so they need a Foundry project, not an Anthropic key. The judge is a ChatConfiguration around an IChatClient. The package documentation says the prompts were tuned against GPT-4o, and Claude Haiku is not on that list.

new ChatConfiguration(claude) fails on every evaluation. The evaluators set Temperature and TopP on their requests, and Claude Haiku 5.5 refuses the first with "temperature is deprecated for this model." and, once that is gone, the second with "top_p is deprecated for this model."

This isn't one model's quirk. Anthropic's migration guide for Claude Haiku 5.5 says to omit temperature, top_p and top_k and to steer the model with the prompt instead, and OpenAI's guide to its latest models says to remove temperature and top_p whenever reasoning is on. An eval can't count on a temperature of 0 to make the judge repeat itself; the variance below is what remains, and the cache further down is what makes a run repeatable. The judge's client removes both settings before the request leaves:

Judge.cs

// The quality evaluators send temperature and top_p with every // request, and Claude Haiku 5.5 rejects both. public static ChatConfiguration Create(IChatClient chatClient) => new(chatClient .AsBuilder() .ConfigureOptions(options => { options.Temperature = null; options.TopP = null; }) .Build()); 

A judge that failed counts as a pass

A first try with those errors, one question scored by a CompositeEvaluator (the type that runs several evaluators on one answer), still printed "CompositeEvaluator passed 1/1": one evaluated answer out of one counted as passed, although every metric on it had errored. AgentEvaluationResults counts an item as failed only when a metric's interpretation says it failed or a boolean metric is false. A metric the judge never scored has neither: it holds an error diagnostic and no value. So an eval whose judge is down reports a perfect run. Judge.FailWhenErrored gives such a metric a failing interpretation:

Judge.cs

// A metric the judge couldn't score has no verdict, and // AgentEvaluationResults counts a metric without one as passed. public static EvaluationMetricInterpretation? FailWhenErrored( EvaluationMetric metric) => metric.ContainsDiagnostics( d => d.Severity == EvaluationDiagnosticSeverity.Error) ? new(EvaluationRating.Inconclusive, failed: true, reason: "The judge returned no score.") : null; 

Returning null leaves the metric's own interpretation alone. Every result below goes through it.

Test the judge on answers you wrote

Before the judge grades the agent, it grades three answers whose quality is known: one cooked from the pantry, one that needs salmon and noodles, and one that only lists the pantry. Each is judged three times; written, an array in the sample's Program.cs, holds the three names and answers. These answers never change, so their verdicts can be cached, which is what Microsoft.Extensions.AI.Evaluation.Reporting does:

Program.cs

ReportingConfiguration reporting = DiskBasedReportingConfiguration.Create( storageRootPath: Path.Combine(Path.GetTempPath(), "kitchen-evals"), evaluators: [new RelevanceEvaluator(), new GroundednessEvaluator()], chatConfiguration: judge, enableResponseCaching: true, evaluationMetricInterpreter: Judge.FailWhenErrored); // ... written, the console header and a stopwatch foreach (var (name, answer) in written) { List<EvaluationResult> results = []; for (int iteration = 1; iteration <= 3; iteration++) { await using ScenarioRun run = await reporting.CreateScenarioRunAsync( name, iterationName: $"{iteration}"); results.Add(await run.EvaluateAsync( new ChatMessage(ChatRole.User, "What can I cook tonight?"), new ChatMessage(ChatRole.Assistant, answer), [new GroundednessEvaluatorContext(Pantry.Contents)])); } Console.WriteLine(Report.Row(name, results)); } 

GroundednessEvaluatorContext is the text the answer has to be grounded in: the pantry. Report.Row is a helper in the sample that prints one row per answer: three relevance scores, then three groundedness scores, one per repetition. A score below 4 fails; the default interpretation's reason reads "Relevance is less than 4." The first run, with an empty cache:

Answers written by hand relevance groundedness from the pantry 4 4 4 5 5 4 salmon 4 4 4 3 3 2 only the pantry 3 3 3 4 4 4 20.2 s, judge tokens: 30579 in, 5244 out 

Relevance scored the salmon dinner 4 every time. It is on topic and the household can't cook it: relevance is never told what the pantry holds. Groundedness, which is told, scored it 3, 3 and 2, which fails, but never 1. The answer that only lists the pantry is the reverse: relevance scored it 3 because it suggests no dinner, and groundedness scored it 4 because every word of it is true. Each metric answers one narrow question, and a useful eval needs both.

The same answer from the pantry, judged three times, scored 5, 5 and 4: the scores change although the answer doesn't. None of this shows in a pass count, only in the data the book's tip says to look at.

Pass the pantry to the judge yourself

Agent Framework has an overload that takes a Microsoft.Extensions.AI.Evaluation evaluator directly, agent.EvaluateAsync(questions, evaluator, chatConfiguration). It hands the evaluator no context at all, so GroundednessEvaluator returns no score: "A value of type GroundednessEvaluatorContext was not found in the additionalContext collection." It also passes only the last message of the answer, without the tool call. That doesn't matter for relevance and groundedness, which read only the text of the answer, but it does for evaluators that check tool calls, such as ToolCallAccuracyEvaluator. A small IAgentEvaluator of your own passes the pantry and the whole answer:

PantryJudge.cs

// Runs an IEvaluator on every answer, with the pantry as the context // that GroundednessEvaluator checks the answer against. sealed class PantryJudge(IEvaluator evaluator, ChatConfiguration judge) : IAgentEvaluator { public string Name => "pantry-judge"; public async Task<AgentEvaluationResults> EvaluateAsync( IReadOnlyList<EvalItem> items, string evalName = "pantry-judge", CancellationToken cancellationToken = default) { List<EvaluationResult> results = []; foreach (EvalItem item in items) { var (question, answer) = item.Split(); EvaluationResult result = await evaluator.EvaluateAsync( question, new ChatResponse([.. answer]), judge, [new GroundednessEvaluatorContext(Pantry.Contents)], cancellationToken); result.Interpret(Judge.FailWhenErrored); results.Add(result); } return new(Name, results, items); } } 

item.Split(), a method on the framework's EvalItem, divides the conversation at the last user message: the question up to and including it, the whole answer after it, tool call and tool result included.

Score the agent's own answers

Program.cs

var pantryJudge = new PantryJudge( new CompositeEvaluator( new RelevanceEvaluator(), new GroundednessEvaluator()), judge); AgentEvaluationResults judged = await agent.EvaluateAsync( questions, pantryJudge, numRepetitions: 3); // ... one row per question, and the reason for every failed metric 

One run, with the answer and the reason shortened:

The agent's answers relevance groundedness What can I cook tonight? 4 4 4 5 5 5 I have 20 minutes. What's a quick vegetarian dinner? 4 5 4 4 5 5 Can I make lasagne tonight? 5 5 3 5 5 4 answer: No, lasagne isn't possible tonight, since your pantry has no pasta sheets, ... Relevance failed: ... it asserts specific pantry contents that are not given in the query, ... Passed: 8/9 

The failed answer is a good one: it says no, explains why, and suggests a dinner from the pantry. The tool result with the pantry was in what PantryJudge passed, but relevance reads only the answer's text and is never given the pantry, so it marked the answer down for facts it couldn't check. RelevanceEvaluator has no context type to hand it the pantry the way groundedness gets one; whether putting the pantry into the question would help is a point these runs leave open. Over five runs of the app the agent passed 8, 9, 8, 9 and 9 of its nine answers, and both failures were on the lasagne question, the one where a correct answer has to talk about food the household doesn't have.

The judge costs more than the agent

The same run, priced with Haiku's $0.10 per million input tokens and $0.50 per million output tokens:

Agent: 8823 in, 3182 out, $0.0025 Judge: 32497 in, 6633 out, $0.0066 

Grading nine answers on two metrics cost more than two and a half times what producing them did. Every metric is its own request with its own long prompt, and every repetition multiplies it. As an estimate from this run's prices: $0.0066 for 18 scored metrics is about $0.00037 per metric, so 100 questions with 3 repetitions and 2 metrics, 600 metrics, would cost about $0.22 for the judge alone. Inference Engineering says the same about testing an inference service: it costs engineering time and GPUs, so think about how to spend less on it.

Cache the verdicts on answers that don't change

A later run of the app printed the hand-written table again:

 0.2 s, judge tokens: 0 in, 0 out 

The scores were the same as in the first run, because they came from the cache, not from Claude. The cache stores the judge's replies on disk, keyed on the request, the judge's provider and model, the scenario name and the iteration name, and keeps them for 14 days unless timeToLiveForCacheEntries says otherwise. It only helps when all of them are identical. The agent's answers change on every run, so their verdicts never hit the cache. Routing the agent through the cache as well would replay an old run at no cost and measure nothing new about the model. A cached verdict also carries the token counts of the original call in its metadata, which is why the sample counts tokens at the chat client instead. The stored results feed an HTML report through the aieval tool from Microsoft.Extensions.AI.Evaluation.Console, on macOS and Linux:

dotnet tool install --global \ Microsoft.Extensions.AI.Evaluation.Console --version 10.10.0 aieval report --path "${TMPDIR:-/tmp}/kitchen-evals" --output report.html 

What a score of 4 means

A 4 is the opinion of one model, asked with a prompt tuned for another, grading answers from its own model. The risk there has a name, self-preference: a judge rating answers from its own model family more favourably. Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena lists it as self-enhancement bias. Nothing in these runs measures it; the cheap check is to score the answers written by hand again with a judge from another model family. The scale is the judge's too: the salmon dinner that the household can't cook at all never scored below 2. Inference Engineering discusses model-graded quality checks in one place, for image generation, and says they point in the right direction at best and can disagree with what people prefer.

So the scores work as a comparison, not as a grade. Run the same questions with the same judge before and after a change to the instructions, and look for a difference larger than the spread you see without any change. Here, in two of five runs a lasagne answer dropped below 4 with nothing changed at all, and that is a small sample: 9 answers per run, 5 runs. In practice the checks in code can fail a build, because they give the same answer every time. The judge's scores don't gate on one threshold; they are compared with a baseline and with the spread between repetitions, the book's noise rule, and someone reads the reasons of every failed metric. What has to hold every time, such as the peanut rule in the pass rates post, still belongs in code, where no judge has to agree.

Try it

  • Add a fourth answer written by hand that serves the salmon with rice, and compare its groundedness with the salmon row.
  • Remove "and name anything the household would have to buy" from the instructions in KitchenAgent.cs, run the app a few times and compare the lasagne rows.