Trying Blazor AI Components (Experimental .NET 11) + AG-UI with MudBlazor

This post is currently a recap, or really just my speaker notes, jotted down before sharing at .NET Conf Thailand 2026 (You can read a recap in Thai). I noticed the Blazor team had launched Blazor AI components, which also support connecting via AG-UI, so I picked it as the topic to share with everyone.

The key challenge for me: adding Blazor AI Components to the main web app I presented in my previous talk (using Skills in Microsoft Agent Framework), which uses MudBlazor, without the two clashing. MudBlazor has known conflicts with the bootstrap.css that ships with Blazor.

For Thai Version: ลองใช้ Blazor AI Components (Experimental .NET 11) + AG-UI ร่วมกับ MudBlazor

A Quick Recap of Microsoft Agent Framework

📙 Microsoft Agent Framework (MAF) is a NuGet library that makes it easier to build AI agents on the .NET, Python, and Go (preview) stacks. It supports plain chat, workflows, and even harness agents that handle memory and tool approval.

📙 It also supports open standards for connecting to other agents, such as Agent2Agent (A2A) (Spec) and AG-UI (Spec). A2UI (Spec) is still under discussion.

📙 In this talk, I'll focus on integrating AG-UI in Microsoft Agent Framework with an existing frontend that uses Blazor AI Components.

What is AG-UI, and what problem does it solve?

AG-UI (Agent–User Interaction Protocol) is an open standard for communication between the frontend and the AI agent + backend. It is event-based and defines a common set of events. Previously, every framework, such as LangGraph, CrewAI, Google ADK, and Microsoft Agent Framework, had its own streaming format, so you had to write an adapter to make them work together every time you switched to a new agent. With AG-UI, the frontend doesn't need to know how the agent thinks behind the scenes. It only needs to know which events exist and how to handle them.

-Why an event-based approach?

📙 REST API + a streaming format is a poor fit. REST APIs suit short tasks. Agent work involves reasoning, planning, and tool calling, and can take several minutes. You end up customizing timeouts and writing custom code, and the more you customize, the tighter the coupling gets and the harder it is to change anything.

📙 AG-UI works in an event-sourcing style. The agent keeps emitting events to report what it's doing. There are 16 event types in total, but I'll only explain the main ones here.

  • LIFECYCLE group: tracks the agent's run. Events: RUN_STARTED / RUN_FINISHED / RUN_ERROR
  • TEXT_MESSAGE group: streams a message piece by piece. Events: TEXT_MESSAGE_START / TEXT_MESSAGE_CONTENT / TEXT_MESSAGE_END
  • TOOL_CALL group: the agent calls a tool, and can stream the tool call's arguments, so the UI can pre-fill a form while they arrive. Events: TOOL_CALL_START / TOOL_CALL_ARGS (the input) / TOOL_CALL_END / TOOL_CALL_RESULT
  • State management group (state sync):
    - STATE_SNAPSHOT: the app's entire state in one payload
    - STATE_DELTA: sends only the changed parts of the shared state (as a JSON Patch) instead of the whole thing
  • INTERRUPT: pauses and waits for a human in the loop, for example to approve running a script
Agent  → TOOL_CALL_START (transfer_funds) …
Agent  → RUN_FINISHED { outcome: "interrupt", interrupt: { id, reason, payload } }
App    → shows a UI for the user to decide (Approve / Reject / Edit)
User   → clicks Approve
App    → RunAgentInput { resume: [{ interruptId, payload }] }   // a new run
Agent  → RUN_STARTED … RUN_FINISHED { outcome: "success" }

📙 For the other events, see the AG-UI schema, which defines each one clearly. Here's an example request:

{
  "threadId": "r-draft",
  "runId": "run_bxac…",
  "protocolVersion": "1.0",
  "state": {
    "draft": {
      "amount": 0, "category": "",
      "note": "" },
    "receipt": { "selectedId": null,
      "proposal": null }
  },
  "messages": [{ "id": "", "role": "user",
    "content": "Fill the transaction form…" }]
}

📙 Every request carries these fields: threadId marks which conversation it belongs to, runId identifies the run within that thread, protocolVersion is the protocol version, state holds the shared application state, and messages is the content of the conversation

AG-UI in Microsoft Agent Framework

📙 With MAF, you don't need to read the spec and write, handle, and test everything yourself. There's already a library for that: Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.

