Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions python/packages/core/agent_framework/azure/_chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
9 changes: 9 additions & 0 deletions python/packages/core/tests/azure/test_azure_chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()