fix: Incorrect order when Advisors have the same order#3461
Open
YunKuiLu wants to merge 1 commit intospring-projects:mainfrom
Open
fix: Incorrect order when Advisors have the same order#3461YunKuiLu wants to merge 1 commit intospring-projects:mainfrom
YunKuiLu wants to merge 1 commit intospring-projects:mainfrom
Conversation
4b0c8b3 to
8a11659
Compare
Member
|
I think we should throw an exception, at at least log a warning, if anything would be short circuit. Probably in |
Contributor
Author
Would it be easier to check for the short circuit in this method? public class DefaultAroundAdvisorChain implements BaseAdvisorChain {
...
@Override
public ChatClientResponse nextCall(ChatClientRequest chatClientRequest) {
...
if (this.callAdvisors.isEmpty()) {
throw new IllegalStateException("No CallAdvisors available to execute");
}
var advisor = this.callAdvisors.pop();
if (advisor instanceof ChatModelCallAdvisor && !this.callAdvisors.isEmpty()){
// Short circuit detected
}
...
}
...
} |
- Fix incorrect order when Advisors have the same order - Added the `hasNextCallAdvisor` method to `CallAdvisorChain`. - Added the `hasNextStreamAdvisor` method to `StreamAdvisorChain`. - The `DefaultAroundAdvisorChain` implements both `hasNextCallAdvisor` and `hasNextStreamAdvisor` method. - Added a last StreamAdvisor check in `ChatModelStreamAdvisor`. - Added a last CallAdvisor check in `ChatModelCallAdvisor`. - Updated the corresponding test cases. Signed-off-by: YunKui Lu <luyunkui95@gmail.com>
Contributor
Author
|
Changelog 2025-07-21:
|
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.
If the order of Advisors is the same, then it should follow the order in which the parameters are passed in.
When I add
new SimpleLoggerAdvisor(Ordered.LOWEST_PRECEDENCE)todefaultAdvisors. SinceChatModelCallAdvisorhas the same order asSimpleLoggerAdvisor, it will result in the order ofChatModelCallAdvisorbeing before that ofSimpleLoggerAdvisorafter sorting.In the end, even if SimpleLoggerAdvisor continued to execute, it would be of no use.