Skip to content

fix(agent): detect modern services.ai.azure.com in _is_azure_openai_url()#47672

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/azure-openai-url-detection
Closed

fix(agent): detect modern services.ai.azure.com in _is_azure_openai_url()#47672
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/azure-openai-url-detection

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Extends _is_azure_openai_url() to detect modern Azure OpenAI endpoints (*.services.ai.azure.com) in addition to the legacy *.openai.azure.com pattern. This ensures Azure-specific routing works correctly for post-2024 Azure OpenAI resources.

Related Issue

Fixes #47666

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • run_agent.py: Extended _is_azure_openai_url() substring check to also match ai.azure.com, covering modern *.services.ai.azure.com endpoints. Updated docstring to document both URL patterns.
  • tests/run_agent/test_run_agent.py: Added assertions for *.services.ai.azure.com URLs in test_is_azure_openai_url_detection.

How to Test

  1. Run pytest tests/run_agent/test_run_agent.py::TestGpt5ApiModeRouting -xvs — all 4 tests should pass
  2. Verify the new assertions: services.ai.azure.com URLs return True, legacy openai.azure.com still works, and non-Azure URLs still return False

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Code Intelligence

  • Analyzed: _is_azure_openai_url (callers: 3 — run_agent.py:1272, agent_init.py:385, chat_completion_helpers.py:1145)
  • Blast radius: LOW — substring match is additive, no existing URLs are affected
  • Related patterns: Azure URL detection used in gpt-5.x API mode routing (TestGpt5ApiModeRouting)

…rl()

Modern Azure OpenAI resources (post-2024) use
`{resource}.services.ai.azure.com` instead of the legacy
`{resource}.openai.azure.com`. The substring check missed these
endpoints, causing Azure-specific routing to fail for gpt-5.x models
served without the `/v1/` prefix.

Extend the detection to also match `ai.azure.com` and update the
docstring to document both URL patterns.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/openai OpenAI / Codex Responses API P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 17, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #47668 — identical fix (extend _is_azure_openai_url() to match ai.azure.com for modern *.services.ai.azure.com resources, same run_agent.py change and test file). #47668 was opened slightly earlier; consolidating there. Both close #47666.

@liuhao1024

Copy link
Copy Markdown
Contributor Author

Closing in favor of #47668 — same fix ("ai.azure.com" in url in _is_azure_openai_url()), but #47668 was created 2 minutes earlier and has broader test coverage (includes eastus.api.ai.azure.com pattern and instance-level detection test).

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: _is_azure_openai_url() doesn't detect modern services.ai.azure.com URLs

2 participants