Skip to content

Commit 318f6ca

Browse files
westey-mhowlowck
authored andcommitted
.NET: [BREAKING] Change GetNewThread and DeserializeThread to async (microsoft#3152)
* Change GetNewThread and DeserializeThread plus ChatMessageStore and AIContextProvider Factories to async * Merge fixes
1 parent 18a0f10 commit 318f6ca

File tree

113 files changed

+538
-477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+538
-477
lines changed

dotnet/samples/A2AClientServer/A2AClient/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private static async Task HandleCommandsAsync(CancellationToken cancellationToke
4242
// Create the Host agent
4343
var hostAgent = new HostClientAgent(loggerFactory);
4444
await hostAgent.InitializeAgentAsync(modelId, apiKey, agentUrls!.Split(";"));
45-
AgentThread thread = hostAgent.Agent!.GetNewThread();
45+
AgentThread thread = await hostAgent.Agent!.GetNewThreadAsync(cancellationToken);
4646
try
4747
{
4848
while (true)

dotnet/samples/AGUIClientServer/AGUIClient/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private static async Task HandleCommandsAsync(CancellationToken cancellationToke
8888
description: "AG-UI Client Agent",
8989
tools: [changeBackground, readClientClimateSensors]);
9090

91-
AgentThread thread = agent.GetNewThread();
91+
AgentThread thread = await agent.GetNewThreadAsync(cancellationToken);
9292
List<ChatMessage> messages = [new(ChatRole.System, "You are a helpful assistant.")];
9393
try
9494
{

dotnet/samples/AzureFunctions/02_AgentOrchestration_Chaining/FunctionTriggers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public sealed record TextResponse(string Text);
1919
public static async Task<string> RunOrchestrationAsync([OrchestrationTrigger] TaskOrchestrationContext context)
2020
{
2121
DurableAIAgent writer = context.GetAgent("WriterAgent");
22-
AgentThread writerThread = writer.GetNewThread();
22+
AgentThread writerThread = await writer.GetNewThreadAsync();
2323

2424
AgentRunResponse<TextResponse> initial = await writer.RunAsync<TextResponse>(
2525
message: "Write a concise inspirational sentence about learning.",

dotnet/samples/AzureFunctions/04_AgentOrchestration_Conditionals/FunctionTriggers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static async Task<string> RunOrchestrationAsync([OrchestrationTrigger] Ta
2121

2222
// Get the spam detection agent
2323
DurableAIAgent spamDetectionAgent = context.GetAgent("SpamDetectionAgent");
24-
AgentThread spamThread = spamDetectionAgent.GetNewThread();
24+
AgentThread spamThread = await spamDetectionAgent.GetNewThreadAsync();
2525

2626
// Step 1: Check if the email is spam
2727
AgentRunResponse<DetectionResult> spamDetectionResponse = await spamDetectionAgent.RunAsync<DetectionResult>(
@@ -43,7 +43,7 @@ public static async Task<string> RunOrchestrationAsync([OrchestrationTrigger] Ta
4343

4444
// Generate and send response for legitimate email
4545
DurableAIAgent emailAssistantAgent = context.GetAgent("EmailAssistantAgent");
46-
AgentThread emailThread = emailAssistantAgent.GetNewThread();
46+
AgentThread emailThread = await emailAssistantAgent.GetNewThreadAsync();
4747

4848
AgentRunResponse<EmailResponse> emailAssistantResponse = await emailAssistantAgent.RunAsync<EmailResponse>(
4949
message:

dotnet/samples/AzureFunctions/05_AgentOrchestration_HITL/FunctionTriggers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static async Task<object> RunOrchestrationAsync(
2424

2525
// Get the writer agent
2626
DurableAIAgent writerAgent = context.GetAgent("WriterAgent");
27-
AgentThread writerThread = writerAgent.GetNewThread();
27+
AgentThread writerThread = await writerAgent.GetNewThreadAsync();
2828

2929
// Set initial status
3030
context.SetCustomStatus($"Starting content generation for topic: {input.Topic}");

dotnet/samples/AzureFunctions/06_LongRunningTools/FunctionTriggers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static async Task<object> RunOrchestrationAsync(
2020

2121
// Get the writer agent
2222
DurableAIAgent writerAgent = context.GetAgent("Writer");
23-
AgentThread writerThread = writerAgent.GetNewThread();
23+
AgentThread writerThread = await writerAgent.GetNewThreadAsync();
2424

2525
// Set initial status
2626
context.SetCustomStatus($"Starting content generation for topic: {input.Topic}");

dotnet/samples/AzureFunctions/08_ReliableStreaming/FunctionTriggers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public async Task<IActionResult> CreateAsync(
9595
AIAgent agentProxy = durableClient.AsDurableAgentProxy(context, "TravelPlanner");
9696

9797
// Create a new agent thread
98-
AgentThread thread = agentProxy.GetNewThread();
98+
AgentThread thread = await agentProxy.GetNewThreadAsync(cancellationToken);
9999
string agentSessionId = thread.GetService<AgentSessionId>().ToString();
100100

101101
this._logger.LogInformation("Creating new agent session: {AgentSessionId}", agentSessionId);

dotnet/samples/GettingStarted/A2A/A2AAgent_PollingForTaskCompletion/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// Create an instance of the AIAgent for an existing A2A agent specified by the agent card.
1717
AIAgent agent = agentCard.GetAIAgent();
1818

19-
AgentThread thread = agent.GetNewThread();
19+
AgentThread thread = await agent.GetNewThreadAsync();
2020

2121
// Start the initial run with a long-running task.
2222
AgentRunResponse response = await agent.RunAsync("Conduct a comprehensive analysis of quantum computing applications in cryptography, including recent breakthroughs, implementation challenges, and future roadmap. Please include diagrams and visual representations to illustrate complex concepts.", thread);

dotnet/samples/GettingStarted/AGUI/Step01_GettingStarted/Client/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
name: "agui-client",
2121
description: "AG-UI Client Agent");
2222

23-
AgentThread thread = agent.GetNewThread();
23+
AgentThread thread = await agent.GetNewThreadAsync();
2424
List<ChatMessage> messages =
2525
[
2626
new(ChatRole.System, "You are a helpful assistant.")

dotnet/samples/GettingStarted/AGUI/Step02_BackendTools/Client/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
name: "agui-client",
2121
description: "AG-UI Client Agent");
2222

23-
AgentThread thread = agent.GetNewThread();
23+
AgentThread thread = await agent.GetNewThreadAsync();
2424
List<ChatMessage> messages =
2525
[
2626
new(ChatRole.System, "You are a helpful assistant.")

0 commit comments

Comments
 (0)