Kaynağa Gözat

fix: append deterministic meta block to parent_canon.md

LLM was hallucinating timestamps in the meta section. Now
appends a code-generated meta block with real parentBookId,
parentTitle, and generatedAt after LLM output.
majx_mac 8 ay önce
ebeveyn
işleme
42230c2b81
1 değiştirilmiş dosya ile 13 ekleme ve 2 silme
  1. 13 2
      packages/core/src/pipeline/runner.ts

+ 13 - 2
packages/core/src/pipeline/runner.ts

@@ -745,8 +745,19 @@ ${matrix}`,
       },
       },
     ], { temperature: 0.3, maxTokens: 16384 });
     ], { temperature: 0.3, maxTokens: 16384 });
 
 
-    await writeFile(join(storyDir, "parent_canon.md"), response.content, "utf-8");
-    return response.content;
+    // Append deterministic meta block (LLM may hallucinate timestamps)
+    const metaBlock = [
+      "",
+      "---",
+      "meta:",
+      `  parentBookId: "${parentBookId}"`,
+      `  parentTitle: "${parentBook.title}"`,
+      `  generatedAt: "${new Date().toISOString()}"`,
+    ].join("\n");
+    const canon = response.content + metaBlock;
+
+    await writeFile(join(storyDir, "parent_canon.md"), canon, "utf-8");
+    return canon;
   }
   }
 
 
   // ---------------------------------------------------------------------------
   // ---------------------------------------------------------------------------