-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(deepseek): reset tool_choice handling to prevent infinite loop when returnDirect=false (#4617) #4649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
* backed by {@link DeepSeekApi}. | ||
* | ||
* @author Geng Rong | ||
* @last Updated By : @kuntal1461 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep same style? @author Geng Rong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiafu1115 It is fixed . Please review once
.build()); | ||
} | ||
else { | ||
// Reset tool choice to AUTO to prevent forcing repeated tool calls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated code with 223. you can extract these duplicated line to seperate method.
…en returnDirect=false (spring-projects#4617) Signed-off-by: Kuntal Maity <kuntal.1461@gmail.com>
…ed tool_choice reset validation (spring-projects#4617) Signed-off-by: Kuntal Maity <kuntal.1461@gmail.com>
…en returnDirect=false (spring-projects#4617) Signed-off-by: Kuntal Maity <kuntal.1461@gmail.com>
c312b9c
to
d05c8dd
Compare
Signed-off-by: Kuntal Maity <kuntal.1461@gmail.com>
Summary
Fixes #4617 — When DeepSeekChatModel is forced to use a tool_choice with returnDirect=false,
the model repeatedly re-enters tool-call, causing an infinite loop.
This change resets tool_choice to auto after tool execution so the model can produce normal assistant text.
Changes
How to Reproduce
Expected Behavior
Tool is invoked once; model returns normal text.
Environment
Tests
mvn -pl models/spring-ai-deepseek -Dtest=org.springframework.ai.deepseek.DeepSeekChatModelToolChoiceResetTests test
DCO Sign-off
Signed-off-by: Kuntal Maity kuntal.1461@gmail.com