Skip to content

Promote Azure served model header for Responses - #3545

Open
scarab-systems wants to merge 2 commits into
openai:mainfrom
scarab-systems:scarab-systems/azure-responses-served-model
Open

Promote Azure served model header for Responses#3545
scarab-systems wants to merge 2 commits into
openai:mainfrom
scarab-systems:scarab-systems/azure-responses-served-model

Conversation

@scarab-systems

Copy link
Copy Markdown

Fixes #3271.

Summary

  • promote non-empty Azure x-ms-served-model response headers into Responses API Response.model
  • apply the same value to streamed response events that carry event.response.model
  • keep the change scoped to Azure client response processing, without touching generated resource files

Testing

  • .venv/bin/pytest tests/lib/test_azure.py -q -o addopts=""
  • .venv/bin/ruff check src/openai/lib/azure.py tests/lib/test_azure.py
  • .venv/bin/ruff format --check src/openai/lib/azure.py tests/lib/test_azure.py
  • .venv/bin/pyright --pythonpath .venv/bin/python src/openai/lib/azure.py tests/lib/test_azure.py
  • .venv/bin/mypy src/openai/lib/azure.py
  • I understand that this repository is auto-generated and that my PR may not be merged

Promote non-empty x-ms-served-model values into Azure Responses model fields before response construction.

This keeps the behavior scoped to Azure clients and covers both parsed Responses objects and streamed response events without touching generated resource files.

Add sync and async Azure regression coverage for non-streaming and streaming Responses calls.
@scarab-systems
scarab-systems marked this pull request as ready for review July 28, 2026 19:06
@scarab-systems
scarab-systems requested a review from a team as a code owner July 28, 2026 19:06

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The production change is focused and behaves correctly in the exercised sync/async and streaming paths, but the test structure needs one cleanup before merge.

tests/lib/test_azure.py grows from 955 to 1,084 lines in this PR, crossing the 1k-line boundary, and the added 130 lines repeat nearly identical client/router setup across four tests. Please move this feature coverage into a focused module (for example, tests/lib/test_azure_responses.py) or collapse the duplication with shared fixtures/helpers so the existing catch-all file does not keep sprawling past 1k lines. This is a clear decomposition boundary and will also make the important absent/blank-header and non-Responses guards easier to cover without making the original file larger.

Validation on exact head d5a658b6125d5d877aaf04c9b6db72eae4255fcb: all 63 Azure tests passed; Ruff lint and format checks passed; Pyright passed; mypy passed; git diff --check passed.

Move Azure Responses served-model header coverage out of the catch-all Azure test module into a focused tests/lib/test_azure_responses.py module.

Keep tests/lib/test_azure.py below the 1k-line decomposition boundary and add focused guard coverage for absent or blank served-model headers and non-Responses resources.

Verification: .venv/bin/python -m pytest -o addopts= tests/lib/test_azure_responses.py tests/lib/test_azure.py -q; .venv/bin/ruff check src/openai/lib/azure.py tests/lib/test_azure.py tests/lib/test_azure_responses.py; .venv/bin/ruff format --check src/openai/lib/azure.py tests/lib/test_azure.py tests/lib/test_azure_responses.py; git diff --check; PATH=.venv/bin:/opt/homebrew/opt/python@3.13/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Library/Apple/usr/bin:/Users/BigMomma/.volta/bin:/Applications/Docker.app/Contents/Resources/bin:/Users/BigMomma/.codex/tmp/arg0/codex-arg0QOxwtR:/Users/BigMomma/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin/override:/Users/BigMomma/.cargo/bin:/Users/BigMomma/.lmstudio/bin:/Users/BigMomma/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin/fallback:/Applications/ChatGPT.app/Contents/Resources scripts/run-pyright; .venv/bin/mypy .
@scarab-systems

Copy link
Copy Markdown
Author

Addressed in the latest push (51de468).

I moved the Azure Responses served-model coverage out of tests/lib/test_azure.py and into a focused tests/lib/test_azure_responses.py module, so the catch-all Azure test file is back below the 1k-line boundary. I also added focused guard coverage for absent/blank x-ms-served-model headers and for non-Responses resources so the model replacement remains scoped to Azure Responses.

Local validation run:

  • .venv/bin/python -m pytest -o addopts= tests/lib/test_azure_responses.py tests/lib/test_azure.py -q
  • .venv/bin/ruff check src/openai/lib/azure.py tests/lib/test_azure.py tests/lib/test_azure_responses.py
  • .venv/bin/ruff format --check src/openai/lib/azure.py tests/lib/test_azure.py tests/lib/test_azure_responses.py
  • PATH=".venv/bin:$PATH" scripts/run-pyright
  • .venv/bin/mypy .
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AzureOpenAI/Foundry: promote x-ms-served-model header into Response.model for the Responses API (parity with OpenAI/Azure Chat Completions)

2 participants