Improve analysis worker Codex error messages with model and token diagnostics
Add pattern matching for model-not-found and context-length errors so the UI shows an actionable message instead of the generic fallback. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,7 @@ import { fileURLToPath } from "node:url";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaPg } from "@prisma/adapter-pg";
|
||||
import { budgetPlan, GOALS, validateReport } from "../src/lib/analysis/plan.mjs";
|
||||
import { codexInvocation } from "./lib/codex-runtime.mjs";
|
||||
import { codexInvocation, DEFAULT_CODEX_MODEL } from "./lib/codex-runtime.mjs";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const SCHEMA_PATH = path.resolve(HERE, "../src/lib/analysis/report.schema.json");
|
||||
@@ -94,6 +94,8 @@ async function runCodex(prompt, workDir) {
|
||||
console.error(`[analysis] codex exited ${code}`, stderr);
|
||||
if (/usage limit|rate limit/i.test(stderr)) return reject(new JobError("โควตา Codex ของเครื่อง worker หมดชั่วคราว ลองใหม่ภายหลัง"));
|
||||
if (/not logged in|login|unauthorized|401/i.test(stderr)) return reject(new JobError("Codex บนเครื่อง worker ยังไม่ได้ login — รัน codex login ก่อน"));
|
||||
if (/model.*not found|invalid model|no such model/i.test(stderr)) return reject(new JobError(`โมเดล Codex ที่ตั้งไว้ไม่รองรับ — ตรวจ CODEX_MODEL ใน env (ค่าปัจจุบัน: ${process.env.CODEX_MODEL || DEFAULT_CODEX_MODEL})`));
|
||||
if (/context.*length|token.*limit|maximum.*token/i.test(stderr)) return reject(new JobError("ข้อมูลเพจมากเกินไปสำหรับรอบนี้ ลองลดช่วงวันหรือจำนวนโพสต์แล้วลองใหม่"));
|
||||
return reject(new JobError("Codex ทำงานไม่สำเร็จ ลองใหม่หรือติดต่อผู้ดูแล"));
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user