Skip to content

Conversation

kuntal1461
Copy link
Contributor

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

  • Reset tool_choice to auto after tool execution in both internalCall and internalStream.
  • Add DeepSeekChatModelToolChoiceResetTests to verify forced tool_choice behavior.

How to Reproduce

  1. Define a tool with returnDirect=false
  2. Force tool_choice to that tool
  3. Observe repeated tool invocation (without this fix)

Expected Behavior
Tool is invoked once; model returns normal text.

Environment

  • Observed on Spring AI 1.0.3
  • Fix applied against main (1.1.0-SNAPSHOT)

Tests
mvn -pl models/spring-ai-deepseek -Dtest=org.springframework.ai.deepseek.DeepSeekChatModelToolChoiceResetTests test

DCO Sign-off
Signed-off-by: Kuntal Maity [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeepSeekChatModel forces tool_choice to be specified to trigger loop tool call

1 participant