Skip to content

PipelineEvaluationContext

NexusLabs.Needlr.AgentFramework.Evaluation

PipelineEvaluationContext Class

Carries an NexusLabs.Needlr.AgentFramework.Diagnostics.IPipelineRunResult through the Microsoft.Extensions.AI.Evaluation evaluator pipeline so that pipeline-aware evaluators can score per-stage and aggregate metrics without re-invoking the model.

public sealed class PipelineEvaluationContext : Microsoft.Extensions.AI.Evaluation.EvaluationContext

Inheritance System.Object 🡒 Microsoft.Extensions.AI.Evaluation.EvaluationContext 🡒 PipelineEvaluationContext

Remarks

Evaluators that require the full pipeline result look up the single instance of this context in the additionalContext collection passed to Microsoft.Extensions.AI.Evaluation.IEvaluator.EvaluateAsync(System.Collections.Generic.IEnumerable{Microsoft.Extensions.AI.ChatMessage},Microsoft.Extensions.AI.ChatResponse,Microsoft.Extensions.AI.Evaluation.ChatConfiguration,System.Collections.Generic.IEnumerable{Microsoft.Extensions.AI.Evaluation.EvaluationContext},System.Threading.CancellationToken).

Microsoft.Extensions.AI.Evaluation.EvaluationContext.Contents contains a single Microsoft.Extensions.AI.TextContent summarising the pipeline run so that reporting pipelines which only serialise Microsoft.Extensions.AI.Evaluation.EvaluationContext.Contents still record meaningful information. Consumers that need the full snapshot read PipelineResult directly.

Use ForStage(IAgentStageResult) to create a per-stage AgentRunDiagnosticsContext for evaluators that operate on individual agent runs within the pipeline.

Constructors

PipelineEvaluationContext(IPipelineRunResult) Constructor

Initializes a new instance of the PipelineEvaluationContext class.

public PipelineEvaluationContext(NexusLabs.Needlr.AgentFramework.Diagnostics.IPipelineRunResult pipelineResult);

Parameters

pipelineResult NexusLabs.Needlr.AgentFramework.Diagnostics.IPipelineRunResult

The captured pipeline run result to expose to evaluators.

Exceptions

System.ArgumentNullException
pipelineResult is null.

Fields

PipelineEvaluationContext.ContextName Field

The stable name used for this context. Evaluators can locate the context by matching Microsoft.Extensions.AI.Evaluation.EvaluationContext.Name against this value.

public const string ContextName = "Needlr Pipeline Run Result";

Field Value

System.String

Properties

PipelineEvaluationContext.PipelineResult Property

Gets the pipeline run result.

public NexusLabs.Needlr.AgentFramework.Diagnostics.IPipelineRunResult PipelineResult { get; }

Property Value

NexusLabs.Needlr.AgentFramework.Diagnostics.IPipelineRunResult

Methods

PipelineEvaluationContext.ForPipeline(IPipelineRunResult) Method

Creates a pipeline-level context from a full pipeline result.

public static NexusLabs.Needlr.AgentFramework.Evaluation.PipelineEvaluationContext ForPipeline(NexusLabs.Needlr.AgentFramework.Diagnostics.IPipelineRunResult result);

Parameters

result NexusLabs.Needlr.AgentFramework.Diagnostics.IPipelineRunResult

The pipeline run result.

Returns

PipelineEvaluationContext
A new PipelineEvaluationContext wrapping the result.

PipelineEvaluationContext.ForStage(IAgentStageResult) Method

Creates an AgentRunDiagnosticsContext for a single stage within a pipeline, or null when the stage has no captured diagnostics.

public static NexusLabs.Needlr.AgentFramework.Evaluation.AgentRunDiagnosticsContext? ForStage(NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentStageResult stage);

Parameters

stage NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentStageResult

The stage result to convert.

Returns

AgentRunDiagnosticsContext
An AgentRunDiagnosticsContext wrapping the stage's diagnostics, or null if NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentStageResult.Diagnostics is null.