Repository navigation
Conversation
DefaultChatClientRequestSpec.mutate() copied advisor params only when there were advisors, and user or system params, media and metadata only when there was user or system text. Defaults set on their own were lost: for example a client built with AdvisorParams.ENABLE_NATIVE_STRUCTURED_OUTPUT and no advisors lost native structured output once mutated. Copy them whether or not advisors or text are set. Signed-off-by: bellCold <whdcks420@gmail.com>
bellCold
force-pushed
the
fix/chatclient-mutate-params
branch
from
November 4, 2026 23:02
e3ece41 to
3dada7f
Compare
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.
Problem
ChatClient.mutate()loses some default settings.It copies them only under conditions that are not related to them:
So if you set one of these defaults on its own, the mutated client does not have it.
Example
Real effects:
AdvisorParams.ENABLE_NATIVE_STRUCTURED_OUTPUTloses it aftermutate().AdvisorParams.toolCallingAdvisorAutoRegister(false)gets theToolCallingAdvisorregistered again aftermutate().Cause
The advisor params were added to
mutate()in #3459, inside the existing check for advisors.User and system params were already inside the checks for user and system text.
Fix
mutate()now always copies advisor params, user and system params, media and metadata.It still sets the user and system text only when there is text.
Tests
testMutatealways set both advisors and text, so it did not catch this.testMutateKeepsParamsWithoutAdvisorsOrTextfails without this change and passes with it.spring-ai-client-chatpass.