![]() |
|
[DevBlog MS] AG-UI Protocol now has a first-class .NET SDK - Printable Version +- Sick Gaming (https://sickgaming.net) +-- Forum: Programming (https://sickgaming.net/forum-76.html) +--- Forum: C#, Visual Basic, & .Net Frameworks (https://sickgaming.net/forum-79.html) +--- Thread: [DevBlog MS] AG-UI Protocol now has a first-class .NET SDK (/thread-113316.html) |
[DevBlog MS] AG-UI Protocol now has a first-class .NET SDK - xSicKxBot - 09-25-2026 The .NET team is pleased to announce that we’ve contributed a .NET SDK for AG-UI in collaboration with CopilotKit. The AG-UI .NET SDK lives in the AG-UI repository alongside the TypeScript and Python SDKs, published on NuGet under the MIT license. Any .NET service can now speak AG-UI directly. The Microsoft Agent Framework (MAF) AG-UI support for .NET is now based on the AG-UI .NET SDK. What is AG-UI? Agents break the traditional request-and-response paradigm. They are long-running, stream tokens as they work, delegate to subagents, and invoke tools mid-response. Without a shared protocol, each agent framework or service can expose a different streaming format, leaving application developers to parse chunks, track state, and map framework-specific events to UI. This creates boilerplate that you must maintain, and it can break whenever the event format shifts. AG-UI (Agent-User Interaction Protocol) standardizes how agents communicate with user-facing applications. ![]() It streams the agent lifecycle as typed events, grouped into several categories. The frontend listens for Code: RUN_STARTEDCode: TEXT_MESSAGE_CONTENTCode: STATE_DELTAThe .NET SDK brings that capability to C#. A backend emits those events natively, and a client consumes them from an agent written in any supported language. Quickstart The SDK works in both directions. Code: AGUI.ServerCode: AGUI.ClientCode: [code]dotnet add package AGUI.Server[/code]Your agent is an Code: IChatClientCode: Microsoft.Extensions.AICode: CreateChatClient()Code: IChatClientCode: [code]using AGUI.Abstractions;
using AGUI.Server;
using Microsoft.AspNetCore.Http.Json;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Options;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton(CreateChatClient());
builder.Services.Configure<JsonOptions>(options =>
options.SerializerOptions.TypeInfoResolverChain.Insert(
0,
AGUIJsonUtilities.DefaultTypeInfoResolver));
var app = builder.Build();
app.MapPost("/", (
RunAgentInput input,
IChatClient chatClient,
IOptions<JsonOptions> jsonOptions,
CancellationToken cancellationToken) =>
{
var context = input.ToChatRequestContext(
jsonOptions.Value.SerializerOptions);
var events = chatClient
.GetStreamingResponseAsync(
context.Messages,
context.ChatOptions,
cancellationToken)
.AsAGUIEventStreamAsync(context, cancellationToken);
return TypedResults.ServerSentEvents(events);
});
await app.RunAsync();[/code]Code: ToChatRequestContextCode: RunAgentInputCode: IChatClientCode: AsAGUIEventStreamAsyncCode: RUN_STARTEDCode: RUN_FINISHEDCode: RUN_FINISHEDThe SDK handles the protocol. The web server is yours, which is why Agent Framework’s ASP.NET Core package wraps these same primitives as Code: AddAGUIServer()Code: MapAGUIServer()In Agent Framework, the same endpoint takes only a few lines. Given an existing Code: IChatClientCode: chatClientCode: [code]dotnet add package Microsoft.Agents.AI.Hosting.AGUI.AspNetCore --prerelease[/code]Code: [code]using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Hosting.AGUI.AspNetCore;
using Microsoft.Extensions.AI;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAGUIServer();
var app = builder.Build();
AIAgent agent = chatClient.AsAIAgent(
name: "AGUIAssistant",
instructions: "You are a helpful assistant.");
app.MapAGUIServer("/", agent);
await app.RunAsync();[/code]Code: AGUI.ClientCode: [code]dotnet add package AGUI.Client[/code]Code: [code]using AGUI.Client;
using var httpClient = new HttpClient();
var chatClient = new AGUIChatClient(
new(httpClient, "http://localhost:5001"));[/code]Code: AGUIChatClientCode: IChatClientCode: IChatClientOnce your endpoint speaks AG-UI, any AG-UI client can drive it: a .NET application through Code: AGUI.ClientThe repository has worked examples for each part of the protocol. There is one client and server pair per step, covering chat, backend and frontend tools, human in the loop, shared state, reasoning, multimodal input, interrupts, parallel tool calls, protobuf, and telemetry. Architecture Here is how everything works together. A request arrives from any AG-UI client, the endpoint hands it to your agent in Microsoft Agent Framework or your own agent code, and the response streams back as protocol events while the agent calls your tools and the model. ![]() The packages The SDK ships as five packages on NuGet: protocol types, wire formatters, protobuf support, an HTTP client, and a framework-agnostic server adapter built on Code: Microsoft.Extensions.AIPackage What it is Code: AGUI.AbstractionsProtocol model: events, messages, tools, capabilities, interrupts, state, and the source-generated serializer Code: AGUI.FormattingWire format abstraction and the default Server-Sent Events implementation Code: AGUI.ProtobufOpt-in protobuf codec generated from the TypeScript Code: .protoCode: AGUI.ClientConsumes AG-UI Code: AGUI.ServerProduces AG-UI The client and server packages pull in the abstractions they need, so most applications reference one of them. What this means for Microsoft Agent Framework Agent Framework, our SDK for building AI agents in .NET and Python, used to include its own implementation of the AG-UI protocol. It now depends on the Code: AGUI.*The protocol is maintained in the AG-UI C# SDK and stays wire-compatible with the TypeScript and Python SDKs. See the migration notice for full details. For existing Agent Framework users, the programming model is unchanged, though a few APIs were renamed: Before Now Code: AddAGUI()Code: MapAGUI()Code: AddAGUIServer()Code: MapAGUIServer()Code: Microsoft.Agents.AI.AGUICode: AGUI.ClientCode: AGUI.ServerCode: AGUI.AbstractionsCode: AGUIChatClientOptions-based constructor Reading the originating request Code: chatOptions.TryGetRunAgentInput(out RunAgentInput? agentInput)The event format is unchanged, so existing frontends keep working against an upgraded backend without changes of their own. Why this matters Any .NET backend can speak the protocol. A worker service, internal API, or existing line-of-business application can expose an agent over AG-UI on its own. No agent framework is required. One backend can serve many surfaces. The client decides how to render the events, so the same endpoint serves a web app, terminal, mobile client, or chat platform like Slack and Teams. Your existing code remains the same. Code: IChatClientInteroperate across languages. The shared wire protocol keeps the C#, TypeScript, and Python SDKs compatible, so a .NET backend can work with clients built using any of them. Get started The AG-UI .NET SDK provides one C# implementation of AG-UI, published on NuGet and usable from any .NET service. Agent Framework consumes it, and so can you.
Questions and feedback about the SDK are welcome in the AG-UI repository. For MAF integration questions, use the Microsoft Agent Framework discussion boards. The post AG-UI Protocol now has a first-class .NET SDK appeared first on .NET Blog. |