From 602c8fbf6c94e67ec7f33508fe6ac00826ffba30 Mon Sep 17 00:00:00 2001 From: Konrad Lother Date: Fri, 20 Nov 2026 16:45:36 +0000 Subject: [PATCH] transport: the Accept header follows the mode junction reads an Accept naming text/event-stream as a request to stream, so a non-streaming call got "data: {...}" back and failed with "reply is not JSON" on models whose answer goes through its review path. Ask for a stream only when this call is one. --- src/backend/transport_openai.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backend/transport_openai.c b/src/backend/transport_openai.c index b87179c..06c6ba7 100644 --- a/src/backend/transport_openai.c +++ b/src/backend/transport_openai.c @@ -201,7 +201,16 @@ openai_curl(const struct openai_ctx *c, const char *body_path, int stream, args[n] = NULL; /* a client says who it is, and some providers insist on it */ snprintf(ua, sizeof(ua), "splinter/%s", SP_VERSION); - hdrs[nh++] = "Accept: text/event-stream, application/json"; + /* + * The Accept header has to follow the mode. It always said + * "text/event-stream, application/json", and junction (rightly) reads an + * Accept naming event-stream as a request to stream: a non-streaming run + * then got "data: {...}" and failed with "reply is not JSON" on models + * whose answer goes through junction's review path. Ask for a stream only + * when this call actually is one. + */ + hdrs[nh++] = stream ? "Accept: text/event-stream, application/json" + : "Accept: application/json"; if (c->key[0] != '\0') { snprintf(auth, sizeof(auth), "Authorization: Bearer %s", c->key); hdrs[nh++] = auth;