Add fallback to default chat client for unconfigured workspaces#24717
Merged
Add fallback to default chat client for unconfigured workspaces#24717
Conversation
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.
Contributor
There was a problem hiding this comment.
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
approved these changes
Jan 23, 2026
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.
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:
Checklist
How to test it?