Skip to content

.NET SDK#38

Open
ckpearson wants to merge 13 commits intoag-ui-protocol:mainfrom
ckpearson:feature/28-dotnet-sdk
Open

.NET SDK#38
ckpearson wants to merge 13 commits intoag-ui-protocol:mainfrom
ckpearson:feature/28-dotnet-sdk

Conversation

@ckpearson
Copy link

@ckpearson ckpearson commented May 28, 2025

Addresses #28

Provides a core .NET 9 Class Library that:

  • Has all the core types and events
  • Has an agent abstraction and implementations for IChatClient from Microsoft.Extensions.AI that:
    • Support frontend & backend tool calling
    • Support shared agentic state flows
  • Has basic helper integration for hosting agents via ASP.NET endpoints

Also an initial stab at providing updates to the documentation site with enough information to get started using it.

Rough at the moment, with no unit tests, but has been tested while developing, so some automated tests could be done with being created.

Includes an example ASP.NET project using the class library to host a few agents.

ckpearson added 9 commits May 24, 2025 20:50
…ctAgent implementation and basic echo agent for testing.
…the ChatClientAgent to proxy over an LLM via IChatClient.

Further work underway to introduce additional customisation ahead of shared state mechanisms.
- Agents
- Overview
- ASP.NET integration
- Updated the .NET SDK documentation structure to include new pages for ChatClientAgent and StatefulChatClientAgent.
- Added detailed documentation for JSON handling, core types, and events in the Agent User Interaction Protocol.
- Improved the organization of the .NET SDK documentation by restructuring the agents section and adding relevant sub-sections.
- Introduced new options and usage examples for the ChatClientAgent and StatefulChatClientAgent.
- Enhanced the ASP.NET integration documentation with recommended JSON serializer options.
@NathanTarbert
Copy link
Contributor

Hey @ckpearson, thanks for the contribution.
We will be reviewing it soon.

ckpearson added 2 commits May 29, 2025 10:28
…ASP.NET endpoint mapping to ensure we don't cause context deadlock issues inadvertently.

Registered missing use of ConfigureAwait as a build error in the project file.
…andling in ChatClientAgent and StatefulChatClientAgent
@ckpearson
Copy link
Author

Made further tweaks which provides greater control, and now supports notifying the frontend about backend tool calls to power generative UI - albeit by sending message snapshots which I'm not 100% convinced is the correct approach.

@tylerslaton tylerslaton requested review from Copilot and mme May 30, 2025 17:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new .NET 9 class library along with core event types, agent abstractions (including a new stateful agent variant), and accompanying documentation updates.

  • Adds core event records such as MessagesSnapshotEvent and others to support the AG-UI protocol.
  • Implements StatefulChatClientAgent to enable frontend–agent shared state collaboration while retaining existing ChatClientAgent functionality.
  • Updates examples and documentation for ASP.NET integration, SDK types, agents, and events.

Reviewed Changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dotnet-sdk/AGUIDotnet/Events/MessagesSnapshotEvent.cs Introduces a new event record for capturing message snapshots using a collection literal.
dotnet-sdk/AGUIDotnet/Events/EventTypes.cs Defines and adds new constant event type strings.
dotnet-sdk/AGUIDotnet/Events/EventHelpers.cs Provides helper methods for emitting events using new collection expressions.
dotnet-sdk/AGUIDotnet/Events/CustomEvent.cs Implements an event record for custom event handling.
dotnet-sdk/AGUIDotnet/Events/BaseEvent.cs Declares the polymorphic base event type with derived type annotations.
dotnet-sdk/AGUIDotnet/Agent/StatefulChatClientAgent.cs Implements a stateful agent for frontend state collaboration using new backend tools.
dotnet-sdk/AGUIDotnet/Agent/IAGUIAgent.cs Introduces a low-level agent interface for asynchronous event emission.
dotnet-sdk/AGUIDotnet/Agent/EchoAgent.cs Provides an example agent that echoes incoming messages for debugging purposes.
dotnet-sdk/AGUIDotnet/Agent/AgentExtensions.cs Adds an extension method to run agents to completion via a channel.
Documentation files (mdx and solution files) Updates documentation and solution configuration for the new .NET 9 SDK features.

