MentorAgent Docs
Menu

Questa pagina non è ancora tradotta in italiano: qui la trovi in inglese.

ConceptPackage: Novior.MentorAgent

What is MentorAgent?

MentorAgent is the application layer for AI agents in .NET: your C# methods become their tools, and the rules your code declares hold on every channel.

On this page

MentorAgent is the application layer for AI agents in .NET. The agent works with what your application already does: the C# methods you mark become its tools, and the rules you declare next to them decide what it can do. Who may run each action, what needs the user's confirmation, which rules of your own apply: MentorAgent checks them in your code, on every channel, from the browser to a phone, an AI assistant or another agent. A rule in a prompt can be talked around; a check in your code cannot.

You govern the agent the way you govern the application, with the users, roles and code you already have. MentorAgent is built on Microsoft Agent Framework (external site), Microsoft's framework for building AI agents: it configures the framework and adds what an application needs around it.

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 for the model and connects your agents to each other. 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.2.0. The first stable version was 1.0.0. A change that breaks your code comes only with a new major version.

The Glossary explains every term that these pages use. For the idea behind MentorAgent, told without code, read What is MentorAgent on the blog.

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 SetPageName first and Set(key, value) for the data. In Dispose() it calls Clear(pageName) with the same name, so its data and actions go away when the user leaves the page. Clear(pageName) leaves alone what the next page has already registered.

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.26.0
GovernanceRole checks and user confirmation on each action, on every channel, plus the action policies you write for rules per record or per company. Every decision, who confirmed it included, can reach an observer of yours. 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 (Blazor and .NET MAUI), a SignalR hub or Server-Sent Events (SSE) for your own front end, and MCP or 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
TestsA fake model checks your actions, roles and confirmation boxes in automated tests, and MentorEvaluator runs test prompts on your ChatClient and fails a test when token use or answer quality gets worse: see Test without a model

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 as tools the actions that the user may run, 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, then your action policies. 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. A rule per record or per company is an action policy that you write, and MentorAgent applies it on every channel.

MentorAgent 1.2.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 and trademark notices, 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.

MentorAgent is a trademark, and the Apache License 2.0 does not license the name or the logo. The trademark policy, TRADEMARKS.md (external site), says how you can use them.