# IMentorOrchestrator interface

> The IMentorOrchestrator interface of Novior.MentorAgent.Abstractions.Interfaces: Public contract for the MentorAgent orchestrator. Implemented by…

- URL: https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentororchestrator
- Verified with: MentorAgent 1.2.0
- Last updated: 2026-10-27
- Packages: Novior.MentorAgent.Abstractions

Public contract for the MentorAgent orchestrator. Implemented by `MentorOrchestrator` (Blazor Server) and `WasmMentorOrchestrator` (Blazor WASM via SignalR). Injected into `ChatWidget` — the component works identically in both contexts.

## Definition

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

`public interface IMentorOrchestrator`

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

## Methods

### `CancelCurrentRequest`

`void CancelCurrentRequest()`

Cancels the current AI request.

### `ResetSessionAsync`

`Task ResetSessionAsync(CancellationToken ct = default)`

Resets the conversation session.

### `RespondToApprovalAsync`

`Task RespondToApprovalAsync(ConfirmationRequest req, bool approved, CancellationToken ct = default)`

Responds to a pending HITL confirmation dialog.

### `RestoreSessionAsync`

`Task RestoreSessionAsync(JsonElement snapshot, CancellationToken ct = default)`

Restores a conversation from a snapshot produced by [`IMentorOrchestrator.SerializeSessionAsync`](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentororchestrator#serializesessionasync).

Throws `ArgumentException` if the snapshot is not one of ours or was written by an incompatible version, leaving the current conversation untouched. That is deliberate: the Agent Framework's own deserializer accepts unrelated JSON and returns an empty session, so without this check a stale `localStorage` entry would silently replace the conversation the user is having.

### `SendMessageAsync`

`Task SendMessageAsync(string userMessage, CancellationToken ct = default)`

Sends a user message and starts the AI response.

`Task SendMessageAsync(MentorUserMessage message, CancellationToken ct = default)`

Sends a user turn: its text, its images and its [`MentorUserMessage.Language`](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-models/mentorusermessage#language). The turn is answered in that language, and the texts the server writes for it are in that language too. An implementation written before this method existed gets the call above, and ignores the language.

`Task SendMessageAsync(string userMessage, IReadOnlyList<MentorAttachment>? attachments, CancellationToken ct = default)`

Sends a user message with optional image attachments (roadmap \#13) and starts the AI response. Attachments are ignored unless `MentorOptions.EnableImageInput` is set and the chat model is vision-capable. Passing `null`/empty is equivalent to the text-only overload.

### `SerializeSessionAsync`

`Task<JsonElement?> SerializeSessionAsync(CancellationToken ct = default)`

Saves the current conversation as a snapshot. The snapshot is the conversation **in clear**: keep it on the server, or protected (e.g. `ProtectedLocalStorage`) — never as text a user can read or edit, because a restored snapshot is history the model trusts. Novior.MentorAgent.Server's `/mentor/session` hands clients a protected, user-bound form instead. Returns `null` when there is no conversation yet — which a caller must tell apart from a snapshot, or it will overwrite a good stored one with nothing.

This lives here rather than on `IMentorSessionManager` because every method there takes the coordinator `AIAgent` as its first argument, and the coordinator is deliberately not handed out to application code — running it directly would bypass the guardrails, the rate limiter and both gates. The orchestrator already owns it, and already carries the third session operation ([`IMentorOrchestrator.ResetSessionAsync`](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentororchestrator#resetsessionasync)).

---

- Previous: [IMentorMetricsStore interface](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentormetricsstore.md)
- Next: [IMentorPageContext interface](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-interfaces/imentorpagecontext.md)
