Respect unavailable AI chat client providers#8453
Merged
Evangelink merged 3 commits intoMay 21, 2026
Merged
Conversation
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix IChatClientProvider.IsAvailable behavior during provider retrieval
Respect unavailable AI chat client providers
May 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Microsoft.Testing.Platform AI integration to honor IChatClientProvider.IsAvailable, ensuring that registered-but-unusable providers behave the same as “no provider registered” (i.e., GetChatClientAsync() returns null rather than attempting client creation and potentially throwing).
Changes:
- Gate
GetChatClientAsync()onIChatClientProvider.IsAvailableto returnnullwhen unavailable. - Add a unit test covering the “unavailable provider” scenario.
- Add a unit test project reference to
Microsoft.Testing.Platform.AIto enable compiling the new AI-related unit test.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/Microsoft.Testing.Platform.UnitTests.csproj | Adds a project reference to the AI project (with netstandard targeting for non-.NETCoreApp TFMs) so unit tests can compile against AI types. |
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/AI/ChatClientProviderExtensionsTests.cs | Introduces a regression test ensuring an unavailable provider results in null. |
| src/Platform/Microsoft.Testing.Platform.AI/ChatClientProviderExtensions.cs | Updates GetChatClientAsync() to return null when a provider exists but reports IsAvailable == false. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 2
Member
|
@copilot address review comments |
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IChatClientProvider.IsAvailabledocumented that providers can be registered but unusable, butGetChatClientAsync()ignored it and still invoked client creation. Unavailable providers could therefore throw instead of behaving like no usable provider exists.GetChatClientAsync()now returnsnullwhen the registered provider reportsIsAvailable == false.nulland does not callCreateChatClientAsync().