Skip to content

.Net: [BREAKING] Remove retired OpenAI Assistants agent and port samples to Foundry Prompt Agents - #14826

Open
Roger Barreto (rogerbarreto) wants to merge 4 commits into
microsoft:mainfrom
rogerbarreto:assistants-removal-plan
Open

Roger Barreto (rogerbarreto) wants to merge 4 commits into
microsoft:mainfrom
rogerbarreto:assistants-removal-plan

Conversation

@rogerbarreto

Copy link
Copy Markdown
Member

Motivation and Context

OpenAI shut down the Assistants API on August 26, 2026 (OpenAI deprecations). Every OpenAIAssistantAgent call now fails, and the samples that teach it can no longer run.

This PR removes the .NET Assistants agent surface and ports every Assistants sample to a Microsoft Foundry Prompt Agent, which is also the replacement that the migration guidance in #14823 recommends. A Foundry Prompt Agent is a versioned agent definition (model, instructions, and tools) stored in a Foundry project.

Python is not changed here. Porting the Python Assistants samples needs azure-ai-projects 2.x, which the current Python AzureAIAgent can't use yet, so that work is left for a follow-up.

Description

Breaking: removed from Microsoft.SemanticKernel.Agents.OpenAI (preview package)

  • OpenAIAssistantAgent, OpenAIAssistantAgentThread, OpenAIAssistantAgentInvokeOptions, and OpenAIAssistantAgentExtensions.AsAIAgent
  • OpenAIAssistantAgentFactory and the openai_assistant declarative agent type
  • OpenAIAssistantCapabilities, OpenAIAssistantDefinition, OpenAIAssistantExecutionOptions, OpenAIAssistantInvocationOptions, OpenAIThreadCreationOptions, RunPollingOptions, and OpenAIClientProvider
  • AssistantClientExtensions and OpenAIClientExtensions (vector store and file helpers that only the Assistants samples used)
  • ChatContentMessageExtensions.ToThreadInitializationMessage(s) and KernelFunctionExtensions.ToToolDefinition
  • The internal Assistants channel, run, message, and logging helpers, and their unit tests

The package keeps OpenAIResponseAgent. Serialized OpenAIAssistantAgentThread state and openai_assistant YAML definitions no longer load. Package validation is disabled for this preview package, so no compatibility suppressions were needed.

Other library changes

  • ProcessAgentFactory (process framework) no longer maps the openai_assistant type.
  • The internal AggregatorAgent channel restore log methods drop their leftover OpenAIAssistant names, and an Agent.cs doc example no longer mentions Assistants.
  • Microsoft.Extensions.AI and Microsoft.Extensions.AI.OpenAI move from 10.5.0 to 10.5.2 to match Microsoft.Extensions.AI.Abstractions 10.5.2. With 10.5.0, every Responses conversion in Microsoft.Extensions.AI.OpenAI throws MissingMethodException for WebSearchToolResultContent.set_Results, because Abstractions 10.5.2 renamed that experimental member. .Net: Update Semantic Kernel to Agent Framework migration guidance and samples #14823 makes the identical change, so the two PRs merge cleanly in either order.

How the samples use a Foundry Prompt Agent

The new sample helper FoundryPromptAgentExtensions.AsKernelChatClient turns a Prompt Agent version into an IChatClient for the kernel of a ChatCompletionAgent:

  1. projectClient.AsAIAgent(agentVersion, clientFactory: ...) from Microsoft.Agents.AI.Foundry captures the innermost Agent Framework chat client. That client sends each request with the agent reference and drops the request options the service rejects when an agent is specified (model, instructions, and tools).
  2. A small DelegatingChatClient clears the conversation id that the Responses API returns, so the ChatHistoryAgentThread stays the only record of the conversation.
  3. UseKernelFunctionInvocation() lets Semantic Kernel run the function calling loop, so IFunctionInvocationFilter and IAutoFunctionInvocationFilter still apply.

Function schemas are declared on the Prompt Agent definition (AddFunctionTools), and the plugin still runs locally. Files generated by the code interpreter are read from the container file citations in the raw response (ChatMessageContent.InnerContent).

