-
Notifications
You must be signed in to change notification settings - Fork 586
.Net: ChatClientAgent (Non-Streaming initial impl) #65
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
.Net: ChatClientAgent (Non-Streaming initial impl) #65
Conversation
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 pull request introduces non‐streaming implementation enhancements for a ChatClientAgent along with several new supporting classes and unit tests to validate the new functionality. Key changes include extending the Agent API to accept a CancellationToken, adding new implementations such as ChatClientAgent, ChatClientAgentThread, and associated metadata and run options classes, and updating unit tests to cover invocation, thread message retrieval, and logging.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.UnitTests/UnitTest1.cs | Removed a placeholder test file. |
| dotnet/tests/Microsoft.Agents.UnitTests/ChatCompletion/ChatClientAgentThreadTests.cs | Added tests to verify ChatClientAgentThread implements IMessagesRetrievableThread and its message-retrieval functionality. |
| dotnet/tests/Microsoft.Agents.UnitTests/ChatCompletion/ChatClientAgentTests.cs | Added unit tests to validate ChatClientAgent definition, invocation, and streaming (skipped) functionality. |
| dotnet/tests/Microsoft.Agents.Abstractions.UnitTests/AgentTests.cs | Updated MockAgent to reflect the new CreateThreadAsync signature with CancellationToken. |
| dotnet/src/Microsoft.Agents/Microsoft.Agents.csproj | Updated project properties to enable InjectSharedThrow. |
| dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentThread.cs | Implemented ChatClientAgentThread with async message retrieval and thread management. |
| dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentRunOptions.cs | Introduced a run options class to include ChatOptions. |
| dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentMetadata.cs | Added a metadata class to encapsulate agent-specific details. |
| dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentLogMessages.cs | Added logging extensions for ChatClientAgent leveraging LoggerMessageAttribute. |
| dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgent.cs | Implemented ChatClientAgent with metadata, logging, and integration with a chat client. |
| dotnet/src/Microsoft.Agents/AgentExtensions.cs | Provided extension methods to ensure a non-null agent name for telemetry purposes. |
| dotnet/src/Microsoft.Agents.Abstractions/Agent.cs | Updated CreateThreadAsync signature to accept an optional CancellationToken. |
Comments suppressed due to low confidence (2)
dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentLogMessages.cs:23
- Consider assigning unique EventIds for each LoggerMessage method to simplify log filtering and troubleshooting, even though disabling warnings is suppressing conflicts.
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "[{MethodName}] Agent {AgentId}/{AgentName} Invoking service {ServiceType}.")]
dotnet/tests/Microsoft.Agents.UnitTests/ChatCompletion/ChatClientAgentTests.cs:102
- [nitpick] The assertion 'Assert.Single(result.Messages);' appears to be duplicated within the test. Removing redundant assertions can improve test clarity.
Assert.Single(result.Messages);
Motivation
This pull request introduces a series of changes to enhance the functionality of the
Agentabstraction and its implementations, particularly focusing on theChatClientAgent. Key updates include extending theAgentAPI, implementing theChatClientAgentclass with metadata and logging capabilities, and adding unit tests to validate the new functionality.Enhancements to
AgentAPI:dotnet/src/Microsoft.Agents.Abstractions/Agent.cs: Updated theCreateThreadAsyncmethod to accept an optionalCancellationTokenparameter for better cancellation support.Implementation of
ChatClientAgent:dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgent.cs: Added theChatClientAgentclass to implement theAgentabstraction. This class provides methods for running chat sessions, handling agent instructions, and integrating with a chat client.dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentMetadata.cs: Introduced theChatClientAgentMetadataclass to encapsulate agent-specific metadata such as ID, name, description, and instructions.dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentThread.cs: Added theChatClientAgentThreadclass to manage chat messages and support message retrieval for threads.dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentRunOptions.cs: Created theChatClientAgentRunOptionsclass to provide additional options for agent invocation, includingChatOptions.Logging Enhancements:
dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgentLogMessages.cs: Added logging extensions forChatClientAgentusingLoggerMessageAttributeto optimize logging code and track agent invocations.Unit Tests:
dotnet/tests/Microsoft.Agents.UnitTests/ChatCompletion/ChatClientAgentTests.cs: Implemented unit tests forChatClientAgentto verify its metadata, invocation, and response handling. Includes tests for synchronous and streaming operations.Additional Updates:
dotnet/src/Microsoft.Agents/AgentExtensions.cs: Added extension methods forAgentto retrieve names and display names, ensuring non-null values for telemetry purposes.dotnet/src/Microsoft.Agents/Microsoft.Agents.csproj: Updated project properties to enableInjectSharedThrow.dotnet/src/Microsoft.Agents/AgentImplementation.cs: Removed the placeholderAgentImplementationclass as it is no longer needed.dotnet/tests/Microsoft.Agents.Abstractions.UnitTests/AgentTests.cs: Updated theMockAgentimplementation to reflect changes in theCreateThreadAsyncmethod signature.