Skip to content

Python: fix: Remove await from synchronous get_openai_client call in AzureAIC…#2349

Closed
q33566 wants to merge 2 commits intomicrosoft:mainfrom
q33566:fix/azure-ai-client-await
Closed

Python: fix: Remove await from synchronous get_openai_client call in AzureAIC…#2349
q33566 wants to merge 2 commits intomicrosoft:mainfrom
q33566:fix/azure-ai-client-await

Conversation

@q33566
Copy link
Contributor

@q33566 q33566 commented Nov 20, 2025

…lient

The get_openai_client method is synchronous. Awaiting it caused a TypeError.

resolve #2338

Result

Before the fix

  • Running samples/getting_started/agents/azure_ai/azure_ai_basic.py got type error.

After the fix

  • Running samples/getting_started/agents/azure_ai/azure_ai_basic.py got correct result.

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.

…lient

The  method in  is synchronous. Awaiting it caused a TypeError.
Copilot AI review requested due to automatic review settings November 20, 2025 13:42
@github-actions github-actions bot changed the title fix: Remove await from synchronous get_openai_client call in AzureAIC… Python: fix: Remove await from synchronous get_openai_client call in AzureAIC… Nov 20, 2025
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

This PR fixes a TypeError caused by incorrectly awaiting a synchronous method call. The get_openai_client() method from AIProjectClient is synchronous, but was being called with await, causing a runtime error.

Key Changes:

  • Removed await keyword from self.project_client.get_openai_client() call in the initialize_client() method

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

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

This also requires a minimum version of the aiprojectclient dependency, please update that as well

@q33566
Copy link
Contributor Author

q33566 commented Nov 20, 2025

This also requires a minimum version of the aiprojectclient dependency, please update that as well

Got it. I have added the minimum version requirement to pyproject.toml.

release azure-ai-projects_2.0.0b2 describe this as a breking change.

get_openai_client() method on the asynchronous AIProjectClient is no longer an "async" method.

@dmytrostruk
Copy link
Member

Let me fix the tests quickly; we need to merge this as soon as possible.

@dmytrostruk
Copy link
Member

@q33566 Thanks for your contribution. I fixed the tests and updated the dependency in correct place in the following PR: #2358. I will close this PR to proceed with another one. Thanks again!

auto-merge was automatically disabled November 20, 2025 20:11

Pull request was closed

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

Labels

Projects

None yet

6 participants