Skip to content

[Fix] DeepSeek 400 errors when mixed-model tasks continue long conversations#270

Draft
roomote[bot] wants to merge 1 commit into
mainfrom
fix/deepseek-reasoning-history-0mzxfggobdyyv
Draft

[Fix] DeepSeek 400 errors when mixed-model tasks continue long conversations#270
roomote[bot] wants to merge 1 commit into
mainfrom
fix/deepseek-reasoning-history-0mzxfggobdyyv

Conversation

@roomote
Copy link
Copy Markdown
Contributor

@roomote roomote Bot commented May 23, 2026

Opened on behalf of Naved Merchant. View the task or mention @roomote for follow-up asks.

Related GitHub Issue

Closes: #201

Description

This fixes the mixed-model DeepSeek history path behind the recurring 400 reasoning_content error.

Assistant turns from OpenAI-style reasoning models now persist explicit reasoning_content metadata when that model requires replay, and request rebuilding only sends that metadata back for the assistant turns that were originally marked for it. That prevents long tasks from replaying generic reasoning blocks from other agents or models as if they were DeepSeek continuation history.

Test Procedure

  • Ran pnpm --dir src exec vitest run core/task/__tests__/apiConversationHistory.spec.ts api/transform/__tests__/openai-format.spec.ts core/task/__tests__/Task.persistence.spec.ts api/providers/__tests__/deepseek.spec.ts
  • Ran pnpm --dir src check-types
  • Attempted the environment-mandated pnpm --dir apps/web-roo-code test, but this checkout does not contain apps/web-roo-code, so that validation path could not run here.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Not applicable for this internal conversation-history fix.

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. (Please describe what needs to be updated or link to a PR in the docs repository).

Additional Notes

The fix also adds regression coverage around request rebuilding so DeepSeek-marked assistant turns keep their own reasoning_content while unrelated reasoning from other models is stripped before replay.

Get in Touch

Roomote (task 0mzxfggobdyyv)

@roomote roomote Bot added the roomote:auto-resolve-conflicts Allow Roomote to auto-resolve merge conflicts for this PR label May 23, 2026
@roomote
Copy link
Copy Markdown
Contributor Author

roomote Bot commented May 23, 2026

1 issue outstanding; 2 checks still running. Action required. See task

  • Preserve reasoning replay for Anthropic-style preserveReasoning providers instead of only replaying stored top-level reasoning_content.
  • platform-unit-test (ubuntu-latest) is still running.
  • platform-unit-test (windows-latest) is still running.

Comment thread src/core/task/Task.ts
role: "assistant",
content: assistantContent,
} satisfies Anthropic.Messages.MessageParam)
...(shouldReplayReasoningContent ? { reasoning_content: preservedReasoningContent } : {}),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prepareApiConversationMessage() only stores top-level reasoning_content for apiProtocol === "openai" (src/core/task/apiConversationHistory.ts). Anthropic-style thinking providers in this repo still set info.preserveReasoning (for example MiniMax and the Bedrock Kimi/MiniMax models) but persist their reasoning as embedded blocks, so this branch now strips the reasoning those continuations need.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 88.09524% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/task/Task.ts 80.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

roomote:auto-resolve-conflicts Allow Roomote to auto-resolve merge conflicts for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] DeepSeek error: 'reasoning_content' must be passed back to the API

1 participant