dotnet add package Microsoft.Agents.AI.Hosting.AGUI.AspNetCore --version 1.28.0-preview.261106.1

📙 After that, in our code, we just expose an AG-UI endpoint (MapAGUIServer)

// Program.cs
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Hosting.AGUI.AspNetCore;

builder.Services.AddAGUIServer();
var app = builder.Build();

AIAgent agent = chatClient.AsAIAgent(
    name: "assistant",
    instructions: "You are helpful.");

app.MapAGUIServer("/ag-ui", agent);
app.Run();

Note: The package doesn't handle authentication or authorization for you, so you have to write that yourself. In my case, I added per-ThreadId authorization checks in AgUiServiceCollectionExtensions.cs and AgUiEndpoints.cs.

Blazor AI components .NET 11 (experimental)

📙 With the server side done and an AG-UI endpoint in place, it's time to use the components this post is about. Here we build the client side that connects to the server. Start with:

dotnet add package Microsoft.AspNetCore.Components.AI --prerelease
  • Next, install AGUI.Client. It helps you understand which AG-UI events the server sends and how you should handle them.
dotnet add package AGUI.Client --version 1.0.1

📙 With everything installed, we can now try out a sample app.

// 1. Program.cs
builder.Services.AddScoped<IChatClient>(sp =>
    new AGUIChatClient(
        new AGUIChatClientOptions(
            http, "https://api.example.com/agent")));

// 2. Components/App.razor
<link rel="stylesheet"
  href="@Assets["_content/…/ai-chat.css"]" />

// 3. Chat.razor
<ChatPage Agent="agent"
          Placeholder="Type a message..." />

@code {
    UIAgent agent = default!;
    protected override void OnInitialized()
        => agent = new UIAgent(ChatClient);
}

If you're interested in the full version, check out my UI page: AguiChat-plain.razor. This one is a simple UI that uses the default styling.

Blazor AI components Pattern

Now that we know what AG-UI is and how to use it with MAF on the agent side, let's look at the UI patterns we can build with Blazor AI components and the AG-UI client.

-Build-in UI

📙 RichContentBlock displays the chat messages from our conversation. It comes with a MarkdownRichTextParser built in. In my existing project, I used Markdig to convert the agent's Markdown responses.

📙 FunctionApprovalBlock is used when a tool call needs a human action (approval) before it can proceed.

-Needs renderer เขียน Custom UI เอง
  • Blazor AI components: Frontend Tools1
  • Blazor AI components: Frontend Tools2 - Change Box Color
  • Blazor AI components: Server Tools
  • Blazor AI components: Shared State

📙 FunctionInvocationContentBlock displays the results of a server-side agent tool call. In my case, that's a Skill that has a script.
📙 UIActionBlock is used to trigger app functions, such as opening or closing a panel, or telling the app to filter data.
📙 ActivityContentBlock is for cases where you want to work with state, meaning the data on the screen. For example, adding an order.

Integration: Web (MudBlazor) + Blazor AI components + AG-UI

As I mentioned at the start, this post extends the demo from the web app that uses four types of MAF skills, which I presented at Build.AI. Here's a quick recap.

📙 MudBlazor is an open-source UI library focused on Material Design. It's C#-centric, so you deal with JavaScript less, and it ships with a default color palette / theme so you don't have to think much about design. For typical apps the defaults work fine, and they don't look like AI slop. It also has chat components, but that isn't the core team's focus. They live in an extension at https://mudx.org/.

📙 The four types of MAF skills

  • File-based skills: Prepare a SKILL.md following the Agent Skills structure, then configure AgentFileSkillsSourceOptions / AgentSkillsProvider to load it.
  • Class-based skills: Like file-based skills, but written as a C# class. Extend AgentClassSkill and override AgentSkillFrontmatter (the skill name + description), the instructions, AgentSkillResource, and AgentSkillScript.
  • Code-defined skills: Similar to class-based skills, but the skill is created at runtime, so you can adjust it dynamically. For example, you can change the skill's name, description, or instructions per user. For a room-lookup skill, you could inject personalized data such as the user's preferences and response style into the skill's content.
  • MCP-based skills: Skills are invoked directly from an MCP server, requested ad hoc in real time. There's also an archive mode, where the server shares skills and the agent downloads them to its own local storage.

From here on, it's the integration. We'll insert MudBlazor components into BlockRenderer<TBlock>, which is a placeholder that Blazor AI components provides so you can plug in your own UI for each defined event. The parts are:

📙 ToolChip (code: ToolChip.razor): a general block that displays information, such as which skill is being called right now and its status. The file doesn't have much code, so I've pasted it in the block below. You'll see it uses FunctionInvocationContentBlock.

@using FinanceApp.Web.Services.AgUi
@using Microsoft.AspNetCore.Components.AI

@* The log line for one tool call (load_skill, read_skill_resource, run_skill_script, ...): what it is, whether it is done,
   and the call's arguments. With ShowDebug on, also what the page received for it. *@
<MudChip T="string" Size="Size.Small" Color="@(Block.HasResult ? Color.Success : Color.Info)" Icon="@Icons.Material.Filled.Build">
    @ToolLabel.Of(Block.ToolName, Block.Arguments) · @(Block.HasResult ? "done" : "running")
</MudChip>
<MudText Typo="Typo.caption">@ToolLabel.Describe(Block.Arguments)</MudText>
@if (ShowDebug)
{
    <MudText Typo="Typo.caption" Style="display:block;opacity:.7">@DebugLine()</MudText>
}

@code {
    [Parameter, EditorRequired]
    public FunctionInvocationContentBlock Block { get; set; } = default!;

    [Parameter]
    public bool ShowDebug { get; set; }

    private string DebugLine()
    {
        var text = ToolResultText.Of(Block.Result);
        var shown = text is null ? "(null)" : text.Length > 160 ? text[..160] + "..." : text;
        var card = Block is SkillCardBlock skill ? (skill.Card is not null).ToString() : "-";
        return $"[debug] block={Block.GetType().Name} hasResult={Block.HasResult} card={card} "
            + $"argsType={Block.Arguments?.GetType().Name} resultType={Block.Result?.GetType().Name} text={shown.Replace("\n", "\\n")}";
    }
}
ToolChip + Approval
ToolChip + Approval

📙Approval card (Code ApprovalCard.razor) - แสดงหน้าจอ ให้ Human Approve ถ้าเจ้าไปดู Code ด้านใน มีใช้ FunctionApprovalBlock

If you're using a small local model such as Qwen3.5, you may need to add a custom BlockWatch.razor, along with an AG-UI event filter that says "this was already sent, don't send it again", and so on. I ran into a tool-call loop when I tried it for real.

📙 Skill results group: shows ProgressCard / LineChartCard so the results of a tool call are explained more clearly.

Skill Card (Bar / Line Chart)
Skill Card (Bar / Line Chart)

As I mentioned earlier about the skills, I added the ability to render charts. The difficulty is that the LLM returns plain text (Markdown), so the data has to be converted. If you look at the flow from

  • The user types a prompt in the chat UI, which sends an event to the AG-UI server. From here, it's the agent and the LLM's job to pick up a skill. Then it's SkillCardBlock.cs's turn, which contains:
    - SkillCardBlock : FunctionInvocationContentBlock, which intercepts the call.
    - SkillCardHandler(IReadOnlyList adapters) : ContentBlockHandler, which handles the result.
  • Next, SkillCardHandler waits for the result from the skill + script, which comes back as Markdown. It passes the result to SkillCardAdapters.cs, which calls the data converter (SavingsProjectionAdapter). That converter calls MonthsToTargetParser.cs to shape the data into the models in CardModels.cs. Finally, ToCard (in SavingsProjectionAdapter) hands the result to LineChartCard.razor, which turns it into a nice chart.

Honestly, the code isn't generic enough yet. It would need changes before it can convert arbitrary data into a chart-ready shape.

plug these components into the main chat page, it goes in MessageListContent > BlockRenderer.

📙 Frontend tools (UIActionBlock): for example, opening or closing a panel, or telling the app to filter data. I pulled an example from AguiChat-advance.razor.

  • Declare Tools
// Runs in the user's circuit
string SetFilter(string category)
{
  if (!_panelOpen)
    return "The panel is closed.";

  var match = _categories.FirstOrDefault(
    c => c.Name.Equals(category,
      StringComparison.OrdinalIgnoreCase));
  if (match is null)
    return $"No category '{category}'.";

  _filterCategory = match.Name;
  return $"filter set to {match.Name}";
}
  • Register Tools - UI Actions
// Create it: the description is
// what the model reads
var setFilter = AIFunctionFactory.Create(
  (string c) => SetFilter(c), "set_filter",
  "Show only one category in the " +
  "Transactions panel.");

