Skip to content

Conversation

@westey-m
Copy link
Contributor

@westey-m westey-m commented Jan 9, 2026

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

  • Change GetNewThread and DeserializeThread to async

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings January 9, 2026 12:32
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET workflows Related to Workflows in agent-framework labels Jan 9, 2026
@github-actions github-actions bot changed the title Change GetNewThread and DeserializeThread to async .NET: Change GetNewThread and DeserializeThread to async Jan 9, 2026
Copy link
Contributor

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 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 AIAgent base class to return ValueTask<AgentThread>
  • Changed factory signatures in ChatClientAgentOptions to accept CancellationToken and return ValueTask
  • Converted ChatClientAgentThread constructor-based deserialization to a static DeserializeAsync factory 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

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

Labels

documentation Improvements or additions to documentation .NET workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants