Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Motivation and Context

AzureOpenAIResponsesClient only supported direct Azure OpenAI endpoint configuration. Users working with Azure AI Foundry projects had no way to create a responses client from a project endpoint or AIProjectClient, unlike AzureAIClient which already supports this.

Description

Adds project_client and project_endpoint parameters to AzureOpenAIResponsesClient, enabling client creation via Azure AI Foundry projects.

  • project_client: Pass an existing AIProjectClient directly
  • project_endpoint + credential: Auto-creates an AIProjectClient from the endpoint
  • Both paths call project_client.get_openai_client() to obtain the AsyncOpenAI client, which is then passed through the existing async_client code path
  • azure-ai-projects is lazily imported — no new hard dependency on the core package
from azure.identity import DefaultAzureCredential
from agent_framework.azure import AzureOpenAIResponsesClient

# From project endpoint
client = AzureOpenAIResponsesClient(
    project_endpoint="https://your-project.services.ai.azure.com",
    deployment_name="gpt-4o",
    credential=DefaultAzureCredential(),
)

# Or from an existing AIProjectClient
from azure.ai.projects.aio import AIProjectClient

project_client = AIProjectClient(
    endpoint="https://your-project.services.ai.azure.com",
    credential=DefaultAzureCredential(),
)
client = AzureOpenAIResponsesClient(
    project_client=project_client,
    deployment_name="gpt-4o",
)

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.
Original prompt

This section details on the original issue you should resolve

<issue_title>Python: [Feature]: Python: allow AzureOpenAIResponseClient creation with foundry project endpoint</issue_title>
<issue_description>### Description

We need to extend the AzureOpenAIResponseClient constructor to allow a project client or endpoint, which is then used to create the async openai client

Code Sample

Language/SDK

Python</issue_description>

<agent_instructions>Take the existing AzureOpenAIResponseClient, extend it with a similar set of parameters as the AzureAIClient to allow a second set of parameters to work, which is creating a azure.ai.projects.aio client, and then calling the get_openai_client method on that. This might not be needed directly, could be done through the _ensure_client feature of our OpenAI stack</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Extend AzureOpenAIResponseClient for project endpoint support Python: Allow AzureOpenAIResponsesClient creation with Foundry project endpoint Feb 10, 2026
@eavanvalkenburg eavanvalkenburg marked this pull request as ready for review February 10, 2026 19:50
Copilot AI review requested due to automatic review settings February 10, 2026 19:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for constructing AzureOpenAIResponsesClient via an Azure AI Foundry project (AIProjectClient or project endpoint), aligning it with existing Foundry-enabled client creation patterns elsewhere in the repo.

Changes:

  • Added project_client / project_endpoint constructor parameters to AzureOpenAIResponsesClient and a helper to create an OpenAI client via Foundry projects.
  • Added unit tests covering initialization via project client/endpoint and basic parameter validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
python/packages/core/agent_framework/azure/_responses_client.py Adds Foundry project-based client creation path and wiring into constructor.
python/packages/core/tests/azure/test_azure_responses_client.py Adds tests for new constructor parameters and _create_client_from_project behavior.

auto-merge was automatically disabled February 10, 2026 21:25

Pull request was closed

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 10, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/azure
   _responses_client.py53688%188, 220, 288–291
   _shared.py81791%138–139, 202, 205, 218, 220, 230
packages/core/agent_framework/openai
   _responses_client.py6118086%292–295, 299–300, 303–304, 310–311, 316, 329–335, 356, 364, 387, 550, 553, 608, 612, 614, 616, 618, 694, 704, 709, 752, 811, 825, 842, 855, 911, 996, 1001, 1005–1007, 1011–1012, 1035, 1104, 1126–1127, 1142–1143, 1161–1162, 1293–1294, 1310, 1312, 1391–1399, 1494, 1549, 1564, 1600–1601, 1603–1605, 1619–1621, 1631–1632, 1638, 1653
TOTAL16809211087% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4012 225 💤 0 ❌ 0 🔥 1m 8s ⏱️

@moonbox3
Copy link
Contributor

@eavanvalkenburg do you want to address any of Copilot's feedback?

@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Feb 11, 2026
Copilot AI and others added 5 commits February 11, 2026 14:39
…dpoints

Add project_client and project_endpoint parameters to allow creating
the client via an Azure AI Foundry project. When provided, the client
uses AIProjectClient.get_openai_client() to obtain the OpenAI client.
The azure-ai-projects package is imported lazily and only required
when using the project endpoint path.

Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
- Add 'type: message' to input items in _prepare_message_for_openai
  to comply with the Responses API schema requirement
- Filter out empty dicts from unsupported content types to prevent
  sending items with invalid empty type values
- Add azure_responses_client_with_foundry.py sample demonstrating
  AzureOpenAIResponsesClient with project_endpoint
- Update README and pyrightconfig.samples.json accordingly
@eavanvalkenburg eavanvalkenburg force-pushed the copilot/extend-azure-openai-response-client branch from 94b8c3c to 3f523ae Compare February 11, 2026 13:41
Patch agent_framework.azure._responses_client.AIProjectClient instead of
azure.ai.projects.aio.AIProjectClient since the import is at module level.
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit a427af9 Feb 11, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Feature]: Python: allow AzureOpenAIResponseClient creation with foundry project endpoint

6 participants