-
Notifications
You must be signed in to change notification settings - Fork 316
.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; } = []; |
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) | ||
{ | ||
|
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. |
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.