Step 2 works around a library bug that deserves its own fix: KernelFunctionInvokingChatClient calls context.Messages.Last() (line 77), and Microsoft.Extensions.AI passes an empty message list once an IChatClient returns a conversation id. This PR only works around it in sample code.

Samples

Before After
GettingStartedWithAgents/OpenAIAssistant/Step01 to Step07 GettingStartedWithAgents/FoundryPromptAgent/Step01 to Step07 (templated instructions, plugins, vision, code interpreter, file search, stored function tools, declarative)
Concepts/Agents/OpenAIAssistant_* Concepts/Agents/FoundryPromptAgent_* (chart maker, file manipulation, function filters, streaming, templating)
Concepts/Agents/MixedChat_* Same files; the Assistant is replaced with a Foundry backed ChatCompletionAgent
Step07_Telemetry, Orchestration/Step06_DifferentAgentTypes, GettingStartedWithProcesses/Step04 Foundry backed agents replace the Assistants
Step10_MultiAgent_Declarative The unused Assistant factory and client are removed
BaseAssistantTest BaseFoundryAgentTest; BaseOrchestrationTest gets CreateFoundryPromptAgentAsync

Every sample deletes the Prompt Agents, files, and vector stores it creates. The vision sample uses images stored in this repository, because Wikimedia rate limits the Foundry image downloader. The READMEs and EXPERIMENTS.md are updated.

Not changed: AzureAIAgent (a different service), the obsolete OpenAIFileService connector, the ADRs, and dotnet/samples/AgentFrameworkMigration (#14823).

Validation

  • dotnet build dotnet/SK-dotnet.slnx -c Debug --tl:off --warnaserror: 0 warnings, 0 errors.
  • All 23 unit test projects in the PR workflow scope (dotnet test -c Debug, net10.0): 5,471 passed, 0 failed, 22 skipped.
  • dotnet format <project> --verify-no-changes (Windows, SDK 10.0.404) on the 9 projects with changed C# files: no changes. The CI container image could not restore locally because the network rejected its TLS connection to nuget.org, so CI provides the container check.
  • Live runs against a Microsoft Foundry project, all passing: GettingStartedWithAgents FoundryPromptAgent (11 cases), Concepts FoundryPromptAgent_* (14 cases) and MixedChat_* (12 cases), Orchestration/Step06_DifferentAgentTypes sequential and group chat, Step07_Telemetry logging and console tracing, and the GettingStartedWithProcesses Step04 single agent process. The Application Insights tracing cases were not run because Application Insights is not configured.

Contribution Checklist

…dry Prompt Agents

OpenAI shut down the Assistants API on August 26, 2026, so every
OpenAIAssistantAgent call now fails.

- Remove OpenAIAssistantAgent, OpenAIAssistantAgentThread, the declarative
  OpenAIAssistantAgentFactory (openai_assistant), the Assistants option and
  definition types, RunPollingOptions, OpenAIClientProvider,
  AssistantClientExtensions, OpenAIClientExtensions,
  ToThreadInitializationMessage(s), ToToolDefinition, the internal Assistants
  run and message helpers, and their unit tests. Agents.OpenAI keeps
  OpenAIResponseAgent.
- Port every Assistants sample to a Microsoft Foundry Prompt Agent used
  through a ChatCompletionAgent (GettingStartedWithAgents/FoundryPromptAgent,
  Concepts FoundryPromptAgent_* and MixedChat_*, telemetry, orchestration,
  declarative and process samples).
- Add FoundryPromptAgentExtensions and BaseFoundryAgentTest sample utilities.
  The kernel chat client wraps the Agent Framework Foundry chat client so that
  Semantic Kernel runs function calling and its filters.
- Bump Microsoft.Extensions.AI.OpenAI to 10.5.2 to match
  Microsoft.Extensions.AI.Abstractions 10.5.2; 10.5.0 fails at runtime with
  MissingMethodException when converting Responses output.
…ractions 10.5.2

Bump Microsoft.Extensions.AI to 10.5.2 so the whole Microsoft.Extensions.AI
package family shares one patch version. This matches the same change in microsoft#14823,
so both pull requests merge cleanly in either order.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

With launchViewer: true, automatically opening generated citations with their original extensions can execute .cmd or .bat files on a developer’s machine.

2 open issues
What changed in this PR

This PR removes the retired .NET OpenAI Assistants integration and migrates its samples to Microsoft Foundry Prompt Agents through ChatCompletionAgent. It retains OpenAIResponseAgent and leaves Python unchanged.

Changes:

  • Removes Assistants-specific APIs, factories, helpers, and unit tests.
  • Ports samples to Foundry, adding shared setup, tool integration, and resource cleanup.
  • Updates documentation and dependencies, including the version alignment also proposed in #14823.
File Description
dotnet/​src/​InternalUtilities/​samples/​InternalUtilities/​TestConfiguration.cs Removes unused Assistant ID configuration.
dotnet/​src/​InternalUtilities/​samples/​AgentUtilities/​BaseOrchestrationTest.cs Adds Foundry agent creation and cleanup.
dotnet/​src/​InternalUtilities/​samples/​AgentUtilities/​BaseFoundryAgentTest.cs Adds shared Foundry sample utilities.
dotnet/​src/​InternalUtilities/​samples/​AgentUtilities/​BaseAzureAgentTest.cs Removes Assistants-specific output handling.
dotnet/​src/​InternalUtilities/​samples/​AgentUtilities/​BaseAssistantTest.cs Deletes the Assistants sample base.
dotnet/​src/​InternalUtilities/​samples/​AgentUtilities/​BaseAgentsTest.cs Uses Azure agent metadata and usage types.
dotnet/​src/​InternalUtilities/​process/​Runtime/​AgentFactoryFactory.cs Removes the Assistants factory mapping.
dotnet/​src/​Agents/​UnitTests/​Yaml/​AgentYamlTests.cs Removes Assistants YAML tests and setup.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​RunPollingOptionsTests.cs Deletes retired polling-option tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​OpenAIThreadCreationOptionsTests.cs Deletes retired thread-option tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​OpenAIClientProviderTests.cs Deletes retired client-provider tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​OpenAIAssistantInvocationOptionsTests.cs Deletes Assistants invocation-option tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​OpenAIAssistantDefinitionTests.cs Deletes Assistants definition tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​OpenAIAssistantAgentInvokeOptionsTests.cs Deletes Assistants invoke-option tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​OpenAIAssistantAgentExtensionsTests.cs Deletes Assistants adapter tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​Internal/​AssistantRunOptionsFactoryTests.cs Deletes run-option factory tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​Internal/​AssistantMessageFactoryTests.cs Deletes Assistants message-conversion tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​Extensions/​OpenAIClientExtensionsTests.cs Deletes removed client-helper tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​Extensions/​KernelFunctionExtensionsTests.cs Deletes Assistants tool-conversion tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​Extensions/​KernelExtensionsTests.cs Deletes obsolete client-provider test scaffolding.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​Extensions/​AuthorRoleExtensionsTests.cs Deletes Assistants role-conversion tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​Extensions/​AgentDefinitionExtensionsTests.cs Deletes Assistants definition-helper tests.
dotnet/​src/​Agents/​UnitTests/​OpenAI/​Definition/​OpenAIAssistantAgentFactoryTests.cs Deletes Assistants factory tests.
dotnet/​src/​Agents/​OpenAI/​RunPollingOptions.cs Removes Assistants polling configuration.
dotnet/​src/​Agents/​OpenAI/​OpenAIThreadCreationOptions.cs Removes legacy thread-creation options.
dotnet/​src/​Agents/​OpenAI/​OpenAIClientProvider.cs Removes the legacy client provider.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantInvocationOptions.cs Removes legacy invocation options.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantExecutionOptions.cs Removes legacy execution options.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantDefinition.cs Removes the Assistants definition model.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantChannel.cs Removes the Assistants chat channel.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantCapabilities.cs Removes the Assistants capability model.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantAgentThread.cs Removes Assistants thread management.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantAgentInvokeOptions.cs Removes Assistants invocation settings.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantAgentExtensions.cs Removes the Assistants Agent Framework adapter.
dotnet/​src/​Agents/​OpenAI/​OpenAIAssistantAgent.ClientFactory.cs Removes Assistants client factories.
dotnet/​src/​Agents/​OpenAI/​Logging/​OpenAIAssistantAgentLogMessages.cs Removes Assistants agent logging helpers.
dotnet/​src/​Agents/​OpenAI/​Logging/​AssistantThreadActionsLogMessages.cs Removes Assistants thread logging helpers.
dotnet/​src/​Agents/​OpenAI/​Internal/​AssistantToolResourcesFactory.cs Removes Assistants tool-resource construction.
dotnet/​src/​Agents/​OpenAI/​Internal/​AssistantRunOptionsFactory.cs Removes Assistants run-option construction.
dotnet/​src/​Agents/​OpenAI/​Internal/​AssistantMessageFactory.cs Removes Assistants message conversion.
dotnet/​src/​Agents/​OpenAI/​Extensions/​OpenAIClientExtensions.cs Removes file and vector-store convenience helpers.
dotnet/​src/​Agents/​OpenAI/​Extensions/​ModelConnectionExtensions.cs Removes Assistants connection helpers.
dotnet/​src/​Agents/​OpenAI/​Extensions/​KernelFunctionExtensions.cs Removes Assistants conversion; retains Responses support.
dotnet/​src/​Agents/​OpenAI/​Extensions/​ChatContentMessageExtensions.cs Removes Assistants thread-message conversion.
dotnet/​src/​Agents/​OpenAI/​Extensions/​AuthorRoleExtensions.cs Removes Assistants role conversion.
dotnet/​src/​Agents/​OpenAI/​Extensions/​AssistantClientExtensions.cs Removes Assistants creation helpers.
dotnet/​src/​Agents/​OpenAI/​Extensions/​AgentDefinitionExtensions.cs Removes Assistants declarative-definition helpers.
dotnet/​src/​Agents/​OpenAI/​Definition/​OpenAIAssistantAgentFactory.cs Removes the declarative Assistants factory.
dotnet/​src/​Agents/​OpenAI/​Agents.OpenAI.csproj Describes the retained Responses integration.
dotnet/​src/​Agents/​Abstractions/​Logging/​AggregatorAgentLogMessages.cs Renames aggregator restore logging methods and messages.
dotnet/​src/​Agents/​Abstractions/​AggregatorAgent.cs Calls the renamed aggregator logging methods.
dotnet/​src/​Agents/​Abstractions/​Agent.cs Updates a documentation example to Azure AI agents.
dotnet/​samples/​GettingStartedWithProcesses/​Step04/​Step04_AgentOrchestration.cs Uses Foundry for the single-agent process sample.
dotnet/​samples/​GettingStartedWithProcesses/​GettingStartedWithProcesses.csproj Adds Foundry dependencies and shared helper inclusion.
dotnet/​samples/​GettingStartedWithAgents/​Step10_MultiAgent_Declarative.cs Removes unused Assistants client and factory registration.
dotnet/​samples/​GettingStartedWithAgents/​Step07_Telemetry.cs Migrates telemetry demonstrations to Foundry.
dotnet/​samples/​GettingStartedWithAgents/​README.md Documents Foundry samples and configuration.
dotnet/​samples/​GettingStartedWithAgents/​Orchestration/​Step06_DifferentAgentTypes.cs Replaces Assistants with Foundry-backed agents.
dotnet/​samples/​GettingStartedWithAgents/​OpenAIAssistant/​Step06_AssistantTool_Function.cs Removes the Assistants function-tool sample.
dotnet/​samples/​GettingStartedWithAgents/​OpenAIAssistant/​Step05_AssistantTool_FileSearch.cs Removes the Assistants file-search sample.
dotnet/​samples/​GettingStartedWithAgents/​OpenAIAssistant/​Step04_AssistantTool_CodeInterpreter.cs Removes the Assistants code-interpreter sample.
dotnet/​samples/​GettingStartedWithAgents/​OpenAIAssistant/​Step03_Assistant_Vision.cs Removes the Assistants vision sample.
dotnet/​samples/​GettingStartedWithAgents/​OpenAIAssistant/​Step02_Assistant_Plugins.cs Removes the Assistants plugin sample.
dotnet/​samples/​GettingStartedWithAgents/​OpenAIAssistant/​Step01_Assistant.cs Removes the Assistants templating sample.
dotnet/​samples/​GettingStartedWithAgents/​GettingStartedWithAgents.csproj Adds the Foundry integration dependency.
dotnet/​samples/​GettingStartedWithAgents/​FoundryPromptAgent/​Step06_FoundryPromptAgentTool_Function.cs Demonstrates stored function tools and local plugins.
dotnet/​samples/​GettingStartedWithAgents/​FoundryPromptAgent/​Step05_FoundryPromptAgentTool_FileSearch.cs Demonstrates Foundry file search.
dotnet/​samples/​GettingStartedWithAgents/​FoundryPromptAgent/​Step04_FoundryPromptAgentTool_CodeInterpreter.cs Demonstrates Foundry code interpreter.
dotnet/​samples/​GettingStartedWithAgents/​FoundryPromptAgent/​Step03_FoundryPromptAgent_Vision.cs Demonstrates image URLs and inline image input.
dotnet/​samples/​GettingStartedWithAgents/​FoundryPromptAgent/​Step02_FoundryPromptAgent_Plugins.cs Demonstrates Foundry with local kernel plugins.
dotnet/​samples/​GettingStartedWithAgents/​FoundryPromptAgent/​Step01_FoundryPromptAgent.cs Demonstrates Foundry with templated instructions.
dotnet/​samples/​Concepts/​README.md Links to the Foundry chart sample.
dotnet/​samples/​Concepts/​Concepts.csproj Adds the Foundry integration dependency.
dotnet/​samples/​Concepts/​Agents/​README.md Updates sample guidance and Foundry configuration.
dotnet/​samples/​Concepts/​Agents/​OpenAIAssistant_Streaming.cs Removes the Assistants streaming sample.
dotnet/​samples/​Concepts/​Agents/​MixedChat_Streaming.cs Uses Foundry in streaming group chat.
dotnet/​samples/​Concepts/​Agents/​MixedChat_Serialization.cs Uses Foundry in chat serialization demonstrations.
dotnet/​samples/​Concepts/​Agents/​MixedChat_Reset.cs Uses Foundry in chat reset demonstrations.
dotnet/​samples/​Concepts/​Agents/​MixedChat_Images.cs Uses Foundry for chart generation and downloads.
dotnet/​samples/​Concepts/​Agents/​MixedChat_Files.cs Uses Foundry for file analysis and reports.
dotnet/​samples/​Concepts/​Agents/​MixedChat_Agents.cs Combines Foundry and chat-completion services.
dotnet/​samples/​Concepts/​Agents/​FoundryPromptAgent_Templating.cs Ports instruction-template demonstrations to Foundry.
dotnet/​samples/​Concepts/​Agents/​FoundryPromptAgent_FileManipulation.cs Ports CSV manipulation to Foundry.
dotnet/​samples/​Concepts/​Agents/​FoundryPromptAgent_ChartMaker.cs Ports chart generation to Foundry.
dotnet/​docs/​EXPERIMENTS.md Removes the retired Assistants experiment entry.
dotnet/​Directory.Packages.props Aligns Microsoft.Extensions.AI packages at 10.5.2.
.github/​workflows/​dotnet-build-and-test.yml Removes the obsolete Assistants test exclusion.

Review effort: Balanced

- Open only generated images, through the shell's default viewer instead of a
  cmd.exe command line, because the model chooses generated file names.
- Wait, with a timeout, for the file-search vector store to finish indexing
  before the first question, and delete every created resource on failure.

This branch was previously deployed

1 inactive deployment
github-app-auth — 3b7d8e6e Deployed Nov 20, 2026 by rogerbarreto via add_label #29778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants