# IMentorCommandHandler<TCommand, TResult>

> The IMentorCommandHandler<TCommand, TResult> interface of Novior.MentorAgent.Abstractions.Interfaces: Handles a command that returns a result: a request that…

- URL: https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentorcommandhandler-2
- Verified with: MentorAgent 1.4.0
- Last updated: 2026-11-18
- Packages: Novior.MentorAgent.Abstractions

Handles a command that returns a result: a request that changes data, written as a type of its own, whose result the model reads as an action's. Registered with `MentorOptions.Actions.AddCommand<TCommand, THandler>()`, as [`IMentorCommandHandler<TCommand>`](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentorcommandhandler-1).

## Definition

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

`public interface IMentorCommandHandler<TCommand, TResult>`

```shell
dotnet add package Novior.MentorAgent.Abstractions
```

## Methods

### `HandleAsync`

`Task<TResult?> HandleAsync(TCommand command, CancellationToken cancellationToken)`

Runs `command`. An exception fails the action, and the model reads that it failed.

**Parameters**

- `command`: The command, built from the model's arguments.
- `cancellationToken`: Cancelled when the turn is.

**Returns:** The result the model reads.

---

- Previous: [IMentorCommandHandler<TCommand> interface](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentorcommandhandler-1.md)
- Next: [IMentorMetrics interface](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentormetrics.md)
