|
6 | 6 | openRouterDefaultModelInfo, |
7 | 7 | OPENROUTER_DEFAULT_PROVIDER_NAME, |
8 | 8 | OPEN_ROUTER_PROMPT_CACHING_MODELS, |
9 | | - OPEN_ROUTER_REASONING_DETAILS_MODELS, |
10 | 9 | DEEP_SEEK_DEFAULT_TEMPERATURE, |
11 | 10 | } from "@roo-code/types" |
12 | 11 |
|
@@ -230,39 +229,37 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH |
230 | 229 | yield { type: "reasoning", text: delta.reasoning } |
231 | 230 | } |
232 | 231 |
|
233 | | - // Handle reasoning_details array format for models that use it (Gemini 3, etc.) |
| 232 | + // Handle reasoning_details array format (used by Gemini 3, Claude, OpenAI o-series, etc.) |
234 | 233 | // See: https://openrouter.ai/docs/use-cases/reasoning-tokens#preserving-reasoning-blocks |
235 | | - if (OPEN_ROUTER_REASONING_DETAILS_MODELS.has(modelId)) { |
236 | | - const deltaWithReasoning = delta as typeof delta & { |
237 | | - reasoning_details?: Array<{ |
238 | | - type: string |
239 | | - text?: string |
240 | | - summary?: string |
241 | | - data?: string |
242 | | - id?: string | null |
243 | | - format?: string |
244 | | - index?: number |
245 | | - }> |
246 | | - } |
| 234 | + const deltaWithReasoning = delta as typeof delta & { |
| 235 | + reasoning_details?: Array<{ |
| 236 | + type: string |
| 237 | + text?: string |
| 238 | + summary?: string |
| 239 | + data?: string |
| 240 | + id?: string | null |
| 241 | + format?: string |
| 242 | + index?: number |
| 243 | + }> |
| 244 | + } |
247 | 245 |
|
248 | | - if (deltaWithReasoning.reasoning_details && Array.isArray(deltaWithReasoning.reasoning_details)) { |
249 | | - for (const detail of deltaWithReasoning.reasoning_details) { |
250 | | - // Store the full reasoning detail object for later use |
251 | | - this.currentReasoningDetails.push(detail) |
| 246 | + if (deltaWithReasoning.reasoning_details && Array.isArray(deltaWithReasoning.reasoning_details)) { |
| 247 | + for (const detail of deltaWithReasoning.reasoning_details) { |
| 248 | + // Store the full reasoning detail object for later use |
| 249 | + this.currentReasoningDetails.push(detail) |
252 | 250 |
|
253 | | - let reasoningText: string | undefined |
| 251 | + let reasoningText: string | undefined |
254 | 252 |
|
255 | | - // Extract text based on reasoning detail type for display |
256 | | - if (detail.type === "reasoning.text" && typeof detail.text === "string") { |
257 | | - reasoningText = detail.text |
258 | | - } else if (detail.type === "reasoning.summary" && typeof detail.summary === "string") { |
259 | | - reasoningText = detail.summary |
260 | | - } |
261 | | - // Note: reasoning.encrypted types are intentionally skipped as they contain redacted content |
| 253 | + // Extract text based on reasoning detail type for display |
| 254 | + if (detail.type === "reasoning.text" && typeof detail.text === "string") { |
| 255 | + reasoningText = detail.text |
| 256 | + } else if (detail.type === "reasoning.summary" && typeof detail.summary === "string") { |
| 257 | + reasoningText = detail.summary |
| 258 | + } |
| 259 | + // Note: reasoning.encrypted types are intentionally skipped as they contain redacted content |
262 | 260 |
|
263 | | - if (reasoningText) { |
264 | | - yield { type: "reasoning", text: reasoningText } |
265 | | - } |
| 261 | + if (reasoningText) { |
| 262 | + yield { type: "reasoning", text: reasoningText } |
266 | 263 | } |
267 | 264 | } |
268 | 265 | } |
|
0 commit comments