From d9b030011f42e12a0cbb8464b8b2eba36e58c31a Mon Sep 17 00:00:00 2001 From: Giang Truong Vu Date: Sat, 13 Jun 2026 10:34:42 +0700 Subject: [PATCH] fix(gemini-to-openai): route unsigned thought parts to reasoning_content Co-authored-by: Cursor --- open-sse/translator/response/gemini-to-openai.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/open-sse/translator/response/gemini-to-openai.js b/open-sse/translator/response/gemini-to-openai.js index 75123964..4f90b35b 100644 --- a/open-sse/translator/response/gemini-to-openai.js +++ b/open-sse/translator/response/gemini-to-openai.js @@ -92,7 +92,10 @@ export function geminiToOpenAIResponse(chunk, state) { continue; } - // Text content (non-thinking) + // Text content. Gemini marks model-internal thinking with `thought: true`. + // Some responses include a thoughtSignature, but Google AI Studio/Gemini API + // can also stream thought parts without a signature; those must not be + // surfaced as normal assistant content in OpenAI-compatible clients. if (part.text !== undefined && part.text !== "") { results.push({ id: `chatcmpl-${state.messageId}`, @@ -101,7 +104,9 @@ export function geminiToOpenAIResponse(chunk, state) { model: state.model, choices: [{ index: 0, - delta: { content: part.text }, + delta: isThought + ? { reasoning_content: part.text } + : { content: part.text }, finish_reason: null }] });