Skip to content

fix: generalize reasoning_content injection across AI SDK providers#24895

Closed
Malkovich-666 wants to merge 1 commit intoanomalyco:devfrom
Malkovich-666:fix/reasoning-content-provider-options
Closed

fix: generalize reasoning_content injection across AI SDK providers#24895
Malkovich-666 wants to merge 1 commit intoanomalyco:devfrom
Malkovich-666:fix/reasoning-content-provider-options

Conversation

@Malkovich-666
Copy link
Copy Markdown

Summary

This PR replaces the hardcoded DeepSeek reasoning-content injection with a generalized approach that works across any AI SDK provider.

Changes

1. New providerOptionsKey() helper

Dynamically resolves the AI SDK providerOptions key instead of hardcoding openaiCompatible. Recognizes @ai-sdk/openai-compatible and @openrouter/ai-sdk-provider npm packages.

2. Replace DeepSeek hardcoded logic

  • Removed the provider-specific if (model.api.id.includes("deepseek")) block
  • Uses capability detection: interleaved, reasoning, and existing reasoning parts in messages
  • Handles both array-content and string-content (old DB format) assistant messages

3. Dynamic caching key

applyCaching() now uses the computed [key] instead of hardcoded openaiCompatible

4. Simplified temperature override

Consolidates 4 separate id.includes("deepseek-xxx") checks into a single id.includes("deepseek") in variants()

Motivation

Models using @ai-sdk/openai-compatible (e.g., DeepSeek) and @openrouter/ai-sdk-provider both need reasoning_content in providerOptions, but the key name differs from the instantiated provider name. This fix makes the logic provider-agnostic.

- Add providerOptionsKey() to dynamically resolve the providerOptions key
  instead of hardcoding 'openaiCompatible'
- Remove DeepSeek-specific hardcoded reasoning injection; use capability
  detection (interleaved + reasoning + existing reasoning parts)
- Handle both array-content and string-content assistant messages for
  DB-replayed conversations
- Use computed [key] in applyCaching() providerOptions instead of
  hardcoded openaiCompatible key
- Consolidate 4 deepseek-xxx id.includes checks into single 'deepseek'
  prefix check in variants() temperature override
@github-actions github-actions Bot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

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

Based on the search results, I found potentially related PRs, but none are direct duplicates of PR #24895. Here are the most relevant ones:

Related PRs:

  1. PR fix(provider): preserve reasoning_content on second interleaved pass (#24146 follow-up) #24443 - fix(provider): preserve reasoning_content on second interleaved pass (#24146 follow-up)

    • Directly related to reasoning_content handling and interleaved reasoning
  2. PR fix(provider): auto-enable interleaved for reasoning models #24218 - fix(provider): auto-enable interleaved for reasoning models

    • Related to reasoning capabilities and model detection
  3. PR fix: pass provider options under correct keys for openai-compatible #23623 - fix: pass provider options under correct keys for openai-compatible

    • Related to provider options key handling for openai-compatible providers
  4. PR fix(opencode): Error 400 missing reasoning_content – transform reasoning according to DeepSeek API and aditional test cases #17529 - fix(opencode): Error 400 missing reasoning_content – transform reasoning according to DeepSeek API and additional test cases

    • Original DeepSeek reasoning_content fix that this PR generalizes

These PRs appear to be part of the same feature area (reasoning_content handling and provider options), but PR #24895 seems to be a distinct generalization effort rather than a direct duplicate. The search found no other open PR with the exact same scope.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 29, 2026
@github-actions github-actions Bot closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants