Skip to content

Add fallback to default chat client for unconfigured workspaces#24717

Merged
EngincanV merged 2 commits intorel-10.1from
10.1-chatclient-fallback
Jan 23, 2026
Merged

Add fallback to default chat client for unconfigured workspaces#24717
EngincanV merged 2 commits intorel-10.1from
10.1-chatclient-fallback

Conversation

@enisn
Copy link
Member

@enisn enisn commented Jan 23, 2026

Updated ChatClientAccessor and TypedChatClient to fallback to the default chat client if a workspace-specific client is not configured. Adjusted tests to verify that the default chat client is resolved for non-configured workspaces.

With this PR, the following code will not throw dependency resolution exception, and resolve the default configuration if done:

var chatClient = serviceProvider.GetRequiredService<IChatClient<NonConfiguredWorkspace>>();

Checklist

  • I fully tested it as developer / designer and created unit / integration tests
  • I documented it (or no need to document or I will create a separate documentation issue)

How to test it?

  • Tests are added, just execute unit tests

enisn added 2 commits January 23, 2026 12:38
Updated ChatClientAccessor and TypedChatClient to fallback to the default chat client if a workspace-specific client is not configured. Adjusted tests to verify that the default chat client is resolved for non-configured workspaces.
@enisn enisn added this to the 10.1-final milestone Jan 23, 2026
@enisn enisn requested review from EngincanV and Copilot January 23, 2026 09:41
@enisn enisn changed the base branch from dev to rel-10.1 January 23, 2026 09:41
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 adds fallback logic to resolve the default chat client when accessing chat clients for unconfigured workspaces. Previously, attempting to resolve IChatClient<T> or IChatClientAccessor<T> for a workspace that wasn't explicitly configured would fail. With this change, the system automatically falls back to the default workspace configuration.

Changes:

  • Modified TypedChatClient<TWorkSpace> to attempt workspace-specific client resolution first, then fall back to default workspace client using null-coalescing operator
  • Modified ChatClientAccessor<TWorkSpace> to check if workspace-specific client is null and fall back to default workspace client
  • Updated test expectations to verify that non-configured workspaces now resolve to default chat client instead of null

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
framework/src/Volo.Abp.AI/Volo/Abp/AI/TypedChatClient.cs Changed from GetRequiredKeyedService to GetKeyedService with fallback to default workspace using null-coalescing operator
framework/src/Volo.Abp.AI/Volo/Abp/AI/ChatClientAccessor.cs Added null check with fallback to default workspace client when workspace-specific client is not configured
framework/test/Volo.Abp.AI.Tests/Volo/Abp/AI/ChatClientAccessor_Tests.cs Renamed test and updated assertions to expect non-null chat client; added new test for IChatClient resolution

@EngincanV EngincanV merged commit a39ab2e into rel-10.1 Jan 23, 2026
8 of 9 checks passed
@EngincanV EngincanV deleted the 10.1-chatclient-fallback branch January 23, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants