| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found the following related PRs: Potential Related PRs
NoteThe current PR #24250 is not a duplicate itself — it's a comprehensive fix that extends PR #24218 to cover the complete two-layer bug where reasoning_content is dropped on conversation replay for DeepSeek thinking mode. The description clearly indicates this is an incremental improvement over the existing fix. |
Sorry, something went wrong.
…ti-turn conversations
Fixes the two-layer bug where reasoning_content is dropped on conversation
replay for DeepSeek thinking mode and OpenRouter-routed DeepSeek models.
Three changes:
1. provider.ts: Auto-enable interleaved for reasoning models
- When model.reasoning is true but interleaved is not explicitly set,
default to { field: "reasoning_content" } instead of false
- This triggers the interleaved transform that extracts reasoning
and passes it via providerOptions
2. transform.ts: Use dynamic SDK key in interleaved transform
- Replace hardcoded "openaiCompatible" with sdkKey(model.api.npm)
- Fixes OpenRouter provider which expects "openrouter" key, not
"openaiCompatible" (prevents key mismatch in providerOptions)
3. transform.ts: Inject reasoning_content for ALL assistant messages
- New fallback transform fires when capabilities.reasoning is true
- Sets reasoning_content: "" in providerOptions for every assistant
message, including historical messages stored before reasoning mode
was enabled (no reasoning part to extract from)
- Also expands DeepSeek detection to check model.id in addition to
model.api.id, covering OpenRouter-routed DeepSeek models
Closes anomalyco#24104
Related: anomalyco#24203 (OpenRouter users still affected by PR anomalyco#24218 alone)
Supersedes partial fix from PR anomalyco#24146 (merged but incomplete)
…ges in reasoning fallback The fallback transform only set reasoning_content in providerOptions for array-content messages. String-content assistant messages (e.g., "It's 4.") were converted to array form but didn't get providerOptions set. Now both content types get reasoning_content: "" injected with the correct SDK key, ensuring DeepSeek's API receives it on all assistant turns.
Consideration: Scoping the fix to avoid unintended side effects on other reasoning modelsFirst commit auto-enables interleaved: { field: "reasoning_content" } for all models with capabilities.reasoning: true, and the fallback injects reasoning_content: "" into providerOptions for all assistant messages when reasoning is active. This is likely harmless for non-DeepSeek models because:
However, if you want to be conservative and scope the fix to only providers that actually need this pattern, the fallback could be gated more narrowly: // Instead of:
if (model.capabilities.reasoning) {
// Consider:
if (model.capabilities.reasoning && (
model.api.id.includes("deepseek") ||
model.id.includes("deepseek") ||
model.api.npm === "@ai-sdk/openai-compatible" ||
model.api.npm === "@openrouter/ai-sdk-provider"
)) {This ensures the reasoning_content injection only fires for:
It would leave other reasoning models (Claude thinking, o-series, Gemini) unaffected and avoid unnecessary providerOptions writes. Happy to push this as an additional commit if you prefer the narrower scope. Leaving it as-is is also fine if you're confident the extra fields are truly no-op for other providers. |
Sorry, something went wrong.
|
is this working for you? As you can see here #24190 (comment) this could be an openrouter issue too. |
Sorry, something went wrong.
|
@rekram1-node this PR addresses the reasoning_content round-trip bug discussed in #24093. The fix is client-side (transform.ts) so it applies regardless of the upstream provider (OpenRouter, opencode-go, direct API). Let me know if you need any changes. |
Sorry, something went wrong.
When the interleaved transform runs on subsequent requests (after DB round-trip), content parts no longer contain reasoning blocks (they were extracted on the first pass). The unconditional [field]: reasoningText overwrites the previously correct providerOptions.reasoning_content with empty string, causing DeepSeek 400: 'The reasoning_content in the thinking mode must be passed back to the API.' Fix: set [field]: reasoningText first, then spread existing providerOptions so that preserved values from DB take priority over empty reasoningText. Closes anomalyco#24442 (co-discovered with @claudianus)
Update: Fixed second-pass regression (commit 41eb35a)Issue #24442 identified a regression where the interleaved transform overwrites existing with empty string on subsequent passes (after DB round-trip). Reproduced and confirmed — affects upstream dev (post-#24146), this PR, and the new #24443. The fix (41eb35a): Swapped the order of spread and set so existing values take priority: \
This is equivalent to the approach in PR #24443 — both are correct, maintainer can pick either. Reproduction script and full trace at #24442 (comment) |
Sorry, something went wrong.
|
I think everything behaves as expected in latest release (going out rn). This introduces other changes that change default behaviors of reasoning models which is a separate discussion and not necessarily a bug fix. |
Sorry, something went wrong.
|
if u want to discuss further discuss w/ me on this issue: |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Issue for this PR
Closes #24104
Related: #24203
Type of change
What does this PR do?
Fixes the complete two-layer bug where reasoning_content is dropped on conversation replay for DeepSeek thinking mode. PR #24218 addresses layer 1 only — this PR covers all three layers:
Layer 1 — interleaved not auto-enabled for reasoning models
When a model has reasoning: true but no explicit interleaved config, the interleaved transform is skipped entirely and reasoning_content is never set in providerOptions.
Layer 2 — Hardcoded openaiCompatible key breaks non-standard SDKs
The interleaved transform hardcodes providerOptions.openaiCompatible, but OpenRouter's SDK key is "openrouter". The remap logic at line ~336 does not cover this because it only remaps from model.providerID, not from openaiCompatible.
Layer 3 — Historical messages have no reasoning part
Messages stored in DB before reasoning mode was enabled have no reasoning part to extract. The interleaved transform only processes messages with existing reasoning parts, so these get skipped. DeepSeek rejects the request because reasoning_content is missing.
Changes
How did you verify your code works?
Screenshots / recordings
N/A
Checklist