[Evaluation.Quality] InterpretScore(NumericMetric) marks unparseable (null) and out-of-range scores as not-failed
Description
The quality evaluators (CoherenceEvaluator, FluencyEvaluator, RelevanceEvaluator, …) self-interpret their score via the internal EvaluationMetricExtensions.InterpretScore(NumericMetric):
// src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EvaluationMetricExtensions.cs
EvaluationRating rating = metric.Value switch
{
null => EvaluationRating.Inconclusive,
> 5.0 => EvaluationRating.Inconclusive,
...
<= 0.0 => EvaluationRating.Inconclusive,
};
const double MinimumPassingScore = 4.0;
return metric.Value is double value && value < MinimumPassingScore
? new EvaluationMetricInterpretation(rating, failed: true, reason: ...)
: new EvaluationMetricInterpretation(rating);
When the LLM judge returns text that cannot be parsed into a score, metric.Value is null, so metric.Value is double value is false and the method falls through to the non-failed constructor: the metric ends up Rating: Inconclusive, Failed: false. An out-of-range score (> 5.0) takes the same path (6.0 < 4.0 is false).
Consequence: any pipeline that gates on "did any metric fail?" treats a metric that was never successfully scored as a pass. A flaky or misconfigured judge silently turns a quality gate green — fail-open in exactly the scenario evaluation is meant to catch. Note the asymmetry: InterpretScore(BooleanMetric) already fails closed (a null boolean takes the failed: true branch); only the numeric overload has the hole.
Reproduction Steps
Compiled and run against published Microsoft.Extensions.AI.Evaluation.Quality 10.8.0 (also reproduces on 10.6.0):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI.Evaluation.Quality" Version="10.8.0" />
</ItemGroup>
</Project>
using Microsoft.Extensions.AI;
using Microsoft.Extensions.AI.Evaluation;
using Microsoft.Extensions.AI.Evaluation.Quality;
var judge = new CannedChatClient("I am unable to evaluate this response.");
var evaluator = new CoherenceEvaluator();
EvaluationResult result = await evaluator.EvaluateAsync(
new ChatMessage(ChatRole.User, "What is 2+2?"),
new ChatResponse(new ChatMessage(ChatRole.Assistant, "4")),
new ChatConfiguration(judge));
NumericMetric metric = result.Get<NumericMetric>(CoherenceEvaluator.CoherenceMetricName);
Console.WriteLine($"Value: {(metric.Value is null ? "null (unparseable judge reply)" : metric.Value)}");
Console.WriteLine($"Rating: {metric.Interpretation!.Rating}");
Console.WriteLine($"Failed: {metric.Interpretation!.Failed}");
sealed class CannedChatClient(string reply) : IChatClient
{
public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
=> Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, reply)));
public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
=> throw new NotSupportedException();
public object? GetService(Type serviceType, object? serviceKey = null) => null;
public void Dispose() { }
}
Expected behavior
Failed: True — a metric with no valid score must not read as not-failed.
A minimal behavior-only fix (no public API change) would fail closed whenever no valid in-range score exists:
return metric.Value is double value
? value < MinimumPassingScore || rating == EvaluationRating.Inconclusive
? new EvaluationMetricInterpretation(rating, failed: true,
reason: $"{metric.Name} is less than {MinimumPassingScore} or out of range.")
: new EvaluationMetricInterpretation(rating)
: new EvaluationMetricInterpretation(rating, failed: true,
reason: $"{metric.Name} was not assigned a valid score.");
Happy to send the PR with tests covering null, out-of-range-high, and boundary scores if the change is acceptable.
Actual behavior
Value: null (unparseable judge reply)
Rating: Inconclusive
Failed: False
Regression?
No — same behavior on 10.6.0 and 10.8.0; the pattern is unchanged on current main (6ea3ca8cf).
Known Workarounds
Consumers can post-process results and treat Rating == Inconclusive (or Value is null) as failed before gating, but every consumer has to know to do this — the default reads as a pass.
Configuration
.NET 10, Microsoft.Extensions.AI.Evaluation.Quality 10.8.0, macOS arm64 (not OS-specific).
Other information
The interpretation logic lives in EvaluationMetricExtensions.InterpretScore(NumericMetric); the BooleanMetric overload in the same file already fails closed and can serve as the reference behavior.