Skip to content

.NET: Python: [Feature Branch] Azure AI Responses client - #1854

Closed
Dmytro Struk (dmytrostruk) wants to merge 38 commits into
microsoft:python-feature-foundry-agentsfrom
dmytrostruk:python-foundry-agents
Closed

.NET: Python: [Feature Branch] Azure AI Responses client#1854
Dmytro Struk (dmytrostruk) wants to merge 38 commits into
microsoft:python-feature-foundry-agentsfrom
dmytrostruk:python-foundry-agents

Conversation

@dmytrostruk

Copy link
Copy Markdown
Member

Motivation and Context

Implemented Azure AI responses client with initial basic and thread management examples.

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.

Comment and nullable type alignment
* Move packages
* Update nuget.config
* Address Xmldoc
* Remove format from branches checks
* Address Xmldocs
* Add more details to the implementation
* Moving Agent logic to ChatClient
* Adding Name and Id overrides to AzureAIAgent
* Updating extensions
* Add GetAiAgent extensions
* Adding support for version as name can conflict 409 using the Agents API with same name
* Addressing more updates to the extensions
* More improvements
* Remove debugging code from sample
* Address copilot feedback
* Apply suggestions from co-pilot code review
Fix package version rollback:
Azure.AI.Agents.Persistent (beta-6 => beta-7)
…nts extension methods (#1786)
* Initial plan
* Add comprehensive unit test project for Microsoft.Agents.AI.AzureAIAgents
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
* Add README documenting test project and package dependency requirements
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
* Fix documentation URL to use learn.microsoft.com
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
* Bump back AAAP 1.2.0-beta.7
* Address AI generated UT's
* Remove UT Readme
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ecific extensions (#1812)
* Remove unneeded model from extensions
* Add noop justification
CopilotAI review requested due to automatic review settings November 2, 2025 00:58
@dmytrostrukDmytro Struk (dmytrostruk) added the python Usage: [Issues, PRs], Target: Python label Nov 2, 2025

CopilotAI 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.

Pull Request Overview

This PR introduces a new AzureAIAgentClientV2 class that uses the OpenAI Responses API (instead of the Azure AI Agents API), migrates AzureAIAgentClient from using AIProjectClient to AgentsClient, and adds sample code demonstrating thread management with the new V2 client. Several test files and configurations were updated to reflect the refactoring.

Key Changes

  • Added AzureAIAgentClientV2 using OpenAI Responses API for Azure AI integration
  • Refactored AzureAIAgentClient to use AgentsClient instead of AIProjectClient
  • Removed connection resolution logic that required HTTP calls to get connection IDs
  • Added sample files demonstrating V2 client usage with thread management

Reviewed Changes

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

Show a summary per file
FileDescription
python/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.pyNew V2 client implementation using OpenAI Responses API
python/packages/azure-ai/agent_framework_azure_ai/_chat_client.pyRefactored to use AgentsClient instead of AIProjectClient and simplified Bing connection handling
python/packages/core/agent_framework/openai/_responses_client.pyMade client initialization async-friendly and refactored option preparation
python/packages/core/agent_framework/openai/_shared.pyMade OpenAI client optional and added async initialization methods
python/samples/getting_started/agents/azure_ai_v2/*.pyNew sample files demonstrating V2 client usage
python/packages/azure-ai/tests/test_azure_ai_agent_client*.pyUpdated tests to reflect API changes
python/packages/azure-ai/tests/conftest.pyUpdated fixture from mock_ai_project_client to mock_agents_client
python/.pre-commit-config.yamlCommented out several pre-commit hooks temporarily

Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client.py Outdated
Comment threadpython/.pre-commit-config.yaml
Comment threadpython/packages/core/agent_framework/openai/_shared.py Outdated
@Zochory

Copy link
Copy Markdown

Hello a small feedback to maybe avoid confusion, in the title it is mention Azure AI Response Client, but in the PR, there is for example a "AzureAIAgentClientV2". that is added, which can be confusing due to the different type of API/SDK ;
-Azure AI Agents SDKs,

  • Foundry Agent Service and the
    -Azure OpenAI Response Format

If we stick to the documentation , it recommends using the OpenAI() client with the responses.create() endpoint for stateful interaction and thread management.
https://learn.microsoft.com/en-us/azure/ai-foundry/openai/api-version-lifecycle?tabs=python#api-evolution

Also worth mentionning :
_Microsoft Entra ID:

Important

Handling automatic token refresh was previously handled through use of the AzureOpenAI() client. The v1 API removes this dependency, by adding automatic token refresh support to the OpenAI() client._

https://learn.microsoft.com/en-us/azure/ai-foundry/openai/api-version-lifecycle?tabs=python#api-evolution

other ressources :

Azure AI Agent Client (Python) : https://learn.microsoft.com/en-us/python/api/overview/azure/ai-agents-readme?view=azure-python-preview&preserve-view=true

Azure OpenAI Response API v1 GA -
https://learn.microsoft.com/en-us/azure/ai-foundry/openai/latest#create-response

Azure OpenAI v1 REST API : https://learn.microsoft.com/en-us/azure/ai-foundry/openai/latest

OpenAPI v1 https://github.com/Azure/azure-rest-api-specs/blob/main/specification/ai/data-plane/OpenAI.v1/azure-v1-v1-generated.json

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't fully understand the changes for the v1 client, the v2 client looks good overall, added some comments

Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
Comment threadpython/packages/core/agent_framework/openai/_responses_client.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
CopilotAI review requested due to automatic review settings November 4, 2025 01:13

CopilotAI 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.

Pull Request Overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Comment threadpython/packages/core/agent_framework/openai/_shared.py Outdated
Comment threadpython/packages/core/agent_framework/openai/_shared.py Outdated
Comment threadpython/packages/core/agent_framework/openai/_responses_client.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
Comment threadpython/packages/azure-ai/agent_framework_azure_ai/_chat_client_v2.py Outdated
@Zochory

Copy link
Copy Markdown

I mean the official terminology is v1 for the APIs Azure OpenAI but not only, also for the Foundry AI Agents in the microsoft documentation, might be kind of confusing to provide in agent-framework an azure ai client v2 imho

Also the Response API (OpenAI Response format) is for now in Azure, only for the Azure OpenAI models, having a microsoft entra id auth as example that would use from openai import OpenAI seems simplier and fully in accordance with potential future changes in azure openai

image

also the agent-framework-core -mem0 -azure-ai-evaluation are already install a openai

https://learn.microsoft.com/en-us/azure/ai-foundry/openai/latest

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings November 4, 2025 19:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…_v2.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…_v2.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…_v2.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

CopilotAI 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.

Pull Request Overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Comment threadpython/.pre-commit-config.yaml
@dmytrostruk

Copy link
Copy Markdown
MemberAuthor

might be kind of confusing to provide in agent-framework an azure ai client v2 imho

Zachary BENSALEM (@Zochory) Sorry, I'm not sure I understand your comment, but current naming is temporary.

@dmytrostruk
Dmytro Struk (dmytrostruk) changed the base branch from feature-foundry-agents to python-feature-foundry-agentsNovember 4, 2025 19:28
@markwallace-microsoftMark Wallace (markwallace-microsoft) added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Nov 4, 2025
@github-actionsgithub-actionsBot changed the title Python: [Feature Branch] Azure AI Responses client.NET: Python: [Feature Branch] Azure AI Responses clientNov 4, 2025
@dmytrostruk

Copy link
Copy Markdown
MemberAuthor

I would like to change base branch to keep Python and .NET changes independently, so will create another PR.

@Zochory

Copy link
Copy Markdown

might be kind of confusing to provide in agent-framework an azure ai client v2 imho

Zachary BENSALEM (@Zochory) Sorry, I'm not sure I understand your comment, but current naming is temporary.

If I understand correctly, the purpose of this PR is to add an OpenAI Response API client supporting both Azure OpenAI and Foundry Agent, correct?
The _chat_response_v2.py file appears to use OpenAIResponse with the OpenAI SDK. I believe similar functionality is already available in the repository (for example, in azure_responses_client_basic.py and the openai_response_client).

Additionally, this format is not used in the same way as the Azure AI Agents or the current implementation.
If I haven't missed anything, it seems that azure.identity is not utilized here—instead, it uses from azure.core.credentials_async import AsyncTokenCredential.

For further information, see:
Azure OpenAI Responses Agent User Guide

Foundry Models Responses Agent User Guide

the other links above

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

Labels

documentationUsage: [Issues, PRs], Target: documentation in the code base and learn docs.NETUsage: [Issues, PRs], Target: .NetpythonUsage: [Issues, PRs], Target: PythonworkflowsUsage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@dmytrostruk@Zochory@eavanvalkenburg@markwallace-microsoft@rogerbarreto@crickman