Skip to content

Fix: echo reasoning_content back for DeepSeek V4 multi-turn tool calls (fixed the Deepseek V4 thinking problem)#3058

Open
Psy-lzh wants to merge 1 commit into
ultraworkers:mainfrom
Psy-lzh:main
Open

Fix: echo reasoning_content back for DeepSeek V4 multi-turn tool calls (fixed the Deepseek V4 thinking problem)#3058
Psy-lzh wants to merge 1 commit into
ultraworkers:mainfrom
Psy-lzh:main

Conversation

@Psy-lzh
Copy link
Copy Markdown

@Psy-lzh Psy-lzh commented May 22, 2026

Fix: echo reasoning_content back for DeepSeek V4 multi-turn tool calls

Two layers in the CLI silently dropped assistant thinking blocks before they could reach build_chat_completion_request, breaking multi-turn tool-using conversations with DeepSeek V4 (which mandates that prior reasoning_content be echoed back per its thinking-mode protocol).

  1. AnthropicRuntimeClient::consume_stream did not accumulate
    ThinkingDelta into pending state, and never emitted
    AssistantEvent::Thinking on ContentBlockStop. As a result the
    session never contained a ContentBlock::Thinking.

  2. convert_messages mapped ContentBlock::Thinking -> None, dropping
    thinking blocks even if they had been persisted.

build_chat_completion_request already serializes
InputContentBlock::Thinking to the reasoning_content field for
DeepSeek V4 (gated on model_requires_reasoning_content_in_history),
so no provider-side changes are needed.

Verified end-to-end with deepseek-v4-flash via a local SSE proxy:
multi-turn tool-using conversations now succeed where they
previously failed with "400 The reasoning_content in the thinking
mode must be passed back to the API."

fixed the Deepseek V4 thinking problem
@Psy-lzh
Copy link
Copy Markdown
Author

Psy-lzh commented May 22, 2026

Thanks a lot for the sharing by the way

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.

1 participant