From 0236bbc810b5ba1b55dc580ac5d2ffe69cbf17ac Mon Sep 17 00:00:00 2001 From: Yarasul Bychok Date: Tue, 17 Nov 2026 09:03:33 +0500 Subject: [PATCH] fix(codex): use Responses WebSocket for managed ChatGPT sessions The managed token-sharing provider disabled WebSockets, so every sampling request re-uploaded the full conversation, including every image a tool had returned. Image-heavy Codex turns grew to ~100 MB per request and took minutes per step on ordinary uplinks. With supports_websockets=true Codex sends continuations over the Responses WebSocket instead of the whole history, and falls back to HTTP for the session if the WebSocket cannot be used. --- apps/server/src/provider/CodexManagedRuntime.test.ts | 2 +- apps/server/src/provider/CodexManagedRuntime.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/server/src/provider/CodexManagedRuntime.test.ts b/apps/server/src/provider/CodexManagedRuntime.test.ts index 2c697f8fa8531..4863fda790bf5 100644 --- a/apps/server/src/provider/CodexManagedRuntime.test.ts +++ b/apps/server/src/provider/CodexManagedRuntime.test.ts @@ -201,7 +201,7 @@ it.live.each( assert.include(args, "features.multi_agent_v2=false"); assert.notInclude(effective.config.launchArgs, "model_catalog_json"); assert.notInclude(effective.config.launchArgs, "x-openai-chatpass-test"); - assert.include(provider, "supports_websockets=false"); + assert.include(provider, "supports_websockets=true"); assert.include(provider, "requires_openai_auth=false"); for (const secret of ["dummy-owned-access", "dummy-refresh", "ambient-bearer"]) { assert.notInclude(effective.config.launchArgs, secret); diff --git a/apps/server/src/provider/CodexManagedRuntime.ts b/apps/server/src/provider/CodexManagedRuntime.ts index 3704c919c2791..d627bf33499e0 100644 --- a/apps/server/src/provider/CodexManagedRuntime.ts +++ b/apps/server/src/provider/CodexManagedRuntime.ts @@ -23,7 +23,9 @@ const managedCodexLaunchArgs = (command: string, args: ReadonlyArray) => [ 'model_provider="openai_token_sharing"', // Codex persists this provider ID in rollouts and needs it unchanged to resume. - `model_providers.openai_token_sharing={name="OpenAI Token Sharing",base_url="https://api.openai.com/v1",model_catalog_url="https://api.openai.com/v1/models",wire_api="responses",requires_openai_auth=false,supports_websockets=false,auth={command=${JSON.stringify(command)},args=${JSON.stringify(args)},timeout_ms=${COMMAND_TIMEOUT_MS},refresh_interval_ms=0}}`, + // WebSockets send each step's new input only; over HTTP every step re-uploads the + // whole history, including every image, which made image-heavy turns take minutes. + `model_providers.openai_token_sharing={name="OpenAI Token Sharing",base_url="https://api.openai.com/v1",model_catalog_url="https://api.openai.com/v1/models",wire_api="responses",requires_openai_auth=false,supports_websockets=true,auth={command=${JSON.stringify(command)},args=${JSON.stringify(args)},timeout_ms=${COMMAND_TIMEOUT_MS},refresh_interval_ms=0}}`, "features.api_key_model_discovery=true", "features.multi_agent=false", "features.multi_agent_v2=false",