Questa pagina non è ancora tradotta in italiano: qui la trovi in inglese.
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.
On this page
Use this page when an administrator must change how the agent behaves without restarting the application, for example to turn on the safety check, change the rate limit or refuse off-topic questions. MentorAgent reads most options once, before the application starts. Since 1.3.0, it reads sixteen of them again while the application runs, and a change applies to the next turn or to the next session.
When to choose it
Section titled “When to choose it”- Choose it for a switch that an administrator flips, such as the safety check or the rate limit, in an application that should not restart.
- To turn actions on and off, or change their roles and confirmations, use a governor instead: it decides per action, and per session.
- For any other option, change the configuration and restart the application.
Change an option
Section titled “Change an option”The options are one object for the whole process: the value of IOptions<MentorOptions>. Inject it, and assign the property:
// Behind an admin page: switches that apply without a restart
public class SafetySwitch(IOptions<MentorOptions> options)
{
// From the next turn of every session, open conversations included
public void TurnOnSafetyCheck()
{
if (MentorRuntimeOptions.IsChangeable(
nameof(MentorOptions.EnableSafetyCheck)))
options.Value.EnableSafetyCheck = true;
}
// From the next session: open conversations keep their value
public void RefuseOffTopic(bool refuse) =>
options.Value.RefuseOutOfScope = refuse;
}- Assign the property on that object. Every session reads the same object, so the change reaches all of them.
- Replace a collection, do not change it in place. Assign a new list or set.
- A turn already running may still read the value from before.
MentorRuntimeOptions.IsChangeable(name)says whether an option is read again.MentorRuntimeOptions.Changeablelists them all, each withMentorOptionReadAt.TurnorMentorOptionReadAt.Session.- Who may change it is yours to decide. Put the page that changes an option behind your own authorization, as you would any administration page.
The options you can change
Section titled “The options you can change”From the next turn of every session, including the conversations already open:
| Option | What a change does |
|---|---|
Language | The language of the next turn, and the widget's texts |
RateLimitPerUser | The limit that the next message is counted against; 0 turns it off |
RateLimitWindowSecs | The window that the next message is counted in |
ConfirmationMessage | The text of the next confirmation box |
ConfirmationTimeout | The deadline of the next confirmation |
ActionPolicyTimeout | The deadline of the next question to a policy or to the governor |
EnableActionFeedback | Whether the next action shows the bar of the running action |
EnableGenerativeCards | Whether the next result of a card method becomes a card |
EnableSafetyCheck | Whether the next message is checked |
CheckAnnouncedActions | Whether the next replies are checked for an action that they announce or report as done, and that no tool of the turn did |
From the next session: the conversations already open keep the value that they started with.
| Option | What a change does |
|---|---|
MentorshipLevel | How the agent explains and guides, in a new session's instructions |
ProactiveNextSteps | Whether the Proactive level of a new session closes with next steps |
EnableRichResponses | Whether a new session's instructions ask for formatted replies |
RefuseOutOfScope | Whether a new session refuses the messages outside your application's scope |
ToolFilterMaxTools | The most tools that a new session's filter sends |
MaxSessionMessages | The history budget of a new session |
A session begins with a new Blazor circuit, a new hub connection, a new MAUI app scope, a request to /mentor/chat, or a task over Agent-to-Agent (A2A).
The options you cannot change
Section titled “The options you cannot change”Every other option is read before the application starts. One may seem to work when you change it later, but nothing promises it, and a later version may read it only once. Two are left out on purpose:
RequireConfirmation: the Model Context Protocol (MCP) server decides at startup which actions it publishes, so a later change would apply only in part.MaxMessageLength: the input box of the widget gets a copy of the value at startup.
The widget's options, such as BotName, Theme and EnableVoiceInput, are copied when the widget is registered. Some options are also read when the services are registered: see When MentorAgent reads the options.
Several instances
Section titled “Several instances”Each instance has its own options object. A change made through IOptions<MentorOptions> in one instance does not reach the others. To change an option on every instance, change it on each one, for example from a shared setting that each instance reads, or restart them with the new configuration. See Run on several instances.
Common errors
Section titled “Common errors”The change does not apply
Section titled “The change does not apply”- The option is not in the tables above: it is read only before the application starts.
- The option applies from the next session: open a new conversation.
- The code changed a collection in place: assign a new one.
- The application runs on several instances, and the change reached only one.
Vedi anche
Sezione “Vedi anche”- Configuration options — Every MentorOptions property with its type, default and effect, grouped by area, plus the options of the WebAssembly client and the YAML loader.
- Ruoli, conferma e governance — Ruoli e approvazione human-in-the-loop per i tool di un agente AI in .NET: controlli nel codice, non nel prompt, su ogni canale, e cosa resta a te.
- Production checklist — Settings to review before production: governance, safety check, rate limits, cost and routing, history, several instances, observability and outgoing data.
