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

This commit is contained in:
Anurag Saxena
2026-04-07 09:46:28 +07:00
committed by GitHub
parent fca829aa2a
commit a53ccf1343
2 changed files with 15 additions and 0 deletions
@@ -210,6 +210,13 @@ export async function handleForcedSSEToJson({ providerResponse, sourceFormat, pr
status: "success"
}, { endpoint: clientRawRequest?.endpoint || null })).catch(() => {});
// Strip reasoning_content — breaks JSON parsers in some clients (e.g. Firecrawl AI SDK)
if (parsed?.choices) {
for (const choice of parsed.choices) {
if (choice?.message) delete choice.message.reasoning_content;
}
}
return { success: true, response: new Response(JSON.stringify(parsed), { headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*" } }) };
} catch (err) {
console.error("[ChatCore] Chat Completions SSE→JSON failed:", err);