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
suiteAgentEvaluationSuiteThe suite.
playFunc<AgentEvaluationCase, CancellationToken, Task<AgentEvaluationTranscript>>Plays one case and returns its transcript.
cancellationTokenCancellationTokenA 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
suiteAgentEvaluationSuiteThe suite.
createConversationFunc<MultiTurnConversation>Creates the agent's conversation for one case: its prompt, tools and knowledge.
cancellationTokenCancellationTokenA 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
suiteAgentEvaluationSuiteThe suite.
createAgentFunc<Agent>Creates the agent for one case.
optionsAgentExecutionOptionsThe execution options of every turn (the thinking level, for one);
nullfor the defaults.cancellationTokenCancellationTokenA 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.