From 165dcbc5e69b3294301ee0bead53079500613435 Mon Sep 17 00:00:00 2001 From: yuanzonghao Date: Sat, 6 Jun 2026 22:28:44 +0800 Subject: [PATCH] fix(engine): prevent Architect from seeing literal "auto" styleGuide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace session.styleGuide with a descriptive placeholder before the Architect runs, so its prompt reads a natural sentence instead of the raw "auto" marker. Also wrap selectStyle in a try-catch so a transient LLM failure falls back to 吉卜力 instead of crashing session start. Co-Authored-By: Claude Opus 4.6 --- lib/engine/orchestrator.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/engine/orchestrator.ts b/lib/engine/orchestrator.ts index da53e66..30f2726 100644 --- a/lib/engine/orchestrator.ts +++ b/lib/engine/orchestrator.ts @@ -16,6 +16,7 @@ import { coerceOrientation } from "@infiplot/types"; import { runArchitect } from "./agents/architect"; import { selectStyle } from "./agents/styleSelector"; import { directInsertBeat, directScene } from "./director"; +import { STYLE_MAP } from "@/lib/options"; import { synthesizeBeat } from "./voice"; import { interpret } from "./vision"; @@ -59,17 +60,23 @@ export async function startSession( `[start] worldSetting (${session.worldSetting.length} chars):\n${session.worldSetting}`, ); const isAutoStyle = session.styleGuide === "auto"; + if (isAutoStyle) { + session.styleGuide = "由 AI 根据剧情自动匹配最佳画风"; + } const tArchitect = Date.now(); const [architectResult, autoStyleGuide] = await Promise.all([ runArchitect(config.text, session), isAutoStyle - ? selectStyle(config.text, session.worldSetting) + ? selectStyle(config.text, session.worldSetting).catch((err) => { + console.warn(`[styleSelector] failed, falling back to 吉卜力:`, err); + return null; + }) : Promise.resolve(null), ]); session.storyState = architectResult; - if (isAutoStyle && autoStyleGuide) { - session.styleGuide = autoStyleGuide; - console.log(`[start] auto-selected style: ${autoStyleGuide.slice(0, 60)}…`); + if (isAutoStyle) { + session.styleGuide = autoStyleGuide ?? STYLE_MAP["吉卜力"]!; + console.log(`[start] auto-selected style: ${session.styleGuide.slice(0, 60)}…`); } tlog("[start] Architect" + (isAutoStyle ? " + StyleSelector" : ""), tArchitect); console.log(