Skip to content

fix(deepseek): use non-empty reasoning_content placeholder for V4 Pro thinking mode#18263

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-f8f8bbc2
May 1, 2026
Merged

fix(deepseek): use non-empty reasoning_content placeholder for V4 Pro thinking mode#18263
teknium1 merged 1 commit into
mainfrom
hermes/hermes-f8f8bbc2

Conversation

@teknium1

@teknium1 teknium1 commented May 1, 2026

Copy link
Copy Markdown
Contributor

DeepSeek V4 Pro rejects empty-string reasoning_content in thinking mode with HTTP 400. Salvages #17341 and widens the fix to every injection site + stale sessions.

Changes

Validation

Before After
DeepSeek V4 Pro thinking-mode multi-turn tool calls 400 reasoning content in the thinking mode must be passed back OK
Older DeepSeek ("" tolerated) OK OK (space also accepted)
Non-thinking providers with empty reasoning_content verbatim "" verbatim ""
Test suite (reasoning/deepseek/kimi/thinking) 160 passed, 3 skipped
tests/run_agent/ full 1190 passed (2 failing concurrent_interrupt tests are unrelated, also fail on origin/main)

Closes #17341 — credit to @IMHaoyan whose commit authorship is preserved on the only commit in this branch.

… 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.
@teknium1 teknium1 merged commit bfb7046 into main May 1, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-f8f8bbc2 branch May 1, 2026 06:04
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent loop, run_agent.py, prompt builder provider/deepseek DeepSeek API labels May 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Salvages #17341 — same fix widened to all injection sites + stale session upgrade.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Salvages #17341 - same fix widened to all injection sites + stale session upgrade.

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

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have provider/deepseek DeepSeek API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants