diff --git a/python/packages/core/agent_framework/azure/_chat_client.py b/python/packages/core/agent_framework/azure/_chat_client.py index b4bd3659ed..f07254b489 100644 --- a/python/packages/core/agent_framework/azure/_chat_client.py +++ b/python/packages/core/agent_framework/azure/_chat_client.py @@ -282,6 +282,23 @@ class MyOptions(AzureOpenAIChatOptions, total=False): **kwargs, ) + @staticmethod + def get_web_search_tool( + *, + web_search_options: Any | None = None, + ) -> dict[str, Any]: + """Web search is not supported by Azure OpenAI's Chat Completions API. + + Use ``OpenAIChatClient`` or ``AzureOpenAIResponsesClient`` for web search support. + + Raises: + NotImplementedError: Always, since Azure OpenAI does not support web search. + """ + raise NotImplementedError( + "Web search is not supported by Azure OpenAI's Chat Completions API. " + "Use OpenAIChatClient or AzureOpenAIResponsesClient for web search support." + ) + @override def _parse_text_from_openai(self, choice: Choice | ChunkChoice) -> Content | None: """Parse the choice into a Content object with type='text'. diff --git a/python/packages/core/tests/azure/test_azure_chat_client.py b/python/packages/core/tests/azure/test_azure_chat_client.py index 3e88504493..aa1828f54d 100644 --- a/python/packages/core/tests/azure/test_azure_chat_client.py +++ b/python/packages/core/tests/azure/test_azure_chat_client.py @@ -884,3 +884,12 @@ async def test_azure_chat_client_agent_level_tool_persistence(): assert second_response.text is not None # Should use the agent-level weather tool again assert any(term in second_response.text.lower() for term in ["miami", "sunny", "72"]) + + +def test_get_web_search_tool_raises_not_implemented() -> None: + """Test that get_web_search_tool() raises NotImplementedError on Azure OpenAI. + + Regression test for: https://github.com/microsoft/agent-framework/issues/3629 + """ + with pytest.raises(NotImplementedError, match="not supported by Azure OpenAI"): + AzureOpenAIChatClient.get_web_search_tool()