fix(opencode): keep DeepSeek assistant content non-empty (#38654)#38778
fix(opencode): keep DeepSeek assistant content non-empty (#38654)#38778razmser wants to merge 1 commit into
Conversation
…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
|
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:
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. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #38654
Type of change
What does this PR do?
DeepSeek returns reasoning_content with empty content, so a reasoning-only assistant turn ends up with nothing in
contentonce reasoning is moved to the interleaved reasoning field.And this is causing
invalid_request_error: messages.1335: all messages must have non-empty contenterrors.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
If you do not follow this template your PR will be automatically rejected.