# IMentorCommandHandler<TCommand> interface

> The IMentorCommandHandler<TCommand> interface of Novior.MentorAgent.Abstractions.Interfaces: Handles a command: a request that changes data, written as a…

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

Handles a command: a request that changes data, written as a type of its own, usually a record. Registered with `MentorOptions.Actions.AddCommand<TCommand, THandler>()`, the command is one of the coordinator's actions, named after `TCommand` in snake\_case: the model gives the command's properties as the action's arguments, and MentorAgent passes the command it built from them to [`IMentorCommandHandler<TCommand>.HandleAsync`](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentorcommandhandler-1#handleasync). A command is a write, so the default confirmation for writes applies to it.

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

## Definition

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

`public interface IMentorCommandHandler<TCommand>`

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

## Methods

### `HandleAsync`

`Task 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.

---

- Previous: [IMentorAgent interface](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentoragent.md)
- Next: [IMentorCommandHandler<TCommand, TResult>](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentorcommandhandler-2.md)