// Register it in the UIAgent options
options.RegisterUIAction(setFilter);

📙 Shared state: syncing data between the user and the agent. The user types some text, the agent maps it into state, and that state is shown in a side panel in the UI. It also covers things like waiting for approval. The demo has two variations.

  • Simple: state shared between the UI and the chat, used when adding a transaction. For example, if you type "add 120 baht for lunch", the app opens the Transaction screen and fills in the data for you right away. The flow is complete once the user clicks Save or types a command to confirm, and the data in the state is then used from there.
// Declare Field , Trigger Share State PushState()
private decimal Amount { get => _amount; set { _amount = value; PushState(); } }

// UI Bind
<MudNumericField T="decimal" @bind-Value="Amount" Label="Amount" Min="0.01m" Format="F2" Dense="true" Disabled="_formLocked" />

// PushState
private void PushState()
    {
        if (_panelOpen && !_agent.State.HasPendingPredictiveState)
        {
            _agent.State.Value = new DraftState
            {
                Draft = new ClientDraft { Amount = _amount, Category = CategoryName(), Note = _description ?? "" },
                Receipt = _agent.State.Value.Receipt,  //For PredictiveState  Case 
            };
        }
    }
Demo Frontend Tools / Share State
  • PredictiveState: state can also support commit / rollback. In this example, the user uploads a receipt, and the ReceiptOCR skill interprets the data and shows it in a form (DraftState). It's only committed once the user confirms. If they cancel, that state is discarded. In a real-world use case, think of putting items in a shopping cart: you chat with the system first, and only when you confirm do the items go into the cart. On the code side, you need to add an event handler to intercept this
c.SetPredictiveState(new DraftState
{
    Draft = currentState.Draft,
    Receipt = new ReceiptSlice
    {
        SelectedId = currentState.Receipt.SelectedId,
        Proposal = proposal
    }
});
PredictiveState + Frontend Tool OCR
  • There's another variation using state delta, which updates data step by step. Think of a checklist, or a shipping flow. The code is more complex than the Simple and PredictiveState variations, because you have to decide when to update, and declare the following:
    - Model + logic (Start / SetChecklistStep / Delta, which tells the UI to update): ChecklistModels.cs
    - Server tools that initialize and update the checklist: ChatAgentProvider.cs. CreateChecklistAgent here creates the tools.
    - Lifecycle wiring in AguiChecklist.razor
_agent = new UIAgent<ChecklistState>(client, options =>
        {
            options.ChatOptions = new ChatOptions { ConversationId = thread };
            options.AddBlockHandler(new SkillCardHandler(_cardAdapters));
            options.StateMapper = c =>
            {
                switch (c.Update.RawRepresentation)
                {
                    case AGUI.Abstractions.StateSnapshotEvent snap when snap.Snapshot.Deserialize<ChecklistState>(StateJson) is { } state:
                        _snapshots++;
                        c.SetState(state);
                        break;
                    case AGUI.Abstractions.StateDeltaEvent delta:
                        // The package does not apply a delta by itself: this page does, and ignores anything it does not recognise.
                        _deltas++;
                        c.SetState(ChecklistDelta.Apply(_agent.State.Value, delta.Delta));
                        break;
                }
            };
        }, new ChecklistState());
State Delta

That's a wrap on trying out Blazor AI Components (experimental in .NET 11) + AG-UI together with MudBlazor. You can find the full code in the repo https://github.com/pingkunga/dotnet_conf26_FinAgentAppWithSkill (branch feature/blazerAG-UI). A few ideas from here:

  • Combined with the earlier class-based and code-defined skills, you could build a custom NuGet package that defines default UI rendering for them.
  • Or build a shared UI library for rendering agent output. Honestly, I think it's similar to LINE LIFF / Mini Apps.
  • AG-UI also works with UI frameworks from other vendors. For example, copilotkit.ai/ag-ui has JS options for all three major frameworks: Vue, Angular, and React.

Blazor AI components also have a section on Persist and restore conversations that I haven't covered here. I tried it out myself with help from two AI models, MAI-CODE and Claude.

Resource: Slide / Source Code / Feedback

Reference

  1. Microsoft Agent Framework
  2. AG-UI Integration with Agent Framework / Getting Started with AG-UI
  3. ASP.NET Core Blazor AI components for agentic user interfaces
  4. Build Agentic UI with the new Blazor AI components / https://github.com/danroth27/AgenticUI