Skip to content

Review all IChatClient implementations for thread-safety and suitability as singleton #5499

@SteveSandersonMS

Description

@SteveSandersonMS

As per dotnet/aspire#6225, there's an argument that the ecosystem will be more understandable if IChatClient implementations are expected to be singleton and thread-safe.

We need to check whether that's already the case for all the leaf clients and middleware in this repo, and whether it will cause any issues with SK integration etc.

I know this creates a limitation that none of them could depend on scoped services. If that turns out to be a blocker we may be forced to reconsider. But right now I don't have a concrete scenario in mind where a scoped service would be strictly needed. The closest I can think of is if you want to depend on an HttpClient that is preconfigured with a delegating handler with auth tokens from your current DI scope. While that does seem like it would be a problem, presumably it would already be a problem when using Aspire's OpenAI integration regardless of this, so maybe people don't need to do that.

Metadata

Metadata

Assignees

Labels

area-aiMicrosoft.Extensions.AI librariesbugThis issue describes a behavior which is not expected - a bug.work in progress 🚧

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions