Python: [BREAKING] Remove deprecated Python OpenAI/Azure AI surfaces (#4990)

* [BREAKING] Remove deprecated Python OpenAI/Azure AI surfaces

Also clean up follow-on docs, environment guidance, package metadata, and lab test stability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix deleted semantic-kernel sample links

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address PR review feedback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* improve foundry language

* Fix A2A Foundry sample regression

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Eduard van Valkenburg
2026-03-31 22:36:21 +02:00
committed by GitHub
Unverified
parent a5eacbbe65
commit 3a49b1d6dd
144 changed files with 669 additions and 18739 deletions
+4 -5
View File
@@ -82,13 +82,12 @@ agent_framework/
### OpenAI (`openai/`)
- **`OpenAIChatClient`** - Chat client for OpenAI API
- **`OpenAIResponsesClient`** - Client for OpenAI Responses API
- **`OpenAIChatClient`** - Chat client for the OpenAI Responses API
- **`OpenAIChatCompletionClient`** - Chat client for the OpenAI Chat Completions API
### Azure OpenAI (`azure/`)
### Foundry (`foundry/`)
- **`AzureOpenAIChatClient`** - Chat client for Azure OpenAI
- **`AzureOpenAIResponsesClient`** - Client for Azure OpenAI Responses API
- **`FoundryChatClient`** - Chat client for Azure AI Foundry project endpoints
## Key Patterns
+33 -39
View File
@@ -5,7 +5,7 @@ Highlights
- Flexible Agent Framework: build, orchestrate, and deploy AI agents and multi-agent systems
- Multi-Agent Orchestration: Group chat, sequential, concurrent, and handoff patterns
- Plugin Ecosystem: Extend with native functions, OpenAPI, Model Context Protocol (MCP), and more
- LLM Support: OpenAI, Azure OpenAI, Azure AI, and more
- LLM Support: OpenAI, Foundry, Anthropic, and more
- Runtime Support: In-process and distributed agent execution
- Multimodal: Text, vision, and function calling
- Cross-Platform: .NET and Python implementations
@@ -16,6 +16,8 @@ Highlights
pip install agent-framework-core --pre
# Optional: Add Azure AI Foundry integration
pip install agent-framework-foundry --pre
# Optional: Add OpenAI integration
pip install agent-framework-openai --pre
```
Supported Platforms:
@@ -25,35 +27,33 @@ Supported Platforms:
## 1. Setup API Keys
Set as environment variables, or create a .env file at your project root:
Depending on the client you want to use, there are various environment variables you can set to configure the chat clients. This can be done in the environment itself, or with a `.env` file in your project root, some examples of environment variables include:
```bash
FOUNDRY_PROJECT_ENDPOINT=...
FOUNDRY_MODEL=...
...
OPENAI_API_KEY=sk-...
OPENAI_CHAT_MODEL=...
OPENAI_RESPONSES_MODEL=...
...
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=...
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=...
...
FOUNDRY_PROJECT_ENDPOINT=...
FOUNDRY_MODEL=...
AZURE_OPENAI_DEPLOYMENT_NAME=...
```
You can also override environment variables by explicitly passing configuration parameters to the chat client constructor:
```python
from agent_framework.azure import AzureOpenAIChatClient
from agent_framework.openai import OpenAIChatClient
client = AzureOpenAIChatClient(
client = OpenAIChatClient(
api_key="",
endpoint="",
deployment_name="",
api_version="",
model="",
)
```
See the following [setup guide](../../samples/01-get-started) for more information.
See the following [getting started samples](https://github.com/microsoft/agent-framework/tree/main/python/samples/01-get-started) for more information.
## 2. Create a Simple Agent
@@ -64,22 +64,19 @@ import asyncio
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient
async def main():
agent = Agent(
client=OpenAIChatClient(),
instructions="""
1) A robot may not injure a human being...
2) A robot must obey orders given it by human beings...
3) A robot must protect its own existence...
agent = Agent(
client=OpenAIChatClient(),
instructions="""
1) A robot may not injure a human being...
2) A robot must obey orders given it by human beings...
3) A robot must protect its own existence...
Give me the TLDR in exactly 5 words.
"""
)
Give me the TLDR in exactly 5 words.
"""
)
result = await agent.run("Summarize the Three Laws of Robotics")
print(result)
asyncio.run(main())
result = asyncio.run(agent.run("Summarize the Three Laws of Robotics"))
print(result)
# Output: Protect humans, obey, self-preserve, prioritized.
```
@@ -95,12 +92,10 @@ from agent_framework import Message, Role
async def main():
client = OpenAIChatClient()
messages = [
response = await client.get_response([
Message("system", ["You are a helpful assistant."]),
Message("user", ["Write a haiku about Agent Framework."])
]
response = await client.get_response(messages)
])
print(response.messages[0].text)
"""
@@ -122,13 +117,12 @@ Enhance your agent with custom tools and function calling:
import asyncio
from typing import Annotated
from random import randint
from pydantic import Field
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient
def get_weather(
location: Annotated[str, Field(description="The location to get the weather for.")],
location: Annotated[str, "The location to get the weather for."],
) -> str:
"""Get the weather for a given location."""
conditions = ["sunny", "cloudy", "rainy", "stormy"]
@@ -161,7 +155,7 @@ async def main():
asyncio.run(main())
```
You can explore additional agent samples [here](../../samples/02-agents).
You can explore additional agent samples [here](https://github.com/microsoft/agent-framework/tree/main/python/samples/02-agents).
## 5. Multi-Agent Orchestration
@@ -213,14 +207,14 @@ if __name__ == "__main__":
asyncio.run(main())
```
**Note**: Sequential, Concurrent, Group Chat, Handoff, and Magentic orchestrations are available. See examples in [orchestration samples](../../samples/03-workflows/orchestrations).
**Note**: Sequential, Concurrent, Group Chat, Handoff, and Magentic orchestrations are available. See examples in [orchestration samples](https://github.com/microsoft/agent-framework/tree/main/python/samples/03-workflows/orchestrations).
## More Examples & Samples
- [Getting Started with Agents](../../samples/02-agents): Basic agent creation and tool usage
- [Chat Client Examples](../../samples/02-agents/chat_client): Direct chat client usage patterns
- [Azure AI Integration](https://github.com/microsoft/agent-framework/tree/main/python/packages/azure-ai): Azure AI integration
- [Workflows Samples](../../samples/03-workflows): Advanced multi-agent patterns
- [Getting Started with Agents](https://github.com/microsoft/agent-framework/tree/main/python/samples/02-agents): Basic agent creation and tool usage
- [Chat Client Examples](https://github.com/microsoft/agent-framework/tree/main/python/samples/02-agents/chat_client): Direct chat client usage patterns
- [Foundry Integration](https://github.com/microsoft/agent-framework/tree/main/python/packages/foundry): Foundry integration
- [Workflows Samples](https://github.com/microsoft/agent-framework/tree/main/python/samples/03-workflows): Advanced multi-agent patterns
## Agent Framework Documentation
@@ -228,4 +222,4 @@ if __name__ == "__main__":
- [Python Package Documentation](https://github.com/microsoft/agent-framework/tree/main/python)
- [.NET Package Documentation](https://github.com/microsoft/agent-framework/tree/main/dotnet)
- [Design Documents](https://github.com/microsoft/agent-framework/tree/main/docs/design)
- [Learn Documentation](https://learn.microsoft.com/en-us/agent-framework/user-guide/workflows/orchestrations/overview)
- [Learn Documentation](https://learn.microsoft.com/agent-framework/)
@@ -231,8 +231,7 @@ class BaseChatClient(SerializationMixin, ABC, Generic[OptionsCoT]):
streaming and non-streaming responses.
For full-featured clients with middleware, telemetry, and function invocation support,
use the public client classes (e.g., ``OpenAIChatClient``, ``OpenAIResponsesClient``)
which compose these layers correctly.
use public client classes such as ``OpenAIChatClient`` which compose these layers correctly.
Examples:
.. code-block:: python
@@ -425,8 +425,8 @@ class SerializationMixin:
from openai import AsyncOpenAI
# OpenAI chat client requires an AsyncOpenAI client instance
# The client is marked as INJECTABLE = {"client"} in OpenAIBase
# OpenAI chat client requires an AsyncOpenAI client instance.
# The client dependency is excluded from serialization.
# Serialized data contains only the model configuration
client_data = {
@@ -251,21 +251,6 @@ class AgentExecutor(Executor):
Returns:
Dict containing serialized cache and session state
"""
# Check if using AzureAIAgentClient with server-side session and warn about checkpointing limitations
if is_chat_agent(self._agent) and self._session.service_session_id is not None:
client_class_name = self._agent.client.__class__.__name__
client_module = self._agent.client.__class__.__module__
if client_class_name == "AzureAIAgentClient" and "azure_ai" in client_module:
logger.warning(
"Checkpointing an AgentExecutor with AzureAIAgentClient that uses server-side sessions. "
"Currently, checkpointing does not capture messages from server-side sessions "
"(service_session_id: %s). The session state in checkpoints is not immutable and can be "
"modified by subsequent runs. If you need reliable checkpointing with Azure AI agents, "
"consider implementing a custom executor and managing the session state yourself.",
self._session.service_session_id,
)
serialized_session = self._session.to_dict()
return {
@@ -12,26 +12,11 @@ _IMPORTS: dict[str, tuple[str, str]] = {
"AgentCallbackContext": ("agent_framework_durabletask", "agent-framework-durabletask"),
"AgentFunctionApp": ("agent_framework_azurefunctions", "agent-framework-azurefunctions"),
"AgentResponseCallbackProtocol": ("agent_framework_durabletask", "agent-framework-durabletask"),
"AzureAIAgentClient": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureAIAgentOptions": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureAIProjectAgentOptions": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureAIClient": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureAIProjectAgentProvider": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureAISearchContextProvider": ("agent_framework_azure_ai_search", "agent-framework-azure-ai-search"),
"AzureAISearchSettings": ("agent_framework_azure_ai_search", "agent-framework-azure-ai-search"),
"AzureAISettings": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureAIAgentsProvider": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureCredentialTypes": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureTokenProvider": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureOpenAIAssistantsClient": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureOpenAIAssistantsOptions": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureOpenAIChatClient": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureOpenAIChatOptions": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureOpenAIEmbeddingClient": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureOpenAIResponsesClient": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureOpenAIResponsesOptions": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureOpenAISettings": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"AzureUserSecurityContext": ("agent_framework_azure_ai", "agent-framework-azure-ai"),
"DurableAIAgent": ("agent_framework_durabletask", "agent-framework-durabletask"),
"DurableAIAgentClient": ("agent_framework_durabletask", "agent-framework-durabletask"),
"DurableAIAgentOrchestrationContext": ("agent_framework_durabletask", "agent-framework-durabletask"),
@@ -4,24 +4,9 @@
# Install the relevant packages for full type support.
from agent_framework_azure_ai import (
AzureAIAgentClient,
AzureAIAgentsProvider,
AzureAIClient,
AzureAIProjectAgentOptions,
AzureAIProjectAgentProvider,
AzureAISettings,
AzureCredentialTypes,
AzureOpenAIAssistantsClient,
AzureOpenAIAssistantsOptions,
AzureOpenAIChatClient,
AzureOpenAIChatOptions,
AzureOpenAIEmbeddingClient,
AzureOpenAIResponsesClient,
AzureOpenAIResponsesOptions,
AzureOpenAISettings,
AzureTokenProvider,
AzureUserSecurityContext,
RawAzureAIClient,
)
from agent_framework_azure_ai_search import (
AzureAISearchContextProvider,
@@ -41,28 +26,13 @@ __all__ = [
"AgentCallbackContext",
"AgentFunctionApp",
"AgentResponseCallbackProtocol",
"AzureAIAgentClient",
"AzureAIAgentsProvider",
"AzureAIClient",
"AzureAIProjectAgentOptions",
"AzureAIProjectAgentProvider",
"AzureAISearchContextProvider",
"AzureAISearchSettings",
"AzureAISettings",
"AzureCredentialTypes",
"AzureOpenAIAssistantsClient",
"AzureOpenAIAssistantsOptions",
"AzureOpenAIChatClient",
"AzureOpenAIChatOptions",
"AzureOpenAIEmbeddingClient",
"AzureOpenAIResponsesClient",
"AzureOpenAIResponsesOptions",
"AzureOpenAISettings",
"AzureTokenProvider",
"AzureUserSecurityContext",
"DurableAIAgent",
"DurableAIAgentClient",
"DurableAIAgentOrchestrationContext",
"DurableAIAgentWorker",
"RawAzureAIClient",
]
@@ -9,7 +9,6 @@ Supported classes include:
- OpenAIChatClient (Responses API)
- OpenAIChatCompletionClient (Chat Completions API)
- OpenAIEmbeddingClient
- OpenAIAssistantsClient (deprecated)
"""
import importlib
@@ -28,13 +27,6 @@ _IMPORTS: dict[str, tuple[str, str]] = {
"OpenAISettings": ("agent_framework_openai", "agent-framework-openai"),
"ContentFilterResultSeverity": ("agent_framework_openai", "agent-framework-openai"),
"OpenAIContentFilterException": ("agent_framework_openai", "agent-framework-openai"),
"AssistantToolResources": ("agent_framework_openai", "agent-framework-openai"),
"OpenAIAssistantProvider": ("agent_framework_openai", "agent-framework-openai"),
"OpenAIAssistantsClient": ("agent_framework_openai", "agent-framework-openai"),
"OpenAIAssistantsOptions": ("agent_framework_openai", "agent-framework-openai"),
"OpenAIResponsesClient": ("agent_framework_openai", "agent-framework-openai"),
"OpenAIResponsesOptions": ("agent_framework_openai", "agent-framework-openai"),
"RawOpenAIResponsesClient": ("agent_framework_openai", "agent-framework-openai"),
}
@@ -4,11 +4,7 @@
# Install agent-framework-openai for full type support.
from agent_framework_openai import (
AssistantToolResources,
ContentFilterResultSeverity,
OpenAIAssistantProvider,
OpenAIAssistantsClient,
OpenAIAssistantsOptions,
OpenAIChatClient,
OpenAIChatCompletionClient,
OpenAIChatCompletionOptions,
@@ -17,20 +13,13 @@ from agent_framework_openai import (
OpenAIContinuationToken,
OpenAIEmbeddingClient,
OpenAIEmbeddingOptions,
OpenAIResponsesClient,
OpenAIResponsesOptions,
OpenAISettings,
RawOpenAIChatClient,
RawOpenAIChatCompletionClient,
RawOpenAIResponsesClient,
)
__all__ = [
"AssistantToolResources",
"ContentFilterResultSeverity",
"OpenAIAssistantProvider",
"OpenAIAssistantsClient",
"OpenAIAssistantsOptions",
"OpenAIChatClient",
"OpenAIChatCompletionClient",
"OpenAIChatCompletionOptions",
@@ -39,10 +28,7 @@ __all__ = [
"OpenAIContinuationToken",
"OpenAIEmbeddingClient",
"OpenAIEmbeddingOptions",
"OpenAIResponsesClient",
"OpenAIResponsesOptions",
"OpenAISettings",
"RawOpenAIChatClient",
"RawOpenAIChatCompletionClient",
"RawOpenAIResponsesClient",
]