-
Notifications
You must be signed in to change notification settings - Fork 829
.NET SDK #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
.NET SDK #38
Conversation
…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.
… into the context inclusion mechanism.
…entEndpoint extension method
- 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.
Hey @ckpearson, thanks for the contribution. |
…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
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. |
There was a problem hiding this 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; } = []; |
Copilot
AI
May 30, 2025
There was a problem hiding this comment.
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.
public required ImmutableList<BaseMessage> Messages { get; init; } = []; | |
public required ImmutableList<BaseMessage> Messages { get; init; } = ImmutableList<BaseMessage>.Empty; |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
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.
catch (JsonException) | ||
{ | ||
|
Copilot
AI
May 30, 2025
There was a problem hiding this comment.
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.
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.
There was a problem hiding this comment.
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.
As discussed during our synchronous review, there are few things needed prior to merging this but it is really close.
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.
Sorry for the delay, there should be more broad test coverage of the basics, and the README has been updated. |
I would love to see this. Are you still working on it? |
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. |
@ckpearson @maxkorp It looks interesting. I would love to try it out with .NET app. Any ETA for this merging? |
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. |
May I ask if this PR is being processed? |
Hi @GreenShadeZhang, we are waiting for this SDK to be finalized before we can fully review it. |
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. |
@ckpearson can I assist you? I mean I want to come up with the Agent Framework implementation. |
Addresses #28
Provides a core .NET 9 Class Library that:
IChatClient
fromMicrosoft.Extensions.AI
that: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.