Skip to content

fix(openaicompat): echo reasoning_content on assistant messages #72

Merged
vietanh85 merged 1 commit into
zendev-sh:mainfrom
tenjinfactory:deepseek-reasoning-roundtrip
May 27, 2026
Merged

fix(openaicompat): echo reasoning_content on assistant messages #72
vietanh85 merged 1 commit into
zendev-sh:mainfrom
tenjinfactory:deepseek-reasoning-roundtrip

Conversation

@tenjinfactory

Copy link
Copy Markdown
Contributor

Summary

This fixes DeepSeek thinking-mode multi-turn round-trips.

When a DeepSeek thinking-mode model returns reasoning_content alongside tool_calls, the next request must echo that reasoning_content back or the API 400s. ConvertMessages now collects PartReasoning parts from assistant messages and sets m["reasoning_content"] on the wire map, concatenating multiple parts with newline (same as joinText does for PartText).

Also adds TestConvertMessages_AssistantReasoningRoundtrip to cover the exact multi-turn message shape that was breaking.

Related issues

Fixes #71

…k thinking-mode multi-turn round-trips

When a DeepSeek thinking-mode model returns reasoning_content alongside
tool_calls, the next request must echo that reasoning_content back or the API
400s. ConvertMessages now collects PartReasoning parts from assistant messages
and sets m["reasoning_content"] on the wire map, concatenating multiple parts
with newline (same as joinText does for PartText).

Also adds TestConvertMessages_AssistantReasoningRoundtrip to cover the
exact multi-turn message shape that was breaking.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vietanh85

Copy link
Copy Markdown
Contributor

/zenflow-review

@github-actions

Copy link
Copy Markdown
Contributor

zenflow review

LGTM - no issues found by either reviewer.

@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@vietanh85 vietanh85 merged commit 331a3af into zendev-sh:main May 27, 2026
3 checks passed
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.

deepseek-v4: The reasoning_content in the thinking mode must be passed back to the API.

3 participants