From 53920b0399784c63f0cbe814d4d32984f7ddab5c Mon Sep 17 00:00:00 2001 From: Shady Khalifa Date: Tue, 27 Jan 2026 18:27:34 +0200 Subject: [PATCH] fix(openai): drop stream for responses/compact --- internal/runtime/executor/codex_executor.go | 2 +- internal/runtime/executor/openai_compat_executor.go | 5 +++++ sdk/api/handlers/openai/openai_responses_handlers.go | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/runtime/executor/codex_executor.go b/internal/runtime/executor/codex_executor.go index c8e9d97c..c09da7ac 100644 --- a/internal/runtime/executor/codex_executor.go +++ b/internal/runtime/executor/codex_executor.go @@ -216,7 +216,7 @@ func (e *CodexExecutor) executeCompact(ctx context.Context, auth *cliproxyauth.A requestedModel := payloadRequestedModel(opts, req.Model) body = applyPayloadConfigWithRoot(e.cfg, baseModel, to.String(), "", body, originalTranslated, requestedModel) body, _ = sjson.SetBytes(body, "model", baseModel) - body, _ = sjson.SetBytes(body, "stream", false) + body, _ = sjson.DeleteBytes(body, "stream") url := strings.TrimSuffix(baseURL, "/") + "/responses/compact" httpReq, err := e.cacheHelper(ctx, from, url, req, body) diff --git a/internal/runtime/executor/openai_compat_executor.go b/internal/runtime/executor/openai_compat_executor.go index 25a87e30..ee61556e 100644 --- a/internal/runtime/executor/openai_compat_executor.go +++ b/internal/runtime/executor/openai_compat_executor.go @@ -96,6 +96,11 @@ func (e *OpenAICompatExecutor) Execute(ctx context.Context, auth *cliproxyauth.A translated := sdktranslator.TranslateRequest(from, to, baseModel, bytes.Clone(req.Payload), opts.Stream) requestedModel := payloadRequestedModel(opts, req.Model) translated = applyPayloadConfigWithRoot(e.cfg, baseModel, to.String(), "", translated, originalTranslated, requestedModel) + if opts.Alt == "responses/compact" { + if updated, errDelete := sjson.DeleteBytes(translated, "stream"); errDelete == nil { + translated = updated + } + } translated, err = thinking.ApplyThinking(translated, req.Model, from.String(), to.String(), e.Identifier()) if err != nil { diff --git a/sdk/api/handlers/openai/openai_responses_handlers.go b/sdk/api/handlers/openai/openai_responses_handlers.go index fb807d37..4b611af3 100644 --- a/sdk/api/handlers/openai/openai_responses_handlers.go +++ b/sdk/api/handlers/openai/openai_responses_handlers.go @@ -18,6 +18,7 @@ import ( "github.com/router-for-me/CLIProxyAPI/v6/internal/registry" "github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers" "github.com/tidwall/gjson" + "github.com/tidwall/sjson" ) // OpenAIResponsesAPIHandler contains the handlers for OpenAIResponses API endpoints. @@ -113,6 +114,11 @@ func (h *OpenAIResponsesAPIHandler) Compact(c *gin.Context) { }) return } + if streamResult.Exists() { + if updated, err := sjson.DeleteBytes(rawJSON, "stream"); err == nil { + rawJSON = updated + } + } c.Header("Content-Type", "application/json") modelName := gjson.GetBytes(rawJSON, "model").String()