MentorAgent Docs
Menu

ReferencePackage: Novior.MentorAgent.Abstractions

IMentorQueryHandler<TQuery, TResult>

The IMentorQueryHandler<TQuery, TResult> interface of Novior.MentorAgent.Abstractions.Interfaces: Handles a query: a request that only reads, written as a…

View as Markdown
On this page

Handles a query: a request that only reads, written as a type of its own, usually a record. Registered with MentorOptions.Actions.AddQuery<TQuery, THandler>(), the query is one of the coordinator's actions, named after TQuery in snake_case and always read-only: the model gives the query's properties as the action's arguments, MentorAgent passes the query it built from them to IMentorQueryHandler<TQuery, TResult>.HandleAsync, and the model reads the result.

The handler is a service the application registers itself. An application that already sends its queries through a dispatcher, MediatR for example, writes a handler that sends the query on.

Namespace: Novior.MentorAgent.Abstractions.Interfaces. Package: Novior.MentorAgent.Abstractions.

public interface IMentorQueryHandler<TQuery, TResult>

Terminal
dotnet add package Novior.MentorAgent.Abstractions

Task<TResult?> HandleAsync(TQuery query, CancellationToken cancellationToken)

Answers query. An exception fails the action, and the model reads that it failed.

Parameters

  • query: The query, built from the model's arguments.
  • cancellationToken: Cancelled when the turn is.

Returns: The result the model reads.