diff --git a/open-sse/handlers/chatCore.ts b/open-sse/handlers/chatCore.ts index b66aab7362..024cca1839 100644 --- a/open-sse/handlers/chatCore.ts +++ b/open-sse/handlers/chatCore.ts @@ -1776,8 +1776,8 @@ export async function handleChatCore({ // Sanitize response for OpenAI SDK compatibility // Strips non-standard fields (x_groq, usage_breakdown, service_tier, etc.) // Extracts and tags into reasoning_content - // Target format determines output shape. If we are outputting OpenAI shape or pseudo-OpenAI shape, sanitize. - if (targetFormat === FORMATS.OPENAI || targetFormat === FORMATS.OPENAI_RESPONSES) { + // Source format determines output shape. If we are outputting OpenAI shape or pseudo-OpenAI shape, sanitize. + if (sourceFormat === FORMATS.OPENAI || sourceFormat === FORMATS.OPENAI_RESPONSES) { translatedResponse = sanitizeOpenAIResponse(translatedResponse); } diff --git a/open-sse/utils/stream.ts b/open-sse/utils/stream.ts index e5f264f34c..c17c00cc33 100644 --- a/open-sse/utils/stream.ts +++ b/open-sse/utils/stream.ts @@ -585,9 +585,9 @@ export function createSSEStream(options: StreamOptions = {}) { // Content for call log is accumulated only from parsed (above) to avoid double-counting; // do not add again from item here. - // #723, #727: Sanitize intermediate stream chunks if target is OpenAI format loop + // #723, #727: Sanitize intermediate stream chunks if source (client) is OpenAI format let itemSanitized: Record = item; - if (targetFormat === FORMATS.OPENAI || targetFormat === FORMATS.OPENAI_RESPONSES) { + if (sourceFormat === FORMATS.OPENAI || sourceFormat === FORMATS.OPENAI_RESPONSES) { itemSanitized = sanitizeStreamingChunk(itemSanitized) as Record; // Extract reasoning tags from content if translation generated them