From 0ad6da1378ab9abc6cb6b9a02f3eb734f9e8a7d9 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 21 Nov 2025 18:20:48 -0500 Subject: [PATCH] Update to latest MEAI 10.0.1 and OpenAI 2.7.0 --- dotnet/Directory.Packages.props | 12 +++++----- .../AgentRunResponseExtensions.cs | 4 ++-- .../ChatClient/ChatClientAgent.cs | 2 +- .../AgentRunResponseUpdateTests.cs | 2 +- .../ChatClient/ChatClientAgentTests.cs | 24 +++++++++---------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props index 8ef93b3072..a49f0fc277 100644 --- a/dotnet/Directory.Packages.props +++ b/dotnet/Directory.Packages.props @@ -18,7 +18,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -51,10 +51,10 @@ - - + + - + @@ -95,7 +95,7 @@ - + diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponseExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponseExtensions.cs index cb3ad7ec74..4ff07cac56 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponseExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponseExtensions.cs @@ -42,7 +42,7 @@ response.RawRepresentation as ChatResponse ?? RawRepresentation = response, ResponseId = response.ResponseId, Usage = response.Usage, - ContinuationToken = response.ContinuationToken, + ContinuationToken = response.ContinuationToken as ResponseContinuationToken, }; } @@ -75,7 +75,7 @@ responseUpdate.RawRepresentation as ChatResponseUpdate ?? RawRepresentation = responseUpdate, ResponseId = responseUpdate.ResponseId, Role = responseUpdate.Role, - ContinuationToken = responseUpdate.ContinuationToken, + ContinuationToken = responseUpdate.ContinuationToken as ResponseContinuationToken, }; } diff --git a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs index d04d9bb9fb..bbe1b28352 100644 --- a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs @@ -551,7 +551,7 @@ await thread.AIContextProvider.InvokedAsync(new(inputMessages, aiContextProvider { chatOptions ??= new ChatOptions(); chatOptions.AllowBackgroundResponses = agentRunOptions.AllowBackgroundResponses; - chatOptions.ContinuationToken = agentRunOptions.ContinuationToken; + chatOptions.ContinuationToken = agentRunOptions.ContinuationToken as ResponseContinuationToken; } return chatOptions; diff --git a/dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AgentRunResponseUpdateTests.cs b/dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AgentRunResponseUpdateTests.cs index 42d3fdf199..32b7acd673 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AgentRunResponseUpdateTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AgentRunResponseUpdateTests.cs @@ -42,7 +42,7 @@ public void ConstructorWithChatResponseUpdateRoundtrips() RawRepresentation = new object(), ResponseId = "responseId", Role = ChatRole.Assistant, - ContinuationToken = new object(), + ContinuationToken = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }), }; AgentRunResponseUpdate response = new(chatResponseUpdate); diff --git a/dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs b/dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs index 862b9ef3b4..e9d458aba4 100644 --- a/dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs @@ -2113,7 +2113,7 @@ public void GetNewThreadUsesAIContextProviderFactoryIfProvided() public async Task RunAsyncPropagatesBackgroundResponsesPropertiesToChatClientAsync(bool providePropsViaChatOptions) { // Arrange - object continuationToken = new(); + var continuationToken = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }); ChatOptions? capturedChatOptions = null; Mock mockChatClient = new(); mockChatClient @@ -2162,8 +2162,8 @@ public async Task RunAsyncPropagatesBackgroundResponsesPropertiesToChatClientAsy public async Task RunAsyncPrioritizesBackgroundResponsesPropertiesFromAgentRunOptionsOverOnesFromChatOptionsAsync() { // Arrange - object continuationToken1 = new(); - object continuationToken2 = new(); + var continuationToken1 = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }); + var continuationToken2 = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }); ChatOptions? capturedChatOptions = null; Mock mockChatClient = new(); mockChatClient @@ -2209,7 +2209,7 @@ public async Task RunStreamingAsyncPropagatesBackgroundResponsesPropertiesToChat new ChatResponseUpdate(role: ChatRole.Assistant, content: "at?"), ]; - object continuationToken = new(); + var continuationToken = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }); ChatOptions? capturedChatOptions = null; Mock mockChatClient = new(); mockChatClient @@ -2266,8 +2266,8 @@ public async Task RunStreamingAsyncPrioritizesBackgroundResponsesPropertiesFromA new ChatResponseUpdate(role: ChatRole.Assistant, content: "wh"), ]; - object continuationToken1 = new(); - object continuationToken2 = new(); + var continuationToken1 = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }); + var continuationToken2 = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }); ChatOptions? capturedChatOptions = null; Mock mockChatClient = new(); mockChatClient @@ -2307,7 +2307,7 @@ public async Task RunStreamingAsyncPrioritizesBackgroundResponsesPropertiesFromA public async Task RunAsyncPropagatesContinuationTokenFromChatResponseToAgentRunResponseAsync() { // Arrange - object continuationToken = new(); + var continuationToken = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }); Mock mockChatClient = new(); mockChatClient .Setup(c => c.GetResponseAsync( @@ -2332,7 +2332,7 @@ public async Task RunAsyncPropagatesContinuationTokenFromChatResponseToAgentRunR public async Task RunStreamingAsyncPropagatesContinuationTokensFromUpdatesAsync() { // Arrange - object token1 = new(); + var token1 = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }); ChatResponseUpdate[] expectedUpdates = [ new ChatResponseUpdate(ChatRole.Assistant, "pa") { ContinuationToken = token1 }, @@ -2372,7 +2372,7 @@ public async Task RunAsyncThrowsWhenMessagesProvidedWithContinuationTokenAsync() ChatClientAgent agent = new(mockChatClient.Object); - AgentRunOptions runOptions = new() { ContinuationToken = new() }; + AgentRunOptions runOptions = new() { ContinuationToken = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }) }; IEnumerable inputMessages = [new ChatMessage(ChatRole.User, "test message")]; @@ -2396,7 +2396,7 @@ public async Task RunStreamingAsyncThrowsWhenMessagesProvidedWithContinuationTok ChatClientAgent agent = new(mockChatClient.Object); - AgentRunOptions runOptions = new() { ContinuationToken = new() }; + AgentRunOptions runOptions = new() { ContinuationToken = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }) }; IEnumerable inputMessages = [new ChatMessage(ChatRole.User, "test message")]; @@ -2459,7 +2459,7 @@ public async Task RunAsyncSkipsThreadMessagePopulationWithContinuationTokenAsync AIContextProvider = mockContextProvider.Object }; - AgentRunOptions runOptions = new() { ContinuationToken = new() }; + AgentRunOptions runOptions = new() { ContinuationToken = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }) }; // Act await agent.RunAsync([], thread, options: runOptions); @@ -2521,7 +2521,7 @@ public async Task RunStreamingAsyncSkipsThreadMessagePopulationWithContinuationT AIContextProvider = mockContextProvider.Object }; - AgentRunOptions runOptions = new() { ContinuationToken = new() }; + AgentRunOptions runOptions = new() { ContinuationToken = ResponseContinuationToken.FromBytes(new byte[] { 1, 2, 3 }) }; // Act await agent.RunStreamingAsync([], thread, options: runOptions).ToListAsync();