fix: generalize reasoning_content injection across AI SDK providers#24895
fix: generalize reasoning_content injection across AI SDK providers#24895Malkovich-666 wants to merge 1 commit intoanomalyco:devfrom
Conversation
- 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
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
|
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:
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. |
|
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. |
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()helperDynamically resolves the AI SDK
providerOptionskey instead of hardcodingopenaiCompatible. Recognizes@ai-sdk/openai-compatibleand@openrouter/ai-sdk-providernpm packages.2. Replace DeepSeek hardcoded logic
if (model.api.id.includes("deepseek"))blockinterleaved,reasoning, and existing reasoning parts in messages3. Dynamic caching key
applyCaching()now uses the computed[key]instead of hardcodedopenaiCompatible4. Simplified temperature override
Consolidates 4 separate
id.includes("deepseek-xxx")checks into a singleid.includes("deepseek")invariants()Motivation
Models using
@ai-sdk/openai-compatible(e.g., DeepSeek) and@openrouter/ai-sdk-providerboth need reasoning_content inproviderOptions, but the key name differs from the instantiated provider name. This fix makes the logic provider-agnostic.