Python: Fix web_search_options sent to Azure OpenAI Chat Completions API (issue #3629)#6225
Python: Fix web_search_options sent to Azure OpenAI Chat Completions API (issue #3629)#6225Oxygen56 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Azure-specific handling for web search tools in the Chat Completions client, preventing unsupported parameters from being sent when using an Azure endpoint.
Changes:
- Persist
use_azure_clientconfiguration on the instance for later branching. - Update tool preparation to ignore
web_searchtools when configured for Azure, and log a warning. - Add a docstring note describing Azure Chat Completions limitations around web search.
|
@microsoft-github-policy-service agree |
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
7e71818 to
af5076b
Compare
|
Addressed Copilot review feedback:
Ready for re-review. |
af5076b to
8b0759f
Compare
Azure OpenAI Chat Completions API does not support the web_search_options parameter. Sending it results in a 400 error: 'Unknown parameter: web_search_options'. This fix: - Stores the use_azure_client flag during initialization - In _prepare_tools_for_openai, skips web search tools when the client is Azure-based, logging a warning that guides users to the Responses API (OpenAIChatClient) for web search support on Azure Closes microsoft#3629 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
8b0759f to
b3cc4e4
Compare
Address review feedback: silent logger.warning was too easy to miss. Raising ValueError ensures callers know immediately that web search is incompatible with Azure Chat Completions and directs them to the Responses API alternative. - Changed logger.warning to ValueError in _prepare_tools_for_openai - Added test_prepare_tools_with_web_search_on_azure_raises - Added test_prepare_tools_with_web_search_on_openai_allowed
b3cc4e4 to
3dbe723
Compare
|
Thanks for the review approval @eavanvalkenburg! It looks like the CI workflows need manual approval to run on this fork PR — all 6 critical checks (Python tests, code quality, merge gatekeeper, etc.) are stuck in The CI run page should be here: https://github.com/microsoft/agent-framework/actions?query=branch%3Afix%2Fazure-web-search-options |
Summary
Azure OpenAI Chat Completions API does not support the
web_search_optionsparameter. Sending it results in a400error:This PR fixes the issue by storing the Azure client flag and skipping web search tools when configured with Azure OpenAI.
Changes
_use_azure_clientflag inRawOpenAIChatCompletionClient.__init__so downstream methods can check whether the client is Azure-based_prepare_tools_for_openai: when the client is Azure-based, web search tools are silently excluded with a warning guiding users to useOpenAIChatClient(Responses API) insteadBefore
After
Alternatives
For web search on Azure, use the Responses API via
OpenAIChatClient:Fixes #3629