From 9c1b2f9a3f702c7888f0f2d058d7c7d92558b6b1 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 12:27:48 +0000 Subject: [PATCH] .NET: Annotate all public methods of OpenAIAssistantClientExtensions with Obsolete attribute (#2640) * Initial plan * Add Obsolete attribute to all public methods of OpenAIAssistantClientExtensions Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com> * Add pragma warning disable CS0618 to files using deprecated OpenAI Assistants API Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com> * Update Obsolete attribute message to use requested text Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com> --- .../Agent_With_OpenAIAssistants/Program.cs | 2 ++ .../Extensions/OpenAIAssistantClientExtensions.cs | 12 ++++++++++++ .../OpenAIAssistantClientExtensionsTests.cs | 2 ++ .../OpenAIAssistantClientExtensionsTests.cs | 2 ++ 4 files changed, 18 insertions(+) diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIAssistants/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIAssistants/Program.cs index 9a91e43d37..b39a21f71f 100644 --- a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIAssistants/Program.cs +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIAssistants/Program.cs @@ -5,6 +5,8 @@ // WARNING: The Assistants API is deprecated and will be shut down. // For more information see the OpenAI documentation: https://platform.openai.com/docs/assistants/migration +#pragma warning disable CS0618 // Type or member is obsolete - OpenAI Assistants API is deprecated but still used in this sample + using Microsoft.Agents.AI; using OpenAI; diff --git a/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs b/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs index fb464fdc39..f103a7fc1c 100644 --- a/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs @@ -30,6 +30,7 @@ public static class OpenAIAssistantClientExtensions /// Provides a way to customize the creation of the underlying used by the agent. /// An optional to use for resolving services required by the instances being invoked. /// A instance that can be used to perform operations on the assistant. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static ChatClientAgent GetAIAgent( this AssistantClient assistantClient, ClientResult assistantClientResult, @@ -54,6 +55,7 @@ public static class OpenAIAssistantClientExtensions /// Provides a way to customize the creation of the underlying used by the agent. /// An optional to use for resolving services required by the instances being invoked. /// A instance that can be used to perform operations on the assistant. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static ChatClientAgent GetAIAgent( this AssistantClient assistantClient, Assistant assistantMetadata, @@ -102,6 +104,7 @@ public static class OpenAIAssistantClientExtensions /// An optional to use for resolving services required by the instances being invoked. /// The to monitor for cancellation requests. The default is . /// A instance that can be used to perform operations on the assistant agent. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static ChatClientAgent GetAIAgent( this AssistantClient assistantClient, string agentId, @@ -134,6 +137,7 @@ public static class OpenAIAssistantClientExtensions /// An optional to use for resolving services required by the instances being invoked. /// The to monitor for cancellation requests. The default is . /// A instance that can be used to perform operations on the assistant agent. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static async Task GetAIAgentAsync( this AssistantClient assistantClient, string agentId, @@ -166,6 +170,7 @@ public static class OpenAIAssistantClientExtensions /// An optional to use for resolving services required by the instances being invoked. /// A instance that can be used to perform operations on the assistant. /// or is . + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static ChatClientAgent GetAIAgent( this AssistantClient assistantClient, ClientResult assistantClientResult, @@ -191,6 +196,7 @@ public static class OpenAIAssistantClientExtensions /// An optional to use for resolving services required by the instances being invoked. /// A instance that can be used to perform operations on the assistant. /// or is . + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static ChatClientAgent GetAIAgent( this AssistantClient assistantClient, Assistant assistantMetadata, @@ -252,6 +258,7 @@ public static class OpenAIAssistantClientExtensions /// A instance that can be used to perform operations on the assistant agent. /// or is . /// is empty or whitespace. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static ChatClientAgent GetAIAgent( this AssistantClient assistantClient, string agentId, @@ -291,6 +298,7 @@ public static class OpenAIAssistantClientExtensions /// A instance that can be used to perform operations on the assistant agent. /// or is . /// is empty or whitespace. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static async Task GetAIAgentAsync( this AssistantClient assistantClient, string agentId, @@ -333,6 +341,7 @@ public static class OpenAIAssistantClientExtensions /// An instance backed by the OpenAI Assistant service. /// Thrown when or is . /// Thrown when is empty or whitespace. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static ChatClientAgent CreateAIAgent( this AssistantClient client, string model, @@ -371,6 +380,7 @@ public static class OpenAIAssistantClientExtensions /// An instance backed by the OpenAI Assistant service. /// Thrown when or or is . /// Thrown when is empty or whitespace. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static ChatClientAgent CreateAIAgent( this AssistantClient client, string model, @@ -437,6 +447,7 @@ public static class OpenAIAssistantClientExtensions /// An instance backed by the OpenAI Assistant service. /// Thrown when or is . /// Thrown when is empty or whitespace. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static async Task CreateAIAgentAsync( this AssistantClient client, string model, @@ -477,6 +488,7 @@ public static class OpenAIAssistantClientExtensions /// An instance backed by the OpenAI Assistant service. /// Thrown when or is . /// Thrown when is empty or whitespace. + [Obsolete("The Assistants API has been deprecated. Please use the Responses API instead.")] public static async Task CreateAIAgentAsync( this AssistantClient client, string model, diff --git a/dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Extensions/OpenAIAssistantClientExtensionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Extensions/OpenAIAssistantClientExtensionsTests.cs index 26f855d59e..c75d72cf34 100644 --- a/dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Extensions/OpenAIAssistantClientExtensionsTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Extensions/OpenAIAssistantClientExtensionsTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. +#pragma warning disable CS0618 // Type or member is obsolete - This is intentional as we are testing deprecated methods + using System; using System.ClientModel; using System.ClientModel.Primitives; diff --git a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs index f1373bd98b..0c8d6b80dd 100644 --- a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs +++ b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. +#pragma warning disable CS0618 // Type or member is obsolete - Testing deprecated OpenAI Assistants API extension methods + using System; using System.Diagnostics; using System.IO;