Summary
IChatClientProvider exposes IsAvailable specifically for providers that are registered but not currently usable, but the platform never checks that property. GetChatClientAsync() always calls CreateChatClientAsync(), so an unavailable provider still fails with an exception instead of behaving as unavailable.
Evidence
Q:\src\testfx\src\Platform\Microsoft.Testing.Platform.AI\IChatClientProvider.cs:15-18
Gets a value indicating whether the provider is available and can be used.
A provider may be registered but not available if required configuration ... is missing.
Q:\src\testfx\src\Platform\Microsoft.Testing.Platform\AI\ChatClientManager.cs:28-33
if (_chatClientProviderFactory is not null)
serviceProvider.AddService(_chatClientProviderFactory(serviceProvider));
Q:\src\testfx\src\Platform\Microsoft.Testing.Platform.AI\ChatClientProviderExtensions.cs:37-42
var provider = (IChatClientProvider?)serviceProvider.GetService(typeof(IChatClientProvider));
: await provider.CreateChatClientAsync(cancellationToken).ConfigureAwait(false);
Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.AzureFoundry\OpenAIChatClientProvider.cs:21-24
public bool IsAvailable => ... AZURE_OPENAI_ENDPOINT ... AZURE_OPENAI_DEPLOYMENT_NAME ... AZURE_OPENAI_API_KEY
Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.AzureFoundry\OpenAIChatClientProvider.cs:39-51
- missing variables cause
throw new InvalidOperationException(...)
Why this is a real issue
The API contract says providers can be present but unavailable. In practice, registering such a provider changes GetChatClientAsync() from returning null (no provider) to throwing InvalidOperationException (provider present but unusable). Consumers cannot safely treat IsAvailable as the intended availability gate because the platform ignores it.
Suggested resolution
Respect IsAvailable either during provider registration or inside GetChatClientAsync(). Returning null (or a dedicated unavailable result) would make the abstraction behave as documented, while still allowing callers to inspect provider metadata separately if needed.
Related issues
Summary
IChatClientProviderexposesIsAvailablespecifically for providers that are registered but not currently usable, but the platform never checks that property.GetChatClientAsync()always callsCreateChatClientAsync(), so an unavailable provider still fails with an exception instead of behaving as unavailable.Evidence
Q:\src\testfx\src\Platform\Microsoft.Testing.Platform.AI\IChatClientProvider.cs:15-18Gets a value indicating whether the provider is available and can be used.A provider may be registered but not available if required configuration ... is missing.Q:\src\testfx\src\Platform\Microsoft.Testing.Platform\AI\ChatClientManager.cs:28-33if (_chatClientProviderFactory is not null)serviceProvider.AddService(_chatClientProviderFactory(serviceProvider));Q:\src\testfx\src\Platform\Microsoft.Testing.Platform.AI\ChatClientProviderExtensions.cs:37-42var provider = (IChatClientProvider?)serviceProvider.GetService(typeof(IChatClientProvider));: await provider.CreateChatClientAsync(cancellationToken).ConfigureAwait(false);Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.AzureFoundry\OpenAIChatClientProvider.cs:21-24public bool IsAvailable => ... AZURE_OPENAI_ENDPOINT ... AZURE_OPENAI_DEPLOYMENT_NAME ... AZURE_OPENAI_API_KEYQ:\src\testfx\src\Platform\Microsoft.Testing.Extensions.AzureFoundry\OpenAIChatClientProvider.cs:39-51throw new InvalidOperationException(...)Why this is a real issue
The API contract says providers can be present but unavailable. In practice, registering such a provider changes
GetChatClientAsync()from returningnull(no provider) to throwingInvalidOperationException(provider present but unusable). Consumers cannot safely treatIsAvailableas the intended availability gate because the platform ignores it.Suggested resolution
Respect
IsAvailableeither during provider registration or insideGetChatClientAsync(). Returningnull(or a dedicated unavailable result) would make the abstraction behave as documented, while still allowing callers to inspect provider metadata separately if needed.Related issues