From 99d45718a5d004fd6e1c4aeb44d9f78b8b5485ba Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 6 Jan 2026 16:49:17 +0000 Subject: [PATCH] fix: use else-if chain for reasoning fields and guard delta.content type --- src/api/providers/lite-llm.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/api/providers/lite-llm.ts b/src/api/providers/lite-llm.ts index e9e23c9e92..d074c699f9 100644 --- a/src/api/providers/lite-llm.ts +++ b/src/api/providers/lite-llm.ts @@ -148,26 +148,23 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa // Check for reasoning/thinking content in the delta // LiteLLM may pass through reasoning content from underlying models + // Use else-if chain to emit at most one reasoning chunk per delta if (delta) { if ("reasoning" in delta && delta.reasoning && typeof delta.reasoning === "string") { yield { type: "reasoning", text: delta.reasoning } - } - - // Also check for thinking content (alternative field name) - if ("thinking" in delta && delta.thinking && typeof delta.thinking === "string") { + } else if ("thinking" in delta && delta.thinking && typeof delta.thinking === "string") { + // Also check for thinking content (alternative field name) yield { type: "reasoning", text: delta.thinking } - } - - // Check for reasoning_content (another possible field name) - if ( + } else if ( "reasoning_content" in delta && delta.reasoning_content && typeof delta.reasoning_content === "string" ) { + // Check for reasoning_content (another possible field name) yield { type: "reasoning", text: delta.reasoning_content } } - if (delta.content) { + if (delta.content && typeof delta.content === "string") { yield { type: "text", text: delta.content } } }