Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.
This repository was archived by the owner on May 15, 2026. It is now read-only.

[BUG] Deepseek V3.2 API error 400 after context condense #10175

Closed

Description

@BowerMotorsport

Problem (one or two sentences)

Resuming task that has been condensed causes error when using deepseek v3.2 reasoning.

Context (who is affected and when)

I believe any user who is using deepseek v3.2 who closes and reopens a chat that has been condensed will hit this issue.

Reproduction steps

Using deepseek v3.2 reasoning.

  1. Get context into the context window by any means.
  2. Manually condense from the task bar.
  3. error may present immediately, if not select new task from the top bar, reopen the same chat and select resume, error will present.

Expected result

Context condense process completes and task resumes and continues executing

Actual result

Error appears just after context condense halting any further task execution in this chat.

Variations tried (optional)

Issue was not present in
PR#9969
or
PR#9925

App Version

3.36.10

API Provider (optional)

DeepSeek

Model Used (optional)

Deepseek V3.2 Reasoning

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

/time: 2025-12-18T03:13:20.310Z
Extension version: 3.36.10
Provider: deepseek
Model: deepseek-reasoner

DeepSeek completion error: 400 Missing `reasoning_content` field in the assistant message at message index 1. For more information, please refer to https://api-docs.deepseek.com/guides/thinking_mode#tool-calls

Activity

  1. added
    bug
    on Dec 18, 2025
  2. changed the title [-][BUG][/-] [+][BUG] Deepseek V3.2 API error 400 after context condense[/+] on Dec 18, 2025
  3. added
    Issue/PR - Triage
    on Dec 18, 2025
  4. BowerMotorsport commented on Dec 18, 2025

    @BowerMotorsport
    Author

    I've analyzed this issue and identified the root cause. Here's my proposed implementation plan:

    Root Cause Analysis

    The error "Missing reasoning_content field in the assistant message at message index 1" occurs because:

    1. DeepSeek's API requirement: DeepSeek's reasoner model (deepseek-reasoner) requires ALL assistant messages to have a reasoning_content field when using thinking mode (see DeepSeek API docs)

    2. Context condense creates summary without reasoning: When context is condensed, a summary message is created in src/core/condense/index.ts (lines 278-284) as an assistant message. This summary message has no reasoning_content field.

    3. The conversion code conditionally adds reasoning_content: In src/api/transform/r1-format.ts (lines 196-199), reasoning_content is only added when it exists:
      ...(finalReasoning && { reasoning_content: finalReasoning }),

      When finalReasoning is empty/undefined (as for summary messages), the field is omitted entirely.

    4. DeepSeek rejects the request: When the task is resumed after condense, the summary message (assistant message at index 1) has no reasoning_content field, causing DeepSeek's API to reject the request.

    Proposed Fix

    Modify src/api/transform/r1-format.ts to ensure that when converting messages for DeepSeek's thinking mode (indicated by mergeToolResultText: true), ALL assistant messages include the reasoning_content field, even if empty:

    // For thinking models, always include reasoning_content field on assistant messages
    // DeepSeek's reasoner API requires this field to be present on all assistant messages
    const shouldAlwaysIncludeReasoningContent = options?.mergeToolResultText === true

    const assistantMessage: DeepSeekAssistantMessage = {
    role: "assistant",
    content: textParts.length > 0 ? textParts.join("\n") : null,
    ...(toolCalls.length > 0 && { tool_calls: toolCalls }),
    // Always include reasoning_content for thinking models, empty string if no reasoning
    ...(finalReasoning
    ? { reasoning_content: finalReasoning }
    : shouldAlwaysIncludeReasoningContent
    ? { reasoning_content: "" }
    : {}),
    }
    This fix will be applied in two places in r1-format.ts:

    1. Lines 193-199 (array content handling)
    2. Lines 232-236 (string content handling)

    Additional Changes

    1. Add tests in src/api/transform/__tests__/r1-format.spec.ts to verify:

      • Summary messages get empty reasoning_content when mergeToolResultText: true
      • Non-thinking models remain unaffected (no reasoning_content added)

    This approach ensures:

    • For non-thinking models: behavior remains unchanged
    • For thinking models (like deepseek-reasoner): reasoning_content is always present on assistant messages

    Please mention @roomote in a comment saying that you approve this plan, and I'll proceed with the implementation.

    Not sure if it helps or not but I have implemented this fix, built to vsix and installed.
    Issue appears to be resolved during initial check.

  5. ghost added a commit that references this issue on Dec 18, 2025
    0fb47f2
  6. KhalidYin commented on Dec 22, 2025

    @KhalidYin

    It still appered the same issue in version 3.36.16

  7. mahfuz-r commented on Dec 23, 2025

    @mahfuz-r

    I am getting similar error:

    Date/time: 2025-12-23T08:38:24.046Z
    Extension version: 3.37.0
    Provider: deepseek
    Model: deepseek-reasoner
    DeepSeek completion error: 400 Missing reasoning_content field in the assistant message at message index 53. For more information, please refer to https://api-docs.deepseek.com/guides/thinking_mode#tool-calls

    Image

    Reproduction steps

    Using Deepseek api key
    Using deepseek-reasoner for Architect mode.
    Using deepseek-chat for Code mode.

    1. I plan with Architect mode with deepseek-reasoner
    2. To implement the plan,Roo code suggested to switching to Code mode, I switched to Code mode
    3. Roo code edit a file with deepseek-chat
    4. To discuss about the updated code, I switch to Architect mode and ask something like, "with your new code I get this output"
    5. And I get error: 400 (please check attached screenshot above)
  8. hannesrudolph commented on Jan 7, 2026

    @hannesrudolph
    Contributor

    fixed a number of weeks ago. sorry for the delay.

  9. removed
    Issue/PR - Triage
    on Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions