Commit 9ee61bb
committed
fix(provider): complete DeepSeek reasoning_content round-trip for multi-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 #24104
Related: #24203 (OpenRouter users still affected by PR #24218 alone)
Supersedes partial fix from PR #24146 (merged but incomplete)1 parent e29058c commit 9ee61bb
2 files changed
Lines changed: 36 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1177 | 1177 | | |
1178 | 1178 | | |
1179 | 1179 | | |
1180 | | - | |
| 1180 | + | |
1181 | 1181 | | |
1182 | 1182 | | |
1183 | 1183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| 199 | + | |
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| |||
211 | 213 | | |
212 | 214 | | |
213 | 215 | | |
214 | | - | |
215 | | - | |
| 216 | + | |
| 217 | + | |
216 | 218 | | |
217 | 219 | | |
218 | 220 | | |
| |||
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
226 | 258 | | |
227 | 259 | | |
228 | 260 | | |
| |||
0 commit comments