Skip to content

fix(openai-adapter): add reasoning_content and handle max_completion_…#10478

Open
BurakBebek1 wants to merge 1 commit intocontinuedev:mainfrom
BurakBebek1:fix/deepseek-reasoner-missing-field
Open

fix(openai-adapter): add reasoning_content and handle max_completion_…#10478
BurakBebek1 wants to merge 1 commit intocontinuedev:mainfrom
BurakBebek1:fix/deepseek-reasoner-missing-field

Conversation

@BurakBebek1
Copy link

@BurakBebek1 BurakBebek1 commented Feb 12, 2026

Description

This PR addresses a specific compatibility issue between the Continue OpenAI adapter and DeepSeek Reasoner (R1) models.

The Problem

  1. Mandatory Field: DeepSeek's API is strict regarding the structure of assistant messages in the chat history. When a previous message contains tool_calls, the API expects a reasoning_content field to be present (even if empty) in the subsequent request. Missing this field results in a 400 Bad Request error.
  2. Token Mapping: Similar to OpenAI's o-series, DeepSeek Reasoner models utilize max_completion_tokens instead of the standard max_tokens for managing reasoning and output budgets.

The Solution

  • Modified modifyChatBody in OpenAIApi.ts to identify official DeepSeek endpoints or reasoner models.
  • Payload Transformation: Added a mapping layer that ensures reasoning_content: "" is added to assistant messages that contain tool calls but lack reasoning data.
  • Parameter Mapping: Automatically renames max_tokens to max_completion_tokens for DeepSeek reasoner models to ensure request validity.

Fixes #10475

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screen recording or screenshot

[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]

Tests

  • Logic Verification: Fix is based on DeepSeek's official API schema requirements to resolve the "Missing reasoning_content" 400 error during tool-use history.
  • Payload Inspection: Confirmed via local builds that modifyChatBody correctly injects reasoning_content and maps token parameters specifically for DeepSeek.
  • Regression Check: Verified that the changes are isolated to DeepSeek endpoints, ensuring zero impact on standard OpenAI or other provider logic.
  • Build Status: npm run build passed successfully in packages/openai-adapters.

Summary by cubic

Fixes DeepSeek Reasoner (R1) compatibility in the OpenAI adapter by adding missing reasoning_content and mapping max_tokens to max_completion_tokens to prevent 400 errors.

  • Bug Fixes
    • For DeepSeek endpoints or models, add reasoning_content: "" to assistant messages that have tool_calls but no reasoning data.
    • Map max_tokens to max_completion_tokens for DeepSeek reasoner models; other providers are untouched.

Written for commit 62b4e77. Summary will update on new commits.

@BurakBebek1 BurakBebek1 requested a review from a team as a code owner February 12, 2026 18:42
@BurakBebek1 BurakBebek1 requested review from Patrick-Erichsen and removed request for a team February 12, 2026 18:42
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 12, 2026
@github-actions
Copy link

github-actions bot commented Feb 12, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

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

@BurakBebek1
Copy link
Author

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

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

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Error: DeepSeek Reasoner - 400

1 participant