feat: add Responses API support for Azure OpenAI provider#4977
Closed
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Closed
feat: add Responses API support for Azure OpenAI provider#4977devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
When api='responses' is specified for Azure, creates an internal OpenAICompletion instance configured with AzureOpenAI/AsyncAzureOpenAI clients from the openai Python SDK, which natively supports the Responses API on Azure. Key changes: - Extended AzureCompletion.__init__() with Responses API parameters (api, instructions, store, previous_response_id, include, builtin_tools, parse_tool_outputs, auto_chain, auto_chain_reasoning, seed, reasoning_effort, max_completion_tokens) - Added _init_responses_delegate() method using composition/delegation - Added delegation logic in call() and acall() methods - Added pass-through properties: last_response_id, last_reasoning_items - Added pass-through methods: reset_chain(), reset_reasoning_chain() - Preserved base endpoint before validation for Azure client config - Interceptors now allowed in responses mode (via OpenAI SDK) - Added AZURE_RESPONSES_API_VERSION constant (2025-03-01-preview) - Added 30+ comprehensive tests covering all new functionality Closes #4974 Co-Authored-By: João <joao@crewai.com>
Contributor
Author
|
Prompt hidden (unlisted session) |
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| with patch.object( | ||
| llm._responses_delegate, "call", return_value='{"temperature": 72.0, "condition": "sunny"}' | ||
| ) as mock_call: | ||
| result = llm.call( |
Contributor
|
Duplicate of #5201. Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #4974. Adds native Responses API support to
AzureCompletionusing a composition/delegation pattern: whenapi="responses"is specified, an internalOpenAICompletioninstance is created and its clients are replaced withAzureOpenAI/AsyncAzureOpenAIfrom theopenaiSDK (which natively supports the Responses API on Azure). All Responses API calls are then delegated to this internal instance.This avoids reimplementing all Responses API logic (tool format conversion, structured output, auto-chaining, reasoning items, streaming, etc.) and reuses the existing
OpenAICompletionimplementation.Key changes to
AzureCompletion:__init__parameters:api,instructions,store,previous_response_id,include,builtin_tools,parse_tool_outputs,auto_chain,auto_chain_reasoning,seed,reasoning_effort,max_completion_tokens_init_responses_delegate()createsOpenAICompletionand swaps inAzureOpenAI/AsyncAzureOpenAIclientscall()/acall()delegate to the internal instance whenapi="responses"last_response_id,last_reasoning_itemsreset_chain(),reset_reasoning_chain()AZURE_RESPONSES_API_VERSION = "2025-03-01-preview"defaultReview & Testing Checklist for Human
self.client/self.async_clientnot set in responses mode: Whenapi="responses", the Azure AI InferenceChatCompletionsClientis never created. Verify that no code path (e.g.,supports_function_calling(),aclose(),supports_stop_words(), event emission, orBaseLLMbase class) accessesself.clienton a responses-mode instance — this would raiseAttributeError.OpenAICompletion(creating defaultOpenAI/AsyncOpenAIclients), then its.clientand.async_clientare immediately replaced withAzureOpenAIinstances. ConfirmOpenAICompletion.__init__doesn't perform any network calls or store client references elsewhere that would bypass this swap.is_azure_openai_endpointisFalsein responses mode: Sinceself.endpointis the raw base URL (e.g.,https://test.openai.azure.comwithout/openai/deployments/), theis_azure_openai_endpointflag will beFalse. Verify this doesn't breaksupports_stop_words(),get_context_window_size(), or_prepare_completion_params()behavior for responses-mode instances.call()/acall(), the delegation to the responses delegate happens before thetry/exceptblock andllm_call_context(). Errors from the delegate won't go through_handle_api_erroror emitcall_failedevents. Consider whether this is acceptable.api="responses"to confirm the delegation actually produces correct Responses API calls over the wire.Notes
uv.lockfile was not modified (it was temporarily regenerated locally for test runs but reverted before commit).self.endpoint→self.base_endpointrename preserves backward compat by still settingself.endpoint— but the initialization order changed, which is worth a quick check.Link to Devin session: https://app.devin.ai/sessions/01c25abb1a1849918399731940f82443