-
Notifications
You must be signed in to change notification settings - Fork 1k
.NET: Change GetNewThread and DeserializeThread to async #3152
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?
Conversation
…IContextProvider Factories to async
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 converts GetNewThread and DeserializeThread methods from synchronous to asynchronous (GetNewThreadAsync and DeserializeThreadAsync) to enable async calls in ChatMessageStore and AIContextProvider factories.
Key Changes:
- Updated abstract methods in
AIAgentbase class to returnValueTask<AgentThread> - Changed factory signatures in
ChatClientAgentOptionsto acceptCancellationTokenand returnValueTask - Converted
ChatClientAgentThreadconstructor-based deserialization to a staticDeserializeAsyncfactory method - Updated all agent implementations and test code to use the new async methods
Reviewed changes
Copilot reviewed 113 out of 113 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.cs | Changed abstract methods from sync to async with ValueTask return types |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Updated GetNewThread and DeserializeThread to async, proper factory invocation |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentOptions.cs | Changed factory signatures to async with CancellationToken parameter |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentThread.cs | Moved deserialization from constructor to static DeserializeAsync method |
| dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.cs | Updated to use ValueTask.FromResult for sync operations |
| dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs | Updated all thread methods to async |
| dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs | Updated thread creation to async |
| dotnet/src/Microsoft.Agents.AI.Purview/PurviewAgent.cs | Delegating agent updated for async methods |
| dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs | Workflow thread creation updated to async |
| dotnet/src/Microsoft.Agents.AI.Hosting/Local/InMemoryAgentThreadStore.cs | Thread store updated for async operations |
| dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosDBChatExtensions.cs | Factory lambdas updated for async signatures |
| dotnet/tests/* | All test files updated to await async method calls |
| dotnet/samples/* | All sample code updated to use GetNewThreadAsync |
Motivation and Context
In some cases users need to make async calls in ChatMessageStore and AIContextProvider factories, so we need to change the factory signatures to be async, which means changing GetNewThread and DeserializeThread to async as well.
#2520
Description
Contribution Checklist