Skip to main content

Fixed: MAAI001 'Microsoft.Agents.AI.RoutePersistingRoutingChatClient' is for evaluation purposes only

· 10 min read
Jagdish Kumawat
Founder @ Dewiride

I wanted one conversation to move between two Microsoft Foundry models with Agent Framework's RoutePersistingRoutingChatClient, and dotnet run stopped at the build: error MAAI001: 'Microsoft.Agents.AI.RoutePersistingRoutingChatClient' is for evaluation purposes only and is subject to change or removal in future updates. The router is experimental in Agent Framework 1.28. Two pragma lines around the one statement that creates it accept that, and the app runs.

What I Was Doing​

I was building StudyBuddy, a console app with a maths tutor agent. Ordinary questions go to one model deployment, gpt-5.6-luna, and a harder question can move the same conversation to another, gpt-5.6-sol. Agent Framework does this with RoutePersistingRoutingChatClient: a chat client that holds several named chat clients, called routes, and sends each request to the route that's active for the conversation's session.

I created the app with these commands:

Terminal
dotnet new console -o StudyBuddy
cd StudyBuddy
dotnet add package Microsoft.Agents.AI.Foundry --version 1.28.0-preview.261106.1
dotnet add package Azure.Identity --version 1.21.0
  • dotnet new console -o StudyBuddy creates a console app in a new StudyBuddy folder, and cd moves into it.
  • Microsoft.Agents.AI.Foundry is Agent Framework's package for Microsoft Foundry. Version 1.28.0-preview.261106.1 is a preview release.
  • Azure.Identity lets the app sign in to Foundry with your Azure CLI account.

Then I replaced everything in Program.cs with this:

Program.cs (as it was)
using System.Text.Json;
using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;

// Both routes use the project's Chat Completions API, which keeps no conversation on the service.
// The agent's session keeps it, so either route can continue it.
var openAI = new AIProjectClient(
new Uri("https://foundry-devblogs-exp.services.ai.azure.com/api/projects/proj-devblogs-exp"),
new AzureCliCredential())
.GetProjectOpenAIClient();

Dictionary<string, IChatClient> routes = new()
{
["everyday"] = openAI.GetChatClient("gpt-5.6-luna").AsIChatClient(),
["expert"] = openAI.GetChatClient("gpt-5.6-sol").AsIChatClient(),
};

// The router picks one of the routes for every request, from the route stored in the session.
RoutePersistingRoutingChatClient router = new(routes, new RoutePersistingRoutingChatClientOptions { DefaultRoute = "everyday" });

AIAgent tutor = router.AsAIAgent(
instructions: "You are a patient maths tutor. Answer in two or three short sentences.",
name: "StudyBuddy");

AgentSession session = await tutor.CreateSessionAsync();

await AskAsync("My name is Priya. What is 3/4 + 1/8?");

// Move this conversation to the stronger model for a harder question.
router.SetActiveRoute(session, "expert");
await AskAsync("Why does dividing by a fraction give the same result as multiplying by its reciprocal? Use my name.");

// The active route is saved with the session, next to its chat history.
JsonElement saved = await tutor.SerializeSessionAsync(session);
foreach (JsonProperty state in saved.GetProperty("stateBag").EnumerateObject())
{
Console.WriteLine($"Session state: {state.Name}");
}

async Task AskAsync(string question)
{
AgentResponse answer = await tutor.RunAsync(question, session);
string? model = (answer.RawRepresentation as ChatResponse)?.ModelId;
Console.WriteLine($"[{router.GetActiveRoute(session)} -> {model}] {answer.Text}");
Console.WriteLine($" {answer.Usage?.InputTokenCount} input tokens, {answer.Usage?.OutputTokenCount} output tokens");
}
  • The two routes are chat clients for the two deployments, both on the project's Chat Completions API, named everyday and expert.
  • Line 21 creates the router with both routes, and makes everyday the route every new session starts on.
  • router.AsAIAgent(...) turns the router into an agent, and CreateSessionAsync starts the conversation.
  • router.SetActiveRoute(session, "expert") moves this conversation to the other model before the second question.
  • AskAsync prints the active route, the model that answered and the answer, then the tokens the request used. The model's name comes from the response the service sent back: How to See Which Model Answered a Microsoft Agent Framework Agent Run in C# shows how that works.
  • The last loop saves the session to JSON and prints the names of the state it holds.

