fix(opencode): ensure DeepSeek reasoning_content round-trips for all interleaved variants#25110
fix(opencode): ensure DeepSeek reasoning_content round-trips for all interleaved variants#25110nahoskins wants to merge 2 commits intoanomalyco:devfrom
Conversation
…interleaved variants
DeepSeek requires reasoning_content to be passed back on all assistant
messages in multi-turn conversations, especially those with tool calls.
The existing interleaved extraction only ran when the model capability
was explicitly { field: "reasoning_content" }, but some DeepSeek model
definitions have interleaved: true (boolean) or no interleaved field at
all. In those cases reasoning stayed in the content array where the AI
SDK may not properly round-trip it in tool-call scenarios.
This adds a fallback check: any DeepSeek model on @ai-sdk/openai-compatible
always gets reasoning extracted from content and placed in
providerOptions.openaiCompatible.reasoning_content.
Closes anomalyco#24722, anomalyco#25000
|
The following comment was made by an LLM, it may be inaccurate: Based on the search results, I found a potentially related PR: PR #24443: This PR appears closely related as it also deals with preserving The current PR (25110) specifically targets ensuring DeepSeek reasoning_content round-trips for all interleaved variants, while PR #24443 focused on preserving reasoning_content on subsequent interleaved passes. They may be addressing related or overlapping issues in the same area. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Relationship to #24443The bot flagged PR #24443 (
What #24443 does: When the transform runs a second time on the same messages (e.g. retry, middleware re-run), reasoning has already been extracted from content on the first pass. On the second pass What #25110 does: When a DeepSeek model has Both fixes touch the same region of |
|
This pr does nothing for 25000 |
|
Good catch — you're right, #25000 is about the zen/go proxy side, not the SDK transform this PR touches. Updated the PR to only close #24722. The proxy-side fix you mentioned (injecting |
Issue for this PR
Closes #24722
Type of change
What does this PR do?
DeepSeek requires
reasoning_contentto be passed back on all assistant messages in multi-turn conversations, especially those with tool calls. Without it, the API returns a 400 error.The existing interleaved reasoning extraction only ran when
model.capabilities.interleavedwas{ field: "reasoning_content" }. But some DeepSeek model definitions haveinterleaved: true(boolean) or no interleaved field. In those cases reasoning stayed in content and the AI SDK may not properly round-trip it in tool-call scenarios.This adds a fallback: any DeepSeek model on
@ai-sdk/openai-compatiblealways gets reasoning extracted from content and placed inproviderOptions.openaiCompatible.reasoning_content.How did you verify your code works?
bun typecheckacross all 19 packages passesScreenshots / recordings
N/A
Checklist