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.
On this page
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
Section titled “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
Section titled “Write the switch”The switch is yours. It says whether the assistant is on, and raises Changed when that changes:
// 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) { }
}
}
}Changedmust be raised only when the value changes. It may be raised on a background thread. Each handler readsIsOnagain and returns at once. Call each handler inside its owntry, 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:
// 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
Section titled “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. When IsOn turns true again, the widget is as before.
WebAssembly and other front ends
Section titled “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.Blazorreads 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
GetAssistantStatusand listens forAssistantStatuson its own connection, and then disables its own input. With/mentor/agent.js,assistantIsOn()andonAssistantStatus(callback)do this for you: see Run recipes in your front end.
Turn off only some actions
Section titled “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: see Turn actions on and off from outside the code. To change an option while the application runs, see Change options while the app runs.
See also
Section titled “See also”- Change options while the app runs — Which MentorAgent options you can change while the application runs, when a change applies, and what happens to the conversations already open.
- Any front end: React, Angular, Vue — Build the chat in React, Angular, Vue or a mobile app with a .NET AI agent behind it: SignalR or Server-Sent Events, confirmation over HTTP, stopping an answer.
- Roles, confirmation and governance — Role checks and human-in-the-loop approval for AI agent tools in .NET, enforced in code on every channel and not in the prompt, and what stays in your code.