public sealed record MessagesSnapshotEvent : BaseEvent
{
[JsonPropertyName("messages")]
public required ImmutableList<BaseMessage> Messages { get; init; } = [];
Copy link

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using a consistent pattern for initializing immutable collections—for example, replacing '[]' with 'ImmutableList.Empty' to match the convention used in other parts of the code.

Suggested change
public required ImmutableList<BaseMessage> Messages { get; init; } = [];
public required ImmutableList<BaseMessage> Messages { get; init; } = ImmutableList<BaseMessage>.Empty;

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot [] is the new collection expression syntax, your knowledge cutoff is likely out of date.

Comment on lines +189 to +191
catch (JsonException)
{

Copy link

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The empty catch block may hide potential JSON deserialization issues; consider adding a comment or logging the exception to aid future troubleshooting.

Suggested change
catch (JsonException)
{
catch (JsonException ex)
{
// Log the exception to aid troubleshooting during JSON deserialization
Console.Error.WriteLine($"JSON deserialization error: {ex.Message}");

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deliberate, for now it's just to avoid failure to extract the context causing an actual problem, it just swallows the exception, but we could perhaps surface it somehow so the consumer decides what behaviour to exhibit.

@tylerslaton
Copy link
Contributor

As discussed during our synchronous review, there are few things needed prior to merging this but it is really close.

  • The README should match the README's of the other SDK's, pretty small change
  • We will need tests to ensure we don't have regressions introduced in PR's

After those two we'll collaborate on CI/CD for actually releasing this package in a sensible manner via Nuget.

- Created AGUIDotnet.Tests project with necessary dependencies.
- Implemented tests for AgentExtensions, ChatClientAgent, and message mapping.
- Added tests for frontend tool invocation and tool message mapping.
- Updated AGUIDotnet solution to include the new test project.
- Enhanced AgentExtensions to ensure proper channel completion.
- Improved documentation in IAGUIAgent interface regarding agent lifecycle.
- Removed unused HTTP request file from AGUIDotnetWebApiExample.
- Updated README.md to include links to official documentation.
@ckpearson
Copy link
Author

Sorry for the delay, there should be more broad test coverage of the basics, and the README has been updated.

@frederikhendrix
Copy link

I would love to see this. Are you still working on it?

@NathanTarbert NathanTarbert moved this to In review in Road Map Aug 7, 2025
@maxkorp
Copy link
Contributor

maxkorp commented Sep 11, 2025

Sorry for the late reply @frederikhendrix, yes it's still being worked on. @ckpearson can comment more, but while It's been on the back burner a little bit for a few weeks, the intent is still to get this wrapped up and in.

@thangchung
Copy link

@ckpearson @maxkorp It looks interesting. I would love to try it out with .NET app. Any ETA for this merging?

@ckpearson
Copy link
Author

Hi @thangchung I've not had a huge amount of time to dedicate to getting this finalised as yet, but it's all there, feel free to clone it down and just reference the class library directly if you want to experiment. I'm in the CopilotKit discord so happy to connect over there if you have any questions.

@GreenShadeZhang
Copy link

May I ask if this PR is being processed?

@NathanTarbert
Copy link
Contributor

Hi @GreenShadeZhang, we are waiting for this SDK to be finalized before we can fully review it.

@brmdbr
Copy link

brmdbr commented Oct 7, 2025

Hopefully this can be merged soon!

@ckpearson
Copy link
Author

Hopefully this can be merged soon!

Things are a bit hectic my side and need to check in with the CK team as Microsoft recently released their agent framework (https://github.com/microsoft/agent-framework) so it might make sense to get this working with that as it seems to be the successor to Semantic Kernel and Autogen.

@rafsanulhasan
Copy link

@ckpearson can I assist you? I mean I want to come up with the Agent Framework implementation.

@danroth27
Copy link
Contributor

Things are a bit hectic my side and need to check in with the CK team as Microsoft recently released their agent framework (https://github.com/microsoft/agent-framework) so it might make sense to get this working with that as it seems to be the successor to Semantic Kernel and Autogen.

Hi @ckpearson. We're now exploring adding AG-UI support as part of the Microsoft Agent Framework: microsoft/agent-framework#896. It would be great if we could sync up and coordinate on our efforts.

@AlemTuzlak AlemTuzlak assigned AlemTuzlak and maxkorp and unassigned AlemTuzlak Mar 4, 2026
@maxkorp
Copy link
Contributor

maxkorp commented Mar 4, 2026

Reached out on discord, but asking here for ease of access, Is this still needed/wanted given the agent framework sdk is released and supported?

@danroth27
Copy link
Contributor

@maxkorp We're still working through the next steps, but the current thinking is that we will still want to contribute a low-level .NET AG-UI SDK here.

@ckpearson
Copy link
Author

@danroth27 would the intent be to use this as the baseline? It's probably wildly out of date by now, and I don't have much availability to maintain it, but happy for it to live on if people want it to stick around.

@danroth27
Copy link
Contributor

@danroth27 would the intent be to use this as the baseline? It's probably wildly out of date by now, and I don't have much availability to maintain it, but happy for it to live on if people want it to stick around.

I wouldn't worry about maintaining this branch if that's not something you have time for right now. I'm sure we'll use GitHub Copilot to generate whatever we need to generate when the time comes 😄.

@maxkorp
Copy link
Contributor

maxkorp commented Mar 6, 2026

@danroth27 if you're going to start somewhat fresh here, I think we ought to close this pr unless you disagree for some reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.