Skip to content

fix(opencode): keep DeepSeek assistant content non-empty (#38654)#38778

Open
razmser wants to merge 1 commit into
anomalyco:devfrom
razmser:fix-deepseek-empty-content
Open

fix(opencode): keep DeepSeek assistant content non-empty (#38654)#38778
razmser wants to merge 1 commit into
anomalyco:devfrom
razmser:fix-deepseek-empty-content

Conversation

@razmser

@razmser razmser commented Jul 25, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #38654

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

DeepSeek returns reasoning_content with empty content, so a reasoning-only assistant turn ends up with nothing in content once reasoning is moved to the interleaved reasoning field.
And this is causing invalid_request_error: messages.1335: all messages must have non-empty content errors.

This PR backfills a whitespace text part, so the message still has some content.

How did you verify your code works?

Tests and local repro.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

…8654)

DeepSeek returns reasoning_content with empty content, so a reasoning-only
assistant turn ends up with nothing in `content` once reasoning is moved to
the interleaved reasoning field. Anthropic-protocol routes drop the reasoning
part entirely when it carries no signature, which DeepSeek never produces, so
the message lowers to `content: []` and the API rejects the whole request with
"all messages must have non-empty content". Once such a turn is in the history
every later request in the session fails.

Backfill a whitespace text part so the message still has content. A tool call
already counts as content and must stay the last block on the Anthropic wire
format, so leave those messages untouched — appending after a tool_use block
is rejected with "tool_use ids were found without tool_result blocks
immediately after".

Fixes anomalyco#38654
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found potentially related PRs that address similar content handling issues:

Related PRs:

  1. fix: add final empty-content guard in message() pipeline #34272 - fix: add final empty-content guard in message() pipeline

    • Addresses empty content validation in the message pipeline, which is directly related to the non-empty content requirement being fixed here
  2. fix: accept Ollama reasoning field in OpenAI Chat deltas #36068 - fix: accept Ollama reasoning field in OpenAI Chat deltas

    • Handles reasoning field extraction from another provider, showing a pattern of reasoning-content handling across providers
  3. fix(llm): suppress lone </think> chunk at reasoning→tool boundary #34698 - fix(llm): suppress lone chunk at reasoning→tool boundary

    • Related to reasoning content processing at provider boundaries

These PRs share the same domain (message content validation, reasoning field handling, and provider-specific content processing) but appear to address different scenarios. PR #34272 is most directly related as it also guards against empty content in messages.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

deepseek v4 pro 报错:invalid_request_error: messages.1335: all messages must have non-empty content

1 participant