What I Expected​

The first question answered on the everyday route and the second on the expert route. The code uses only what Microsoft's documentation describes for this client: Set the initial route with RoutePersistingRoutingChatClientOptions.DefaultRoute, inspect a session's route with GetActiveRoute, and change it with SetActiveRoute.

What I Got​

Terminal
dotnet run
Output
/Users/you/source/StudyBuddy/Program.cs(21,1): error MAAI001: 'Microsoft.Agents.AI.RoutePersistingRoutingChatClient' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
/Users/you/source/StudyBuddy/Program.cs(21,59): error MAAI001: 'Microsoft.Agents.AI.RoutePersistingRoutingChatClientOptions' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

The build failed. Fix the build errors and run again.

macOS-style terminal window titled Terminal — StudyBuddy showing dotnet run stopping with two MAAI001 errors on line 21 of Program.cs: Microsoft.Agents.AI.RoutePersistingRoutingChatClient and Microsoft.Agents.AI.RoutePersistingRoutingChatClientOptions are for evaluation purposes only and are subject to change or removal in future updates, followed by The build failed. Fix the build errors and run again.

dotnet run builds the project before it runs it. The build stopped with two errors, so the app never started and no model was called.

What I Checked​

Where the errors point. Both are on line 21, the line that creates the router. Column 1 is the type name RoutePersistingRoutingChatClient, and column 59 is RoutePersistingRoutingChatClientOptions, the options object on the same line. The lines further down that use the router, SetActiveRoute on line 32 and GetActiveRoute on line 46, got no error: the build reported only the two places where the code names the types.

What Microsoft's documentation says about the router. The Agent Framework page on switching models at runtime introduces it like this: The .NET SDK provides the experimental RoutePersistingRoutingChatClient. So nothing was wrong with my code. In Microsoft.Agents.AI 1.28.0 the class is marked [Experimental("MAAI001")], and the second error shows that its options class reports the same ID.

What .NET says about experimental APIs. The .NET documentation on preview APIs: When building against an experimental API, the compiler produces an error. And: To express consent to using an experimental API, you suppress the specific diagnostic. It recommends the project's <NoWarn> property for that, and it expects each experimental feature to have its own ID. Agent Framework doesn't work that way: the router, its options and the session store all report MAAI001 (Fixed: MAAI001 'Microsoft.Agents.AI.AgentSessionStore' is for evaluation purposes only). A project-wide <NoWarn> would accept all of them at once.

How far a pragma reaches. The C# reference on #pragma warning: The disable takes effect beginning on the next line of the source file. The warning is restored on the line following the restore. A disable before line 21 and a restore after it accept MAAI001 for that one statement, and any other experimental Agent Framework API added later still gets its own error.

Why It Happens​

RoutePersistingRoutingChatClient and RoutePersistingRoutingChatClientOptions are experimental in Agent Framework 1.28. The compiler turns every place that names an experimental type into an error, and the error stays until you suppress its diagnostic ID. Suppressing it is how you agree that the API can still change.

The Fix​

Wrap the statement that creates the router in #pragma warning disable MAAI001 and #pragma warning restore MAAI001, with a comment that says why:

Program.cs (the router)
// The router picks one of the routes for every request, from the route stored in the session.
// It's experimental in Agent Framework 1.28 (MAAI001), so its API can still change.
#pragma warning disable MAAI001
RoutePersistingRoutingChatClient router = new(routes, new RoutePersistingRoutingChatClientOptions { DefaultRoute = "everyday" });
#pragma warning restore MAAI001
  • #pragma warning disable MAAI001 stops the compiler from reporting MAAI001, from the next line on.
  • #pragma warning restore MAAI001 turns it back on after the router's line.
  • The comment tells the next person who reads the file what was accepted, and why.

Nothing else in the file changes. The calls to SetActiveRoute and GetActiveRoute need no pragma: they never reported the error.

After the Fix​

Terminal
dotnet run
Output
[everyday -> gpt-5.6-luna-2026-07-09] Hi Priya! Convert \( \frac{3}{4} \) to eighths: \( \frac{3}{4}=\frac{6}{8} \).
So, \( \frac{6}{8}+\frac{1}{8}=\boxed{\frac{7}{8}} \).
43 input tokens, 68 output tokens
[expert -> gpt-5.6-sol-2026-07-09] Priya, dividing by a fraction asks how many of that fraction fit into a number. Multiplying by its reciprocal undoes the fraction’s division and multiplication, so \(a \div \frac{b}{c}=a \times \frac{c}{b}\).
141 input tokens, 81 output tokens
Session state: RoutePersistingRoutingChatClient
Session state: InMemoryChatHistoryProvider

macOS-style terminal window titled Terminal — StudyBuddy showing dotnet run after the fix: the first answer on the everyday route from gpt-5.6-luna-2026-07-09 with 43 input and 68 output tokens, the second on the expert route from gpt-5.6-sol-2026-07-09 with 141 input and 81 output tokens, then the session state RoutePersistingRoutingChatClient and InMemoryChatHistoryProvider

The build passed and the router did its job. The first answer came from gpt-5.6-luna-2026-07-09 on the everyday route, and after SetActiveRoute(session, "expert") the second came from gpt-5.6-sol-2026-07-09. The second model used Priya's name, which only the first question gave, so the conversation's history went with it to the other model. Both models wrote the fractions in LaTeX, such as \frac{3}{4}, and the app printed their text as it came.

The last two lines are what the session saved: the router's state and the chat history. The router stores its state under its own type name: the documentation of its options says the key Defaults to the name of the RoutePersistingRoutingChatClient type.

Common Mistakes​

MistakeWhat happensDo this instead
Adding <NoWarn>$(NoWarn);MAAI001</NoWarn> to the project to make the error go awayEvery Agent Framework API that reports MAAI001 is accepted, including ones you add laterSuppress it around the router's statement
#pragma warning disable without an IDEvery warning after it in the file is hidden tooName the ID: #pragma warning disable MAAI001
Leaving out the restore lineMAAI001 stays off for the rest of the fileEnd with #pragma warning restore MAAI001

Troubleshooting​

SymptomLikely causeFix
error MAAI001 for RoutePersistingRoutingChatClientThe statement names an experimental typeWrap it in #pragma warning disable MAAI001 and restore
error MAAI001 for RoutePersistingRoutingChatClientOptionsThe options type is experimental tooKeep the statement that creates the options between the same two lines

FAQ​

Do the router's method calls need the pragma too?​

No. Only line 21 reported MAAI001, at the two places that name the types. The calls to SetActiveRoute and GetActiveRoute further down built without it.

Is it safe to use an experimental API?​

It works, but its shape can change in a later version, and suppressing MAAI001 is how you accept that. Keeping the code that names it in one statement, as here, means a change to the API touches one place.

Conclusion​

error MAAI001 on RoutePersistingRoutingChatClient means the router is experimental in Agent Framework 1.28, as Microsoft's documentation on switching models at runtime says. Wrap the statement that creates it, options included, in #pragma warning disable MAAI001 and #pragma warning restore MAAI001, with a comment that says why. The app then built, and the conversation moved from gpt-5.6-luna to gpt-5.6-sol with its history.

Additional Resources​