fix: skip default rule reminder when story has custom narrativeRules
This commit is contained in:
@@ -267,6 +267,7 @@ ${story.plot}`;
|
||||
export function buildDynamicContext(
|
||||
session: GameSession,
|
||||
messageCount?: number,
|
||||
hasCustomRules?: boolean,
|
||||
): string {
|
||||
const state = session.currentState;
|
||||
const summary = session.storySummary || "The story just began.";
|
||||
@@ -275,8 +276,9 @@ export function buildDynamicContext(
|
||||
: "No significant events yet.";
|
||||
|
||||
// Add rule reminders after 10+ messages to prevent drift
|
||||
// Skip if story has custom rules - they take priority
|
||||
const ruleReminder =
|
||||
messageCount && messageCount >= 10
|
||||
messageCount && messageCount >= 10 && !hasCustomRules
|
||||
? `
|
||||
|
||||
=== REMINDER ===
|
||||
@@ -326,8 +328,9 @@ export async function generateStoryResponse(
|
||||
const worldContext = buildWorldContext(story);
|
||||
|
||||
// 3. Dynamic context (state + summary + rule reminders after 10+ messages)
|
||||
const hasCustomRules = Boolean(story.narrativeRules?.trim());
|
||||
const dynamicContext = session
|
||||
? buildDynamicContext(session, chatHistory.length)
|
||||
? buildDynamicContext(session, chatHistory.length, hasCustomRules)
|
||||
: "";
|
||||
|
||||
// 4. Last N messages (not the full history!)
|
||||
@@ -363,8 +366,9 @@ export async function generateStoryResponseStream(
|
||||
): Promise<string> {
|
||||
const styleRules = buildStyleRules(story, player);
|
||||
const worldContext = buildWorldContext(story);
|
||||
const hasCustomRules = Boolean(story.narrativeRules?.trim());
|
||||
const dynamicContext = session
|
||||
? buildDynamicContext(session, chatHistory.length)
|
||||
? buildDynamicContext(session, chatHistory.length, hasCustomRules)
|
||||
: "";
|
||||
const recentMessages = chatHistory.slice(-RECENT_MESSAGES_COUNT);
|
||||
const systemPrompt = styleRules + "\n" + worldContext + "\n" + dynamicContext;
|
||||
|
||||
Reference in New Issue
Block a user