TerminationAppropriatenessEvaluator
NexusLabs.Needlr.AgentFramework.Evaluation¶
TerminationAppropriatenessEvaluator Class¶
Deterministic evaluator that scores whether an agent run terminated appropriately, using the captured NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentRunDiagnostics snapshot carried in an AgentRunDiagnosticsContext.
public sealed class TerminationAppropriatenessEvaluator : Microsoft.Extensions.AI.Evaluation.IEvaluator
Inheritance System.Object 🡒 TerminationAppropriatenessEvaluator
Implements Microsoft.Extensions.AI.Evaluation.IEvaluator
Remarks¶
When the AgentRunDiagnosticsContext is present, the evaluator emits:
- Run Succeeded — boolean; mirrors NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentRunDiagnostics.Succeeded.
- Termination Consistent — boolean; true when Succeeded is consistent with NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentRunDiagnostics.ErrorMessage (success ⇔ no error message).
- Execution Mode — string; mirrors NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentRunDiagnostics.ExecutionMode, or "Unknown" when not set.
When no AgentRunDiagnosticsContext is present, the evaluator returns an empty Microsoft.Extensions.AI.Evaluation.EvaluationResult.
Fields¶
TerminationAppropriatenessEvaluator.ExecutionModeMetricName Field¶
Metric name for the captured execution mode string.
Field Value¶
TerminationAppropriatenessEvaluator.RunSucceededMetricName Field¶
Metric name for the success rollup.
Field Value¶
TerminationAppropriatenessEvaluator.TerminationConsistentMetricName Field¶
Metric name for the success/error consistency check.
Field Value¶
TerminationAppropriatenessEvaluator.UnknownExecutionMode Field¶
Execution mode string emitted when the diagnostics do not carry one.
Field Value¶
Properties¶
TerminationAppropriatenessEvaluator.EvaluationMetricNames Property¶
Gets the Microsoft.Extensions.AI.Evaluation.EvaluationMetric.Names of the Microsoft.Extensions.AI.Evaluation.EvaluationMetrics produced by this Microsoft.Extensions.AI.Evaluation.IEvaluator.
Implements EvaluationMetricNames
Property Value¶
System.Collections.Generic.IReadOnlyCollection<System.String>
Methods¶
TerminationAppropriatenessEvaluator.EvaluateAsync(IEnumerable<ChatMessage>, ChatResponse, ChatConfiguration, IEnumerable<EvaluationContext>, CancellationToken) Method¶
Evaluates the supplied modelResponse and returns an Microsoft.Extensions.AI.Evaluation.EvaluationResult containing one or more Microsoft.Extensions.AI.Evaluation.EvaluationMetrics.
public System.Threading.Tasks.ValueTask<Microsoft.Extensions.AI.Evaluation.EvaluationResult> EvaluateAsync(System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, Microsoft.Extensions.AI.ChatResponse modelResponse, Microsoft.Extensions.AI.Evaluation.ChatConfiguration? chatConfiguration=null, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.Evaluation.EvaluationContext>? additionalContext=null, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters¶
messages System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>
The conversation history including the request that produced the supplied modelResponse.
modelResponse Microsoft.Extensions.AI.ChatResponse
The response that is to be evaluated.
chatConfiguration Microsoft.Extensions.AI.Evaluation.ChatConfiguration
A Microsoft.Extensions.AI.Evaluation.ChatConfiguration that specifies the Microsoft.Extensions.AI.IChatClient that should be used if one or more composed Microsoft.Extensions.AI.Evaluation.IEvaluators use an AI model to perform evaluation.
additionalContext System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.Evaluation.EvaluationContext>
Additional contextual information (beyond that which is available in messages) that the Microsoft.Extensions.AI.Evaluation.IEvaluator may need to accurately evaluate the supplied modelResponse.
cancellationToken System.Threading.CancellationToken
A System.Threading.CancellationToken that can cancel the evaluation operation.
Returns¶
System.Threading.Tasks.ValueTask<Microsoft.Extensions.AI.Evaluation.EvaluationResult>
An Microsoft.Extensions.AI.Evaluation.EvaluationResult containing one or more Microsoft.Extensions.AI.Evaluation.EvaluationMetrics.
Remarks¶
The Microsoft.Extensions.AI.Evaluation.EvaluationMetric.Names of the Microsoft.Extensions.AI.Evaluation.EvaluationMetrics contained in the returned Microsoft.Extensions.AI.Evaluation.EvaluationResult should match Microsoft.Extensions.AI.Evaluation.IEvaluator.EvaluationMetricNames.
Also note that chatConfiguration must not be omitted if the evaluation is performed using an AI model.