From bb840a54ff202b3f0f1d324d07a7fbd5619da7e1 Mon Sep 17 00:00:00 2001 From: Loma Bot Ops Date: Thu, 26 Nov 2026 10:01:29 +0700 Subject: [PATCH] Fix Codex model and schema: revert to gpt-5.6-sol, strip $schema from Zod output RCA: - gpt-5.6-sol is the only model supported by this ChatGPT account; other models (gpt-4.1-mini, o4-mini, gpt-4o) all return model_not_in_accessible_catalog - Zod v4 toJSONSchema emits a $schema meta field that gpt-5.6-sol rejects as an invalid schema keyword; strip it before passing to the automation worker Co-Authored-By: Claude Sonnet 4.6 --- scripts/lib/codex-runtime.mjs | 2 +- src/lib/ai/claude.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/lib/codex-runtime.mjs b/scripts/lib/codex-runtime.mjs index e33c75b..a03db60 100644 --- a/scripts/lib/codex-runtime.mjs +++ b/scripts/lib/codex-runtime.mjs @@ -5,7 +5,7 @@ import path from "node:path"; import { promisify } from "node:util"; const execute = promisify(execFile); -export const DEFAULT_CODEX_MODEL = "o4-mini"; +export const DEFAULT_CODEX_MODEL = "gpt-5.6-sol"; let invocation; /** Isolate background content jobs from the desktop model default and unrelated MCP servers. */ diff --git a/src/lib/ai/claude.ts b/src/lib/ai/claude.ts index 2d1b104..0001498 100644 --- a/src/lib/ai/claude.ts +++ b/src/lib/ai/claude.ts @@ -22,7 +22,11 @@ export async function generateStructured(req: { throw new UserFacingError(`เพจนี้ใช้ AI ครบ ${AI_DAILY_LIMIT_PER_PAGE} ครั้งใน 24 ชั่วโมงแล้ว ลองใหม่ภายหลัง`); } - const response = await runAutomation({ kind: "text", system: req.system, prompt: req.prompt, schema: z.toJSONSchema(req.schema) }, { waitForWorker: req.waitForWorker }); + const rawSchema = z.toJSONSchema(req.schema) as Record; + // gpt-5.6-sol (ChatGPT Codex) does not accept the $schema meta keyword — strip it. + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { $schema: _drop, ...schema } = rawSchema; + const response = await runAutomation({ kind: "text", system: req.system, prompt: req.prompt, schema }, { waitForWorker: req.waitForWorker }); const result = req.schema.safeParse(response.result); if (!result.success) throw new UserFacingError("Codex ตอบกลับไม่ครบรูปแบบ ลองใหม่อีกครั้ง");