Skip to content

fix: include reasoning_content field for DeepSeek Reasoner models#11290

Open
mvanhorn wants to merge 1 commit intocontinuedev:mainfrom
mvanhorn:fix/deepseek-reasoning-content
Open

fix: include reasoning_content field for DeepSeek Reasoner models#11290
mvanhorn wants to merge 1 commit intocontinuedev:mainfrom
mvanhorn:fix/deepseek-reasoning-content

Conversation

@mvanhorn
Copy link
Contributor

@mvanhorn mvanhorn commented Mar 11, 2026

Summary

  • DeepSeek Reasoner API requires reasoning_content on every assistant message, but appendReasoningFieldsIfSupported returned early when no thinking message preceded the assistant message (e.g. in resumed sessions)
  • Now reasoning_content defaults to an empty string when includeReasoningContentField is true but no thinking content is available, preventing 400 "Missing reasoning_content field" errors

How it works

  • Moved the includeReasoningContent check before the early return guard so it always runs for providers that need it
  • When a thinking message precedes the assistant message, the actual reasoning content is used
  • When no thinking message is present, an empty string is used as the default
  • Other reasoning fields (reasoning, reasoning_details) still require a preceding thinking message

Test plan

  • Verify DeepSeek Reasoner no longer returns 400 errors in resumed sessions
  • Verify DeepSeek Reasoner still includes actual reasoning_content when thinking messages are present
  • Verify Claude and other providers are unaffected (they use reasoning_details, not reasoning_content)

Fixes #11285

🤖 Generated with Claude Code


Summary by cubic

Always include reasoning_content for DeepSeek Reasoner models, defaulting to an empty string when no prior thinking message exists. Prevents 400 errors in resumed sessions and keeps other providers unchanged.

  • Bug Fixes
    • Run includeReasoningContentField logic before the early return and set msg.reasoning_content to the previous thinking content or "" if missing.
    • Leave reasoning and reasoning_details unchanged and only set when a thinking message is present.

Written for commit a843400. Summary will update on new commits.

DeepSeek Reasoner API requires the reasoning_content field on every
assistant message, even when no thinking message precedes it (e.g. in
resumed sessions). Previously, appendReasoningFieldsIfSupported returned
early when prevMessage was missing or not a thinking role, causing 400
"Missing reasoning_content field" errors. Now reasoning_content defaults
to an empty string when no thinking content is available.

Fixes continuedev#11285

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mvanhorn mvanhorn requested a review from a team as a code owner March 11, 2026 06:18
@mvanhorn mvanhorn requested review from RomneyDa and removed request for a team March 11, 2026 06:18
@mvanhorn
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 11, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

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

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Error: DeepSeek Reasoner - 400

1 participant