MentorAgent Docs
Menu

ConceptPackage: Novior.MentorAgent

What is MentorAgent?

MentorAgent turns C# methods into tools for an AI agent, and checks on every channel who may call each one and whether the user confirms.

View as Markdown
On this page

MentorAgent is a .NET library that lets an AI agent call the C# methods of an application you already have. You declare the rules: which roles may call each method, and whether the user must confirm first. MentorAgent is built on Microsoft Agent Framework (external site), Microsoft's framework for building AI agents.

You mark your methods with attributes. MentorAgent turns them into tools, the functions an AI model can ask to run. It also builds the prompt and connects the agents. For Blazor, it gives you a ready-made chat widget.

It is distributed on NuGet as a family of packages. Its source code is public on GitHub (external site). The current version is 1.0.0, the first stable version. A change that breaks your code comes only with a new major version.

The Glossary explains every term that these pages use.

This service has two actions. One only reads data. The other changes data, so it has a role and asks for confirmation:

CaseService.cs
public class CaseService(ICaseStore store)
{
    // Only reads data: it never asks for confirmation
    [MentorAction(
        Description = "Gets the status of a support case",
        ReadOnly = true)]
    public Task<string> GetStatusAsync(string caseNumber)
        => store.GetStatusAsync(caseNumber);

    // Changes data: only supervisors, and the user confirms first
    [MentorAction(
        Description = "Closes a support case with a resolution",
        RequiresConfirmation = true,
        RequiredRoles = ["Supervisors"])]
    public Task CloseAsync(string caseNumber, string resolution)
        => store.CloseAsync(caseNumber, resolution);
}
  • Actions. An action is a public method of one of your services that the agent can call as a tool. You mark it with [MentorAction]. The attribute says which roles may call the method and whether the user must confirm first. A method that only reads declares ReadOnly = true. A method that changes data asks the user to confirm by default.
  • Specialists. The coordinator is the main agent: it answers the user. A class marked with [MentorAgent] is a specialist, an agent for one area. The coordinator hands the requests of that area to it: this is called a handoff.
  • Teams. A class marked with [MentorTeam] is a team: several agents that discuss a request in a group chat before the coordinator answers.
  • Pages. The agent can open a page that you mark with [MentorPage]. A page can also give the agent its page context (the data that the user sees). It can also register UI actions (actions that run on the page itself).
  • Skills. A skill holds knowledge that the agent loads only when a request needs it. You write it as a class marked with [MentorSkill] or as a SKILL.md file, and turn skills on with EnableSkills.

The library handles everything else, such as the system prompt, the session and the widget.

Any interactive page can give the agent its page context through IMentorPageContext, for example the selected record. The page calls Set(key, value) for the data, and Clear() in Dispose(), so its data and actions go away when the user leaves the page.

The agent and your actions run in your .NET application, which these pages call the host. The user interface and the other programs that talk to the agent can use any technology:

PartWhat it can be
Your applicationAn ASP.NET Core application on .NET 10, or a .NET MAUI app with the agent inside it, built for Android and Windows
The user interfaceThe ready-made chat widget, in Blazor Server, WebAssembly, Auto or MAUI. Or your own UI: React, Angular, Vue or another JavaScript framework, a native mobile or desktop app, or any client that speaks SignalR or HTTP. See Any front end
Other programsAI assistants and coding tools that call your actions as tools through the Model Context Protocol (MCP), an open protocol for AI applications. Other agents that call your agent over the Agent-to-Agent (A2A) protocol. Both can use any programming language: see Channels
AreaWhat MentorAgent does
AgentsA coordinator that answers directly, hands the request to a specialist (handoff) or asks a team (group chat). It is built on Agent Framework 1.18.0
GovernanceRole checks and user confirmation on each action, on every channel. An action that changes data asks for confirmation unless you declare otherwise. MCP and A2A callers cannot confirm. For them, an action that needs confirmation is not offered, or it is refused when they call it. See Roles, confirmation and governance
ContextBefore every model call, MentorAgent adds this context to the prompt: the current page, the signed-in user and their roles, and the page's own data. When you turn them on, it also adds memory, the skills catalog and retrieved documents
ChannelsThe ways a client reaches the same agent: the widget in Blazor Server, Blazor WebAssembly or Auto and .NET MAUI; a SignalR hub or Server-Sent Events (SSE) for React, Angular, Vue or a mobile app; MCP and A2A for other agents and tools: see Channels
CostA prompt that starts the same way on every call, so the model provider can cache it; token counts per call; optional routing between a cheap and a strong model; and a cost dashboard
KnowledgeOptional. Retrieval-augmented generation (RAG) adds the most relevant documents from your vector store to the prompt. Your document source can filter the documents by the signed-in user and by the current page. It can also attach a fact, such as a date, to each document. Memory keeps facts about each user. Agent Skills load extra instructions only when a request needs them
WidgetStreamed answers with a Stop button, cards returned by your actions and, when you turn them on, voice input and output, a first-run tour built from your pages and actions, and image input: see the widget options
Structured resultsIMentorStructured asks the model for a typed result, for example to fill in a form
TestsMentorEvaluator runs test prompts on your ChatClient and fails a test when token use or answer quality gets worse

A user sends a message from the widget or from your own front end. The message goes to the coordinator, an Agent Framework agent that runs in your application. Before the model sees the message, MentorAgent adds the context: the application, the page, the user and whatever the page registered.

The coordinator sees your actions as tools, each with the name and description taken from your method. It can answer directly, call one or more tools, hand the request to a specialist, or ask a team.

Every call to one of your methods passes the role check first. If the method asks for confirmation, the user must also confirm. These rules apply whichever agent makes the call: the coordinator, a specialist or a team member.

The answer then streams back to the client that sent the message.

A turn is one message and everything the agent does to answer it, model calls and tool calls included.

MentorAgent does not replace Agent Framework: it configures it. With Agent Framework alone, a tool that needs approval (Agent Framework's word for a confirmation) makes the run return an approval request. Your code must then ask the user and send back the answer. MentorAgent adds three things, on every channel: the role check before the approval, the confirmation box, and the way the answer travels back.

You can also pass your own Agent Framework agent (AIAgent). The coordinator's confirmations can also use Agent Framework's own approval protocol: see Blocking and Native modes.

MentorAgent is a good fit when:

  • you have a .NET 10 application whose methods already do the work;
  • some of those methods change data;
  • you want the agent to use them under the same roles your users have.

MentorAgent is not a good fit when:

  • your application runs on .NET 8 or .NET 9, because MentorAgent runs on .NET 10 only;
  • you want a chatbot that only answers from documents, without actions. For that, Microsoft.Extensions.AI or Agent Framework alone is enough;
  • you need a workflow engine.

Your front end does not matter: any front end talks to the same backend. Roles decide who may call an action, not which records a user may see. Permissions on single records stay in your code.

MentorAgent 1.0.0 is distributed under the Apache License 2.0 (external site). You can use, change and distribute it, also in paid software. When you redistribute it, include what every package contains:

  • the license text, in LICENSE;
  • the copyright notice, in NOTICE;
  • the notices for the icons and fonts that the widget takes from other projects, in THIRD-PARTY-NOTICES.md.

If you change files of the library, say so in the files you changed. Versions up to and including 1.0.0-rc.14 were released under the MIT license (external site), which still applies to them. The samples and the finished Quickstart project are under the MIT license too.