Repository navigation
feat: allow history restore with Spring AI ChatClient (#9972) (CP: 25.3) - #9994
Merged
Merged
Conversation
## Description The `ChatClient` constructor exists for applications that need more control than the `ChatModel` one gives — their own chat memory, advisors, or model configuration. Restoring a saved conversation was refused on exactly that path, so an application could have its own client or its conversation history, but not both. - `SpringAILLMProvider.setHistory(List, Map)` no longer throws `UnsupportedOperationException` when the provider was created with the `ChatClient` constructor. The application owns the chat memory on that path and loads it before passing the client in, so the call returns instead of aborting. - Previously the throw failed `AIOrchestrator.Builder.withHistory(List, Map)` and `reconnect(LLMProvider)` outright, so the message list, the attachment id mappings and the `getHistory()` snapshot were left unrestored as well — none of which depend on the provider. - Added a warning when the given `ChatClient` cannot hold the conversation being restored: either it carries no chat memory advisor, or its memory advisor has no default `ChatMemory.CONVERSATION_ID` parameter, which makes every prompt fail inside the advisor. - Read through `ChatClient.prompt()` and the public getters on `DefaultChatClientRequestSpec`; a client that is not Spring AI's own implementation is left alone, since it may carry the conversation its own way. - Corrected the `withHistory`, `reconnect` and `Reconnector.apply` Javadoc, which stated that conversation history is always replayed onto the new provider. - Added tests for the no-op restore, a preloaded `ChatMemory` reaching the model, both warnings, the uninspectable-client branch, and that neither warning falls through into a second log line. ## Type of change - Feature/bugfix --------- Co-authored-by: Claude <noreply@anthropic.com>
tomivirkki
approved these changes
Aug 31, 2026
|
Collaborator
Author
|
This ticket/PR has been released with Vaadin 25.3.0. |
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.



This PR cherry-picks changes from the original PR #9972 to branch 25.3.
Original PR description