Table of Contents

Method RunAsync

Namespace
LMKit.Agents.Evaluation
Assembly
LM-Kit.NET.dll

RunAsync(AgentEvaluationSuite, Func<AgentEvaluationCase, CancellationToken, Task<AgentEvaluationTranscript>>, CancellationToken)

Runs a suite through any player: play plays one case (on a server over HTTP, in process, anywhere) and returns what it observed; the cases run one after the other and are scored the same way whoever played them.

public static Task<AgentEvaluationReport> RunAsync(AgentEvaluationSuite suite, Func<AgentEvaluationCase, CancellationToken, Task<AgentEvaluationTranscript>> play, CancellationToken cancellationToken = default)

Parameters

suite AgentEvaluationSuite

The suite.

play Func<AgentEvaluationCase, CancellationToken, Task<AgentEvaluationTranscript>>

Plays one case and returns its transcript.

cancellationToken CancellationToken

A token to stop the run between cases.

Returns

Task<AgentEvaluationReport>

The report.

Exceptions

ArgumentNullException

Thrown when an argument is null.

ArgumentException

Thrown when the suite cannot run (Validate()).

RunAsync(AgentEvaluationSuite, Func<MultiTurnConversation>, CancellationToken)

Runs a suite in process: each case gets a fresh conversation from createConversation, its tools that write are replaced by simulations (Guard(ITool)), its turns are submitted in order, and every tool call and the final knowledge verdict are recorded.

public static Task<AgentEvaluationReport> RunAsync(AgentEvaluationSuite suite, Func<MultiTurnConversation> createConversation, CancellationToken cancellationToken = default)

Parameters

suite AgentEvaluationSuite

The suite.

createConversation Func<MultiTurnConversation>

Creates the agent's conversation for one case: its prompt, tools and knowledge.

cancellationToken CancellationToken

A token to stop the run.

Returns

Task<AgentEvaluationReport>

The report.

Exceptions

ArgumentNullException

Thrown when an argument is null.

RunAsync(AgentEvaluationSuite, Func<Agent>, AgentExecutionOptions, CancellationToken)

Runs a suite in process against an agent: each case gets a fresh agent from createAgent (an agent built from an AgentDefinition plays exactly as the definition says: its prompt, tools, knowledge and output schema) and every tool that writes is answered by its simulation.

public static Task<AgentEvaluationReport> RunAsync(AgentEvaluationSuite suite, Func<Agent> createAgent, AgentExecutionOptions options = null, CancellationToken cancellationToken = default)

Parameters

suite AgentEvaluationSuite

The suite.

createAgent Func<Agent>

Creates the agent for one case.

options AgentExecutionOptions

The execution options of every turn (the thinking level, for one); null for the defaults.

cancellationToken CancellationToken

A token to stop the run.

Returns

Task<AgentEvaluationReport>

The report.

Examples

var report = await AgentEvaluator.RunAsync(suite, () => Agent.CreateBuilder(model)
    .WithDefinition(definition, resolveKnowledge: sources => retriever)
    .Build());

Exceptions

ArgumentNullException

Thrown when an argument is null.

Share