Skip to content

Python: Add service_url to OpenAIChatClient - #9225

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
BichengWang:openai-responses-client-service-url
Oct 9, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
BichengWang:openai-responses-client-service-url

Conversation

@BichengWang

Copy link
Copy Markdown
Contributor

Motivation & Context

RawOpenAIChatClient (the Responses API client) does not override BaseChatClient.service_url(), so chat spans report server.address as Unknown. OpenAIChatCompletionClient and OpenAIEmbeddingClient already implement it.

Description & Review Guide

  • What are the major changes? RawOpenAIChatClient.service_url() returns str(self.client.base_url), the same implementation as RawOpenAIChatCompletionClient. One unit test added.
  • What is the impact of these changes? Spans from OpenAIChatClient now carry the real base URL. FoundryChatClient and the Foundry agent chat client inherit from this class, so their spans will show the project's OpenAI base URL instead of Unknown. Nothing else changes.
  • What do you want reviewers to focus on? Nothing specific.

Related Issue

Fixes #9224

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Return the underlying client's base URL from the Responses API client so
chat telemetry reports a real server.address instead of Unknown, matching
OpenAIChatCompletionClient and OpenAIEmbeddingClient.

Copilot AI 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.

🟢 Approval recommended

The implementation matches existing OpenAI client patterns and is covered by a focused unit test.

0 open findings

What changed in this PR

Adds service URL reporting to OpenAI Responses API clients so telemetry spans contain the configured base URL.

Changes:

  • Implements RawOpenAIChatClient.service_url().
  • Adds unit coverage for custom base URLs.
File Description
python/​packages/​openai/​agent_framework_openai/​_chat_client.py Returns the underlying OpenAI client base URL.
python/​packages/​openai/​tests/​openai/​test_openai_chat_client.py Verifies URL normalization and reporting.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@BichengWang

Copy link
Copy Markdown
Contributor Author

Hello members, is there any one can help additional review? Thank you!

Merged via the queue into microsoft:main with commit 524f79c Oct 9, 2026
53 of 54 checks passed
@BichengWang
Bicheng (Kenneth) (BichengWang) deleted the openai-responses-client-service-url branch October 9, 2026 17:57

This branch was successfully deployed

1 active deployment
github-app-auth — 61224cbe Deployed Oct 8, 2026 by BichengWang via team_check #6408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: OpenAIChatClient (Responses API) does not implement service_url(), so server.address is reported as Unknown

3 participants