< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Evaluation.AgentRunDiagnosticsEvaluationExtensions
Assembly: NexusLabs.Needlr.AgentFramework.Evaluation
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Evaluation/AgentRunDiagnosticsEvaluationExtensions.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 36
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ToEvaluationInputs(...)100%66100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Evaluation/AgentRunDiagnosticsEvaluationExtensions.cs

#LineLine coverage
 1using Microsoft.Extensions.AI;
 2using NexusLabs.Needlr.AgentFramework.Diagnostics;
 3
 4namespace NexusLabs.Needlr.AgentFramework.Evaluation;
 5
 6/// <summary>
 7/// Extensions that convert <see cref="IAgentRunDiagnostics"/> into the input shape expected
 8/// by <c>Microsoft.Extensions.AI.Evaluation</c> evaluators.
 9/// </summary>
 10public static class AgentRunDiagnosticsEvaluationExtensions
 11{
 12    /// <summary>
 13    /// Projects a captured agent run into <see cref="EvaluationInputs"/> that can be handed
 14    /// directly to any <c>IEvaluator.EvaluateAsync</c> overload without re-invoking the model.
 15    /// </summary>
 16    /// <param name="diagnostics">Diagnostics captured for a single agent run.</param>
 17    /// <returns>
 18    /// An <see cref="EvaluationInputs"/> whose <see cref="EvaluationInputs.Messages"/> is the
 19    /// captured input, and whose <see cref="EvaluationInputs.ModelResponse"/> is built from
 20    /// the captured <c>AgentResponse</c>. When the run produced no output response, the
 21    /// returned response contains a single empty assistant message so evaluators always
 22    /// receive a non-null <see cref="ChatResponse"/>.
 23    /// </returns>
 24    /// <exception cref="ArgumentNullException"><paramref name="diagnostics"/> is <see langword="null"/>.</exception>
 25    public static EvaluationInputs ToEvaluationInputs(this IAgentRunDiagnostics diagnostics)
 26    {
 527        ArgumentNullException.ThrowIfNull(diagnostics);
 28
 429        var outputMessages = diagnostics.OutputResponse?.Messages;
 430        var chatResponse = outputMessages is { Count: > 0 }
 431            ? new ChatResponse(outputMessages)
 432            : new ChatResponse(new ChatMessage(ChatRole.Assistant, string.Empty));
 33
 434        return new EvaluationInputs(diagnostics.InputMessages, chatResponse);
 35    }
 36}