Skip to content

DeepSeek V4: reasoning_content 400 error persists on v1.14.31 — complete fix exists in unmerged PRs #25311

Closed as not planned

Description

@cameronmpalmer

Bug Description

When using DeepSeek V4 Pro or Flash models with thinking mode enabled (default), multi-turn conversations fail with:

The `reasoning_content` in the thinking mode must be passed back to the API.

This happens reliably on v1.14.31 (latest release) in conversations with multiple tool-call turns, regardless of whether the conversation is fresh or resumed from history.

Why the existing fixes are insufficient

The release notes mention:

  • v1.14.24: "Fixed DeepSeek assistant messages so reasoning is always included"
  • v1.14.29: "DeepSeek OpenAI-compatible setups now keep reasoning_content interleaved by default"

These handle some code paths but not all. The fundamental issue is that reasoning_content must be present on every assistant message in the conversation history — historical messages from DB replay, string-content messages, and messages processed on the second interleaved pass all need it. The current code has gaps.

The fix exists — three separate PRs wrote it

Three contributors have submitted PRs with the complete fix:

  1. fix(provider): complete DeepSeek reasoning_content round-trip for multi-turn conversations #24250 by @knefenk — Covers all three layers: auto-enable interleaved, dynamic SDK key, and unconditional reasoning_content injection for all assistant messages including DB-replayed ones. Commit: 41eb35a
  2. fix: preserve existing reasoning_content on second interleaved pass (#24146 follow-up) #24428 by @claudianus — Fixes second-pass regression where empty reasoningText overwrites preserved providerOptions values. Commit: 86dd22f
  3. fix: generalize reasoning_content injection across AI SDK providers #24895 by @Malkovich-666 — Generalizes the fix across all AI SDK providers with a providerOptionsKey() helper. Commit: c42e105

All three were closed without merge.

Environment

  • OpenCode v1.14.31 (Linux binary)
  • Provider: @ai-sdk/openai-compatible via LLM Gateway (pinned to DeepSeek API)
  • Model: deepseek-v4-pro with reasoning: true and interleaved: { field: "reasoning_content" }
  • Also reproduced with direct DeepSeek API (bypassing gateway)

Request

Please review and merge one of the existing complete fixes (#24250, #24895) so that DeepSeek V4 with thinking mode works reliably in multi-turn conversations.

Activity

  1. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    There are also many closed issues tracking this same error (e.g. #24261, #24442, #24190, #24803). The maintainers are likely already tracking this bug — please check the above issues and consider adding a +1 or relevant details there rather than opening a new report.

  2. chrispository commented on May 1, 2026

    @chrispository

    Edit: Ignore the below. My opencode was out of date. Seems to be working fine in the actual up to date version.

    I can confirm the first one you linked fixes it: #24250

    I had OpenCode pull the main dev branch and asked it apply the linked fix. Then I re-built, and it's working perfectly for me now. You'll just have to build it, took less than 20 seconds for me.

    https://github.com/chrispository/opencode_deepseek_fix

  3. tom-knight-ai commented on May 4, 2026

    @tom-knight-ai

    Comment from optinosis team: Cerebras GLM-4.7 also affected

    We hit this exact bug with the Cerebras Z.AI GLM-4.7 model on OpenCode v1.14.33. Our internal issue: https://github.com/optinosis/optinosis/issues/2229

    We confirmed that:

    Our temporary workaround is to disable reasoning (), but that significantly degrades model quality for complex tasks (~20-30% drop for architecture/design, ~5% for simple tasks).

    We believe a merge of any one of the three PRs — particularly #24250 which is the most comprehensive (3-layer fix covering auto-enable interleaved, dynamic SDK key, and unconditional reasoning injection for all assistant messages) — would resolve this for Cerebras GLM-4.7 and all other affected providers.

    Could you review one of these? Happy to provide additional testing or reproductions.

  4. tom-knight-ai commented on May 4, 2026

    @tom-knight-ai

    Comment from optinosis team: Cerebras GLM-4.7 also affected

    We hit this exact bug with the Cerebras Z.AI GLM-4.7 model on OpenCode v1.14.33. Our internal issue: https://github.com/optinosis/optinosis/issues/2229

    We confirmed that:

    Our temporary workaround is to disable reasoning (reasoning_effort: none), but that significantly degrades model quality for complex tasks (~20-30% drop for architecture/design, ~5% for simple tasks).

    We believe a merge of any one of the three PRs - particularly #24250 which is the most comprehensive (3-layer fix covering auto-enable interleaved, dynamic SDK key, and unconditional reasoning injection for all assistant messages) - would resolve this for Cerebras GLM-4.7 and all other affected providers.

    Could you review one of these? Happy to provide additional testing or reproductions.

  5. github-actions commented on Jul 5, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions