# Show that the assistant is off

> Show users that the assistant is off, from your own switch or a console, with no release: IMentorAssistantStatus, the widget, the hub, other front ends.

- URL: https://docs.mentoragent.net/configure/turn-the-assistant-off
- Verified with: MentorAgent 1.5.0
- Last updated: 2026-11-27
- Packages: Novior.MentorAgent.Abstractions, Novior.MentorAgent, Novior.MentorAgent.Server, Novior.MentorAgent.Blazor

Use this page when your application can turn its assistant off without a release: a switch of its own, an admin page, or a console that stops the requests to the model. Here, the assistant is the agent as your users see it in the chat widget: the widget's texts and `IMentorAssistantStatus` use that name. Register an `IMentorAssistantStatus`, and the widget shows your users that the assistant is off, before anyone writes.

## What it does, and what it does not

- **It shows the state.** While the assistant is off, the widget does not let users write a message, and a sentence says why.
- **It does not turn the assistant off.** MentorAgent does not refuse the requests to the model because of it: your own switch does that, in your code. A turn that is already running ends as usual.
- **Only on or off.** The status has no reason and no author: keep those in your own switch.

Without an `IMentorAssistantStatus`, the assistant is on and nothing changes.

## Write the switch

The switch is yours. It says whether the assistant is on, and raises `Changed` when that changes:

```csharp title="AssistantSwitch.cs"
// The application's switch: your console or admin page calls Set
public sealed class AssistantSwitch : IMentorAssistantStatus
{
    private volatile bool _on = true;

    public bool IsOn => _on;

    public event EventHandler? Changed;

    public void Set(bool on)
    {
        if (_on == on) return;   // raised only when the value changes
        _on = on;
        foreach (var handler in Changed?.GetInvocationList() ?? [])
        {
            // A handler that throws does not stop the others
            try { ((EventHandler)handler)(this, EventArgs.Empty); }
            catch (Exception) { }
        }
    }
}
```

- **`Changed`** must be raised only when the value changes. It may be raised on a background thread. Each handler reads `IsOn` again and returns at once. Call each handler inside its own `try`, so that a handler that throws does not stop the others, as the example does.

Register the switch as a singleton in `Program.cs`, so that the widget, the hub and your console see the same switch:

```csharp title="Program.cs"
// One switch for the whole application, read by the widget
// and by the hub
services.AddSingleton<AssistantSwitch>();
services.AddSingleton<IMentorAssistantStatus>(
    sp => sp.GetRequiredService<AssistantSwitch>());
```

## What the widget shows

While `IsOn` is false, the chat widget:

- disables the input, the send button, the attachments and the microphone;
- offers no suggestion to send in the welcome panel;
- says *off* in its header, with a grey dot, where it says *online*;
- shows a sentence right above the input, in the language of the widget. The sentence has `role="status"`, so that a screen reader reads it when it appears:

> The assistant was turned off by the administrator

The sentence is translated into the ten languages of [`Language`](https://docs.mentoragent.net/reference/options#language). When `IsOn` turns true again, the widget is as before.

## WebAssembly and other front ends

Register the switch in the server project, the one that calls `AddMentorAgentServer()`. The hub tells its clients:

| On the hub | What it does |
|---|---|
| `GetAssistantStatus()` | Answers whether the assistant is on: `true` when the server registers no `IMentorAssistantStatus`. Call it when a connection opens, and again after each reconnect |
| `AssistantStatus(on)` | An event to every connection, each time the switch turns the assistant off or on |

- **The WebAssembly widget** of `Novior.MentorAgent.Blazor` reads the state when it connects, and follows each change as the widget on the server does. To do so, its client opens the connection when the widget is created, not at the first message. A message that the user sends before the state arrives waits for it, 5 seconds at most. While the assistant is off, the message is not sent, and it stays in the chat under the sentence.
- **A React, Angular, Vue or JavaScript front end** calls `GetAssistantStatus` and listens for `AssistantStatus` on its own connection, and then disables its own input. With `/mentor/agent.js`, `assistantIsOn()` and `onAssistantStatus(callback)` do this for you: see [Run recipes in your front end](https://docs.mentoragent.net/configure/any-front-end#run-recipes-in-your-front-end).

## Turn off only some actions

To turn off one action, or the actions of a Model Context Protocol (MCP) server, without turning off the assistant, use an [action policy](https://docs.mentoragent.net/reference/action-policies): see [Turn actions on and off from outside the code](https://docs.mentoragent.net/concepts/governance#turn-actions-on-and-off-from-outside-the-code). To change an option while the application runs, see [Change options while the app runs](https://docs.mentoragent.net/configure/runtime-options).

---

- Previous: [Change options while the app runs](https://docs.mentoragent.net/configure/runtime-options.md)
- Next: [Run a turn from your own code](https://docs.mentoragent.net/configure/run-a-turn-from-code.md)
