From 363ecc4024c984b712be21279ded136cc9e9e17a Mon Sep 17 00:00:00 2001 From: janeza2 <49841619+janeza2@users.noreply.github.com> Date: Fri, 22 May 2026 09:15:00 +0700 Subject: [PATCH] fix(codex): accept auth.json without auth_mode field on import (#2536) Integrated into release/v3.8.2 --- src/lib/oauth/utils/codexAuthImport.ts | 6 ++++-- src/lib/semanticCache.ts | 19 +++---------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/lib/oauth/utils/codexAuthImport.ts b/src/lib/oauth/utils/codexAuthImport.ts index 8d62ed9048..81fb123663 100644 --- a/src/lib/oauth/utils/codexAuthImport.ts +++ b/src/lib/oauth/utils/codexAuthImport.ts @@ -88,9 +88,11 @@ export interface CreateConnectionOptions { export function parseAndValidateCodexAuth(raw: unknown): ParsedCodexAuth { const doc = toRecord(raw); - if (doc.auth_mode !== "chatgpt") { + // Codex CLI no longer writes auth_mode in auth.json (only OmniRoute's own export + // includes it). Accept both formats as long as the required tokens are present. + if (doc.auth_mode !== undefined && doc.auth_mode !== null && doc.auth_mode !== "chatgpt") { throw new CodexAuthFileError( - 'Not a Codex auth.json — expected auth_mode: "chatgpt"', + 'Not a Codex auth.json — unexpected auth_mode value', 400, "invalid_auth_file" ); diff --git a/src/lib/semanticCache.ts b/src/lib/semanticCache.ts index 3e12b9f3a5..9508a991c8 100644 --- a/src/lib/semanticCache.ts +++ b/src/lib/semanticCache.ts @@ -393,30 +393,17 @@ export function getCacheStats() { }; } -/** - * Check if a request is cacheable for read (pre-request lookup). - * Only non-streaming, deterministic (temperature=0) requests. - * @deprecated Use isCacheableForRead instead. - */ -export function isCacheable(body, headers) { - if ((getHeaderValue(headers, "x-omniroute-no-cache") || "").toLowerCase() === "true") { - return false; - } - if (body.stream !== false) return false; - if ((body.temperature ?? 0) !== 0) return false; - return true; -} - /** * Check if a cached response can be served for this request. * Works for both streaming and non-streaming requests (cache hit returns JSON). - * Omitted temperature defaults to 0 for read (matching existing cache entries). + * Requires explicit numeric `temperature: 0` — omitted temperature is NOT cached + * because the provider default may be non-deterministic (e.g. random/creative tasks). */ export function isCacheableForRead(body, headers) { if ((getHeaderValue(headers, "x-omniroute-no-cache") || "").toLowerCase() === "true") { return false; } - if ((body.temperature ?? 0) !== 0) return false; + if (typeof body.temperature !== "number" || body.temperature !== 0) return false; return true; }