fix: preserve forced streaming for json clients

Keep provider-required streaming when client prefers JSON. The
Accept: application/json branch no longer flips stream back to false
for forceStream providers, fixing 400 errors on stream-only providers
(e.g. Command Code) for Hermes / Claude Code / other JSON clients.

Fixes #2031

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Joseph Yaksich
2026-06-26 10:33:29 +07:00
committed by decolua
parent 4d9da5db26
commit c842dc8f07
2 changed files with 138 additions and 2 deletions

View File

@@ -89,7 +89,7 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
const acceptHeader = clientRawRequest?.headers?.accept || "";
const clientPrefersJson = acceptHeader.includes("application/json");
const clientPrefersSSE = acceptHeader.includes("text/event-stream");
if (clientPrefersJson && !clientPrefersSSE && body.stream !== true) {
if (clientPrefersJson && !clientPrefersSSE && body.stream !== true && !providerRequiresStreaming) {
stream = false;
}