Skip to content

Commit 8fc19a3

Browse files
giles17Copilot
andauthored
Python: Deprecate Azure AI v1 (Persistent Agents API) helper methods (microsoft#4804)
* Deprecate Azure AI v1 (Persistent Agents API) helper methods Add DeprecationWarning to v1 classes and functions that have been superseded by the v2 (Projects/Responses) API: - AzureAIAgentsProvider -> use AzureAIProjectAgentProvider - AzureAIAgentClient -> use AzureAIClient - AzureAIAgentOptions -> use AzureAIProjectAgentOptions - to_azure_ai_agent_tools() -> use to_azure_ai_tools() - from_azure_ai_agent_tools() -> use from_azure_ai_tools() - AzureAIAgentClient static tool factory methods -> use AzureAIClient equivalents All v1 components still function but emit warnings to guide migration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add deprecation warnings to AzureAIAgentsProvider methods Mark create_agent(), get_agent(), and as_agent() as deprecated individually, pointing to AzureAIProjectAgentProvider equivalents. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 26cd5cc commit 8fc19a3

3 files changed

Lines changed: 119 additions & 1 deletion

File tree

python/packages/azure-ai/agent_framework_azure_ai/_agent_provider.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import sys
6+
import warnings
67
from collections.abc import Callable, Sequence
78
from typing import Any, Generic, cast
89

@@ -49,6 +50,10 @@
4950
class AzureAIAgentsProvider(Generic[OptionsCoT]):
5051
"""Provider for Azure AI Agent Service V1 (Persistent Agents API).
5152
53+
.. deprecated::
54+
AzureAIAgentsProvider is deprecated and will be removed in a future release.
55+
Use :class:`AzureAIProjectAgentProvider` instead for the V2 (Projects/Responses) API.
56+
5257
This provider enables creating, retrieving, and wrapping Azure AI agents as Agent
5358
instances. It manages the underlying AgentsClient lifecycle and provides a high-level
5459
interface for agent operations.
@@ -114,6 +119,12 @@ def __init__(
114119
Raises:
115120
ValueError: If required parameters are missing or invalid.
116121
"""
122+
warnings.warn(
123+
"AzureAIAgentsProvider is deprecated and will be removed in a future release; "
124+
"use AzureAIProjectAgentProvider instead for the V2 (Projects/Responses) API.",
125+
DeprecationWarning,
126+
stacklevel=2,
127+
)
117128
self._settings = load_settings(
118129
AzureAISettings,
119130
env_prefix="AZURE_AI_",
@@ -177,6 +188,10 @@ async def create_agent(
177188
) -> Agent[OptionsCoT]:
178189
"""Create a new agent on the Azure AI service and return a Agent.
179190
191+
.. deprecated::
192+
This method is deprecated and will be removed in a future release.
193+
Use :meth:`AzureAIProjectAgentProvider.create_agent` instead.
194+
180195
This method creates a persistent agent on the Azure AI service with the specified
181196
configuration and returns a local Agent instance for interaction.
182197
@@ -209,6 +224,12 @@ async def create_agent(
209224
tools=get_weather,
210225
)
211226
"""
227+
warnings.warn(
228+
"AzureAIAgentsProvider.create_agent() is deprecated and will be removed in a future release; "
229+
"use AzureAIProjectAgentProvider.create_agent() instead.",
230+
DeprecationWarning,
231+
stacklevel=2,
232+
)
212233
resolved_model = model or self._settings.get("model_deployment_name")
213234
if not resolved_model:
214235
raise ValueError(
@@ -271,6 +292,10 @@ async def get_agent(
271292
) -> Agent[OptionsCoT]:
272293
"""Retrieve an existing agent from the service and return a Agent.
273294
295+
.. deprecated::
296+
This method is deprecated and will be removed in a future release.
297+
Use :meth:`AzureAIProjectAgentProvider.get_agent` instead.
298+
274299
This method fetches an agent by ID from the Azure AI service
275300
and returns a local Agent instance for interaction.
276301
@@ -299,6 +324,12 @@ async def get_agent(
299324
# With function tools
300325
agent = await provider.get_agent("agent-123", tools=my_function)
301326
"""
327+
warnings.warn(
328+
"AzureAIAgentsProvider.get_agent() is deprecated and will be removed in a future release; "
329+
"use AzureAIProjectAgentProvider.get_agent() instead.",
330+
DeprecationWarning,
331+
stacklevel=2,
332+
)
302333
agent = await self._agents_client.get_agent(id)
303334

304335
# Validate function tools
@@ -323,6 +354,10 @@ def as_agent(
323354
) -> Agent[OptionsCoT]:
324355
"""Wrap an existing Agent SDK object as a Agent without making HTTP calls.
325356
357+
.. deprecated::
358+
This method is deprecated and will be removed in a future release.
359+
Use :meth:`AzureAIProjectAgentProvider.as_agent` instead.
360+
326361
Use this method when you already have an Agent object from a previous
327362
SDK operation and want to use it with the Agent Framework.
328363
@@ -354,6 +389,12 @@ def as_agent(
354389
# Wrap as Agent
355390
chat_agent = provider.as_agent(sdk_agent)
356391
"""
392+
warnings.warn(
393+
"AzureAIAgentsProvider.as_agent() is deprecated and will be removed in a future release; "
394+
"use AzureAIProjectAgentProvider.as_agent() instead.",
395+
DeprecationWarning,
396+
stacklevel=2,
397+
)
357398
# Validate function tools
358399
normalized_tools = normalize_tools(tools)
359400
self._validate_function_tools(agent.tools, normalized_tools)

python/packages/azure-ai/agent_framework_azure_ai/_chat_client.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import re
1010
import sys
11+
import warnings
1112
from collections.abc import AsyncIterable, Awaitable, Callable, Mapping, MutableMapping, Sequence
1213
from typing import Any, ClassVar, Generic, TypedDict, cast
1314

@@ -118,6 +119,10 @@
118119
class AzureAIAgentOptions(ChatOptions, total=False):
119120
"""Azure AI Foundry Agent Service-specific options dict.
120121
122+
.. deprecated::
123+
AzureAIAgentOptions is deprecated and will be removed in a future release.
124+
Use :class:`AzureAIProjectAgentOptions` instead for the V2 (Projects/Responses) API.
125+
121126
Extends base ChatOptions with Azure AI Agent Service parameters.
122127
Azure AI Agents provides a managed agent runtime with built-in
123128
tools for code interpreter, file search, and web search.
@@ -212,7 +217,12 @@ class AzureAIAgentClient(
212217
BaseChatClient[AzureAIAgentOptionsT],
213218
Generic[AzureAIAgentOptionsT],
214219
):
215-
"""Azure AI Agent Chat client with middleware, telemetry, and function invocation support."""
220+
"""Azure AI Agent Chat client with middleware, telemetry, and function invocation support.
221+
222+
.. deprecated::
223+
AzureAIAgentClient is deprecated and will be removed in a future release.
224+
Use :class:`AzureAIClient` instead for the V2 (Projects/Responses) API.
225+
"""
216226

217227
OTEL_PROVIDER_NAME: ClassVar[str] = "azure.ai" # type: ignore[reportIncompatibleVariableOverride, misc]
218228
STORES_BY_DEFAULT: ClassVar[bool] = True # type: ignore[reportIncompatibleVariableOverride, misc]
@@ -227,6 +237,10 @@ def get_code_interpreter_tool(
227237
) -> CodeInterpreterTool:
228238
"""Create a code interpreter tool configuration for Azure AI Agents.
229239
240+
.. deprecated::
241+
This method is deprecated and will be removed in a future release.
242+
Use :meth:`AzureAIClient.get_code_interpreter_tool` instead.
243+
230244
Keyword Args:
231245
file_ids: List of uploaded file IDs or Content objects to make available to
232246
the code interpreter. Accepts plain strings or Content.from_hosted_file()
@@ -256,6 +270,12 @@ def get_code_interpreter_tool(
256270
257271
agent = ChatAgent(client, tools=[tool])
258272
"""
273+
warnings.warn(
274+
"AzureAIAgentClient.get_code_interpreter_tool() is deprecated and will be removed in a future release; "
275+
"use AzureAIClient.get_code_interpreter_tool() instead.",
276+
DeprecationWarning,
277+
stacklevel=2,
278+
)
259279
resolved = resolve_file_ids(file_ids)
260280
return CodeInterpreterTool(file_ids=resolved, data_sources=data_sources)
261281

@@ -266,6 +286,10 @@ def get_file_search_tool(
266286
) -> FileSearchTool:
267287
"""Create a file search tool configuration for Azure AI Agents.
268288
289+
.. deprecated::
290+
This method is deprecated and will be removed in a future release.
291+
Use :meth:`AzureAIClient.get_file_search_tool` instead.
292+
269293
Keyword Args:
270294
vector_store_ids: List of vector store IDs to search within.
271295
@@ -282,6 +306,12 @@ def get_file_search_tool(
282306
)
283307
agent = ChatAgent(client, tools=[tool])
284308
"""
309+
warnings.warn(
310+
"AzureAIAgentClient.get_file_search_tool() is deprecated and will be removed in a future release; "
311+
"use AzureAIClient.get_file_search_tool() instead.",
312+
DeprecationWarning,
313+
stacklevel=2,
314+
)
285315
return FileSearchTool(vector_store_ids=vector_store_ids)
286316

287317
@staticmethod
@@ -293,6 +323,10 @@ def get_web_search_tool(
293323
) -> BingGroundingTool | BingCustomSearchTool:
294324
"""Create a web search tool configuration for Azure AI Agents.
295325
326+
.. deprecated::
327+
This method is deprecated and will be removed in a future release.
328+
Use :meth:`AzureAIClient.get_web_search_tool` instead.
329+
296330
For Azure AI Agents, web search uses Bing Grounding or Bing Custom Search.
297331
If no arguments are provided, attempts to read from environment variables.
298332
If no connection IDs are found, raises ValueError.
@@ -333,6 +367,12 @@ def get_web_search_tool(
333367
334368
agent = ChatAgent(client, tools=[tool])
335369
"""
370+
warnings.warn(
371+
"AzureAIAgentClient.get_web_search_tool() is deprecated and will be removed in a future release; "
372+
"use AzureAIClient.get_web_search_tool() instead.",
373+
DeprecationWarning,
374+
stacklevel=2,
375+
)
336376
# Try explicit Bing Custom Search parameters first, then environment variables
337377
resolved_custom_connection = bing_custom_connection_id or os.environ.get("BING_CUSTOM_CONNECTION_ID")
338378
resolved_custom_instance = bing_custom_instance_id or os.environ.get("BING_CUSTOM_INSTANCE_NAME")
@@ -368,6 +408,10 @@ def get_mcp_tool(
368408
) -> McpTool:
369409
"""Create a hosted MCP tool configuration for Azure AI Agents.
370410
411+
.. deprecated::
412+
This method is deprecated and will be removed in a future release.
413+
Use :meth:`AzureAIClient.get_mcp_tool` instead.
414+
371415
This configures an MCP (Model Context Protocol) server that will be called
372416
by Azure AI's service. The tools from this MCP server are executed remotely
373417
by Azure AI, not locally by your application.
@@ -400,6 +444,12 @@ def get_mcp_tool(
400444
)
401445
agent = ChatAgent(client, tools=[tool])
402446
"""
447+
warnings.warn(
448+
"AzureAIAgentClient.get_mcp_tool() is deprecated and will be removed in a future release; "
449+
"use AzureAIClient.get_mcp_tool() instead.",
450+
DeprecationWarning,
451+
stacklevel=2,
452+
)
403453
mcp_tool = McpTool(
404454
server_label=name.replace(" ", "_"),
405455
server_url=url or "",
@@ -511,6 +561,12 @@ class MyOptions(AzureAIAgentOptions, total=False):
511561
client: AzureAIAgentClient[MyOptions] = AzureAIAgentClient(credential=credential)
512562
response = await client.get_response("Hello", options={"my_custom_option": "value"})
513563
"""
564+
warnings.warn(
565+
"AzureAIAgentClient is deprecated and will be removed in a future release; "
566+
"use AzureAIClient instead for the V2 (Projects/Responses) API.",
567+
DeprecationWarning,
568+
stacklevel=2,
569+
)
514570
azure_ai_settings = load_settings(
515571
AzureAISettings,
516572
env_prefix="AZURE_AI_",

python/packages/azure-ai/agent_framework_azure_ai/_shared.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import logging
66
import sys
7+
import warnings
78
from collections.abc import Mapping, MutableMapping, Sequence
89
from typing import Any, cast
910

@@ -158,6 +159,10 @@ def to_azure_ai_agent_tools(
158159
) -> list[ToolDefinition | dict[str, Any]]:
159160
"""Convert Agent Framework tools to Azure AI V1 SDK tool definitions.
160161
162+
.. deprecated::
163+
This function is deprecated and will be removed in a future release.
164+
Use :func:`to_azure_ai_tools` instead for the V2 (Projects/Responses) API.
165+
161166
Handles FunctionTool instances and dict-based tools from static factory methods.
162167
163168
Args:
@@ -170,6 +175,12 @@ def to_azure_ai_agent_tools(
170175
Raises:
171176
ValueError: If tool configuration is invalid.
172177
"""
178+
warnings.warn(
179+
"to_azure_ai_agent_tools() is deprecated and will be removed in a future release; "
180+
"use to_azure_ai_tools() instead for the V2 (Projects/Responses) API.",
181+
DeprecationWarning,
182+
stacklevel=2,
183+
)
173184
if not tools:
174185
return []
175186

@@ -208,12 +219,22 @@ def from_azure_ai_agent_tools(
208219
) -> list[dict[str, Any]]:
209220
"""Convert Azure AI V1 SDK tool definitions to dict-based tools.
210221
222+
.. deprecated::
223+
This function is deprecated and will be removed in a future release.
224+
Use :func:`from_azure_ai_tools` instead for the V2 (Projects/Responses) API.
225+
211226
Args:
212227
tools: Sequence of Azure AI V1 SDK tool definitions.
213228
214229
Returns:
215230
List of dict-based tool definitions.
216231
"""
232+
warnings.warn(
233+
"from_azure_ai_agent_tools() is deprecated and will be removed in a future release; "
234+
"use from_azure_ai_tools() instead for the V2 (Projects/Responses) API.",
235+
DeprecationWarning,
236+
stacklevel=2,
237+
)
217238
if not tools:
218239
return []
219240

0 commit comments

Comments
 (0)