fix: strip reasoning_content from non-streaming responses (closes #509) (#517)

This commit is contained in:
Anurag Saxena
2026-04-06 22:46:28 -04:00
committed by GitHub
parent fca829aa2a
commit a53ccf1343
2 changed files with 15 additions and 0 deletions

View File

@@ -185,6 +185,14 @@ export async function handleNonStreamingResponse({ providerResponse, provider, m
translatedResponse.usage = filterUsageForFormat(addBufferToUsage(translatedResponse.usage), sourceFormat);
}
// Strip reasoning_content — some clients (e.g. Firecrawl AI SDK) have JSON parsers that
// break on this non-standard field, even though OpenAI allows it in extensions.
if (translatedResponse?.choices) {
for (const choice of translatedResponse.choices) {
if (choice?.message) delete choice.message.reasoning_content;
}
}
reqLogger.logConvertedResponse(translatedResponse);
const totalLatency = Date.now() - requestStartTime;