Skip to content

fix: passthrough reasoning_content for DeepSeek thinking mode#54

Merged
cnjack merged 1 commit intomainfrom
fix/deepseek-reasoning-content
Apr 27, 2026
Merged

fix: passthrough reasoning_content for DeepSeek thinking mode#54
cnjack merged 1 commit intomainfrom
fix/deepseek-reasoning-content

Conversation

@cnjack
Copy link
Copy Markdown
Owner

@cnjack cnjack commented Apr 27, 2026

Problem

DeepSeek reasoning models (e.g. deepseek-reasoner, deepseek-v4-pro with thinking mode) return reasoning_content alongside content in API responses. Per DeepSeek API docs:

  • When tool calls are involved, reasoning_content from assistant messages must be sent back in subsequent API requests
  • Failure to do so results in a 400 Bad Request error

The toOpenAIMessage(), toEinoMessage(), and stream delta handling in chatmodel.go were all dropping the reasoning_content field, causing multi-turn tool-calling conversations with DeepSeek reasoning models to fail.

Fix

Map ReasoningContent in all three message conversion points:

  1. toOpenAIMessage() — Eino Message → OpenAI request message (sends reasoning_content back to API)
  2. toEinoMessage() — OpenAI response → Eino Message (captures reasoning_content from non-streaming responses)
  3. Stream handler — stream delta → Eino Message (captures reasoning_content from streaming responses)

Both go-openai v1.41.2 and Eino v0.8.11 already support the ReasoningContent field — only the conversion layer was missing the mapping.

DeepSeek's reasoning models return reasoning_content alongside content in
API responses. When tool calls are involved, this field must be sent back
in subsequent requests, otherwise the API returns 400 Bad Request.

Map ReasoningContent in all three conversion points:
- toOpenAIMessage: Eino Message -> OpenAI request
- toEinoMessage: OpenAI response -> Eino Message
- Stream handler: stream delta -> Eino Message
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

Warning

Rate limit exceeded

@cnjack has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 38 minutes and 41 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bda5a3a7-1a96-4fdb-9b93-28bd2731c67e

📥 Commits

Reviewing files that changed from the base of the PR and between 9c5c912 and 6e84794.

📒 Files selected for processing (1)
  • internal/model/chatmodel.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deepseek-reasoning-content

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cnjack cnjack merged commit 69a367a into main Apr 27, 2026
1 check passed
@cnjack cnjack deleted the fix/deepseek-reasoning-content branch April 27, 2026 17:01
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.

1 participant