anomalyco / anomalyco/opencode

[Bug] reasoning_content "invalid_request" on follow-up messages with OpenCodeZen DeepSeek-V4-Flash in thinking mode

Open
#41,061 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 7, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description
When using OpenCodeZen's DeepSeek-V4-Flash with thinking mode enabled, sending a follow-up message within the same session intermittently fails with:
Error from provider (Console): Upstream request failed: [invalid_request_error]
The reasoning_content in the thinking mode must be passed back to the API.
The error breaks tool invocations and upstream requests, interrupting the conversation until the session is restarted.
Steps to reproduce

  1. Create a new session with OpenCodeZen's DeepSeek-V4-Flash with thinking mode enabled.
  2. First message works fine.
  3. Send a second (follow-up) message in the same session while reasoning output is present in the history.
  4. The error triggers and the conversation is interrupted.
    Expected vs actual
  • Expected: reasoning_content from history is passed back to the API correctly, or the client omits stale/empty reasoning fields.
  • Actual: Request rejected with invalid_request_error; upstream request fails.
    Environment
  • Provider: OpenCodeZen (configured via auth.json)
  • Model: DeepSeek-V4-Flash (thinking mode)
  • Error type: [invalid_request_error]
    Additional notes
  • Official DeepSeek API does NOT exhibit this issue with the same model — the problem appears specific to the OpenCodeZen gateway's handling of reasoning_content.
  • Restarting the session temporarily resolves it, but it reproduces again afterward.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.