MentorAgent Docs
Menu

ReferencePackage: Novior.MentorAgent

MentorActionAttribute class

The MentorActionAttribute class of Novior.MentorAgent.Attributes: Advanced Level 1 — Decorates a method to expose it as an AI action with additional…

View as Markdown
On this page

Advanced Level 1 — Decorates a method to expose it as an AI action with additional metadata. For simple cases, the native .NET [Description("...")] is sufficient — zero dependencies. Use [MentorAction] when you need confirmation dialogs, categories, or proactive hints.

Example
// Simple
[MentorAction(Description = "Cancels an existing order")]
public async Task<bool> CancelOrder(int orderId, string reason) { }

// Advanced
[MentorAction(
    Description = "Cancels an existing order",
    Category = "Orders",
    RequiresConfirmation = true,
    ProactiveHint = "Suggest checking active orders first")]
public async Task<bool> CancelOrder(int orderId, string reason) { }

Namespace: Novior.MentorAgent.Attributes. Package: Novior.MentorAgent.

public sealed class MentorActionAttribute : Attribute

Terminal
dotnet add package Novior.MentorAgent

public MentorActionAttribute()

public string? Category { get; init; }

Free-form category, published as the skill's tag on the A2A agent card. It does not change what the assistant sees or does. Example: "Orders", "Customers", "Reports"

public required string Description { get; init; }

Natural language description used as the AI tool description.

public string? NavigateTo { get; init; }

Automatic navigation URL after tool execution (only on success). MentorAgent navigates automatically if the user is on a different page. Example: NavigateTo = "/products"

public string? ProactiveHint { get; init; }

Guidance for the assistant about what to suggest to the user before or after this action. Appended to the tool's description as "Guidance: …" — so the model reads it when it considers the tool — without changing how the tool is matched by semantic filtering. Example: "Suggest checking active orders first"

public bool ReadOnly { get; init; }

The action only reads: it changes no data. MentorAgent does not check this; it takes your word, the way an MCP client takes a server's readOnlyHint. It is published to MCP clients as readOnlyHint, and with MentorOptions.RequireLookupForRecordQuestions on such an action is one the assistant may be required to call before it answers a question about a value of your records. Ignored when the action also needs confirmation: confirmation is the mark of an action that changes data, and it wins. To declare actions by name instead — for example those marked only with [Description] — use MentorOptions.IsReadOnlyAction. Default: false

public string[] RequiredRoles { get; init; }

Roles allowed to run the action: the user needs any one of them and must be authenticated. The user is the caller of the hub, of /mentor/chat or of A2A (Novior.MentorAgent.Server), and in a Blazor circuit the host's AuthenticationStateProvider's; with neither, nobody can run it. Tested with ClaimsPrincipal.IsInRole — the identity's own RoleClaimType, so roles in a roles claim (Entra ID) work too; names are case-sensitive. The same test decides the MCP surface when McpCallerPrincipal is set. Empty (default) = no role check at all, for signed-in and anonymous users alike.

public bool RequiresConfirmation { get; init; }

If true, the widget shows a confirmation dialog before executing the action. Use for destructive or irreversible operations.

Left out, the action follows MentorOptions.RequireConfirmationForWrites: on by default, so an action that is not MentorActionAttribute.ReadOnly asks for confirmation. Write RequiresConfirmation = false to opt one action out — the declaration itself is what counts, which is why leaving it out and writing false are not the same.

public bool RequiresConfirmationDeclared { get; }

Whether MentorActionAttribute.RequiresConfirmation was written in the attribute, true or false. An attribute argument cannot be a bool?, so the setter records it.

Read it to tell the two actions MentorActionAttribute.RequiresConfirmation alone cannot: with MentorOptions.RequireConfirmationForWrites on, an action that declares nothing asks for confirmation, and one that declares RequiresConfirmation = false does not, while MentorActionAttribute.RequiresConfirmation reads false for both. This is only what the attribute says: the confirmation an action gets also depends on MentorActionAttribute.ReadOnly and on MentorOptions.IsReadOnlyAction and MentorOptions.RequiresApproval.