fix: preserve DeepSeek thinking blocks on Anthropic replay (#16748)#16781
Closed
vominh1919 wants to merge 1 commit into
Closed
fix: preserve DeepSeek thinking blocks on Anthropic replay (#16748)#16781vominh1919 wants to merge 1 commit into
vominh1919 wants to merge 1 commit into
Conversation
…rch#16748) DeepSeek's /anthropic endpoint requires thinking blocks to be replayed in multi-turn conversations for reasoning continuity. The existing code classified api.deepseek.com as a generic third-party endpoint and stripped ALL thinking blocks, causing HTTP 400 from DeepSeek. Fix: add _is_deepseek_anthropic_endpoint() detector (following the Kimi precedent) and a dedicated branch that strips only signed Anthropic blocks while preserving unsigned ones synthesised from reasoning_content. This follows the exact same pattern as the Kimi exemption (issue NousResearch#13848) and does not change behavior for any other third-party endpoint (Azure, Bedrock, MiniMax, etc.). Fixes NousResearch#16748
Collaborator
|
Likely duplicate of #16149 — same fix: preserve DeepSeek thinking blocks on Anthropic replay in anthropic_adapter.py. |
Closed
19 tasks
Contributor
4 tasks
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.
Summary
When using DeepSeek via their Anthropic Messages-compatible endpoint (
api.deepseek.com/anthropic) with thinking-capable models, Hermes strips ALL thinking blocks from assistant history on replay, causing DeepSeek to return HTTP 400 because it expects thinking context from prior turns.Root Cause
_is_third_party_anthropic_endpoint()returnsTrueforapi.deepseek.com(it's notanthropic.com), causing the thinking-block stripping logic to remove all thinking/redacted_thinking blocks unconditionally. DeepSeek's endpoint, unlike Azure/Bedrock/MiniMax, requires these blocks for reasoning continuity.Fix
Added
_is_deepseek_anthropic_endpoint()detector and a dedicated branch in the thinking-block processing logic that:reasoning_contentThis follows the exact same pattern as the Kimi exemption (added via issue #13848) and does not change behavior for any other third-party endpoint.
File changed:
agent/anthropic_adapter.py(+29 lines)Key Code Changes
Safety
Fixes #16748