fix(deepseek): use non-empty reasoning_content placeholder for V4 Pro thinking mode#18263
Merged
Conversation
… thinking mode
DeepSeek V4 Pro tightened thinking-mode validation and rejects empty-string
reasoning_content with HTTP 400:
The reasoning content in the thinking mode must be passed back to the API.
run_agent.py injected "" at three fallback sites — the tool-call pad in
_build_assistant_message and both injection branches of
_copy_reasoning_content_for_api (cross-provider poison guard + unconditional
thinking pad). All three now emit " " (single space), which satisfies the
non-empty check on V4 Pro without leaking fabricated reasoning.
Also upgrades stale empty-string placeholders on replay: sessions persisted
before this change have reasoning_content="" pinned at creation time; when
the active provider enforces thinking-mode echo, the replay path now rewrites
"" -> " " so existing users don't 400 on their first V4 Pro turn after
updating. Non-thinking providers still round-trip "" verbatim.
Updates 9 existing assertions + adds 2 regression tests (stale-placeholder
upgrade, non-thinking verbatim preservation).
Refs #15250, #17400.
Closes #17341.
Collaborator
|
Salvages #17341 — same fix widened to all injection sites + stale session upgrade. |
Collaborator
|
Salvages #17341 - same fix widened to all injection sites + stale session upgrade. |
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.
DeepSeek V4 Pro rejects empty-string
reasoning_contentin thinking mode with HTTP 400. Salvages #17341 and widens the fix to every injection site + stale sessions.Changes
run_agent.py: replace""with" "at all three injection sites_build_assistant_messagetool-call pad ([Bug]: DeepSeek V4 Flash Discord session poisoned when tool-call assistant lacks reasoning_content #15250 / reasoning_content dropped in multi-turn tool calls with DeepSeek v4 (causes HTTP 400) #17400 path)_copy_reasoning_content_for_apicross-provider poison guard ([Bug] _copy_reasoning_content_for_api: cross-provider reasoning promotion leaks stale content to DeepSeek/Kimi #15748 path)_copy_reasoning_content_for_apiunconditional thinking padrun_agent.py: upgrade stalereasoning_content=""→" "on replay when the active provider enforces thinking-mode echo (so sessions persisted before this change don't 400 on their first V4 Pro turn after updating)" "; 2 new regression tests (stale upgrade on DeepSeek V4 Pro, verbatim preservation on non-thinking providers)scripts/release.py: AUTHOR_MAP entry for IMHaoyanValidation
reasoning content in the thinking mode must be passed back""tolerated)reasoning_content""""tests/run_agent/fullCloses #17341 — credit to @IMHaoyan whose commit authorship is preserved on the only commit in this branch.