From ba8b65b6d932e72c77cce88cf10247830b2a4157 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Tue, 16 Jun 2026 19:39:50 +0700 Subject: [PATCH] fix: remove system role from Shakespeare AI calls, embed prompt in user message instead Co-authored-by: shakespeare.diy --- src/components/SasquatchGuide.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/SasquatchGuide.tsx b/src/components/SasquatchGuide.tsx index 234a798..4c2cb68 100644 --- a/src/components/SasquatchGuide.tsx +++ b/src/components/SasquatchGuide.tsx @@ -225,13 +225,19 @@ export function SasquatchGuide({ message, onDismiss }: SasquatchGuideProps) { let accumulated = ''; // First pass: get AI response which may include a TOOL: call - // Inject system prompt as first user message if system role unsupported - const messagesWithSystem = [ - { role: 'system' as const, content: SYSTEM_PROMPT }, - ...history, - ]; + // Prefix the system prompt into the first user message for compatibility + const historyWithContext = history.length > 0 + ? [ + { + role: 'user' as const, + content: `${SYSTEM_PROMPT}\n\n---\n\nUser question: ${history[0].content}`, + }, + ...history.slice(1), + ] + : [{ role: 'user' as const, content: SYSTEM_PROMPT }]; + const firstResponse = await shakespeare.sendChatMessage( - messagesWithSystem, + historyWithContext, 'shakespeare' ); @@ -278,12 +284,9 @@ export function SasquatchGuide({ message, onDismiss }: SasquatchGuideProps) { setStreamingText(''); const toolResultStr = JSON.stringify(toolResult, null, 2); const secondResponse = await shakespeare.sendChatMessage([ - { role: 'system' as const, content: SYSTEM_PROMPT }, - ...history, - { role: 'assistant' as const, content: aiText }, { role: 'user' as const, - content: `Tool result from ${toolName}:\n${toolResultStr}\n\nNow answer the user's question naturally based on this live data. Be concise and skater-friendly.`, + content: `${SYSTEM_PROMPT}\n\n---\n\nUser asked: ${question}\n\nTool result from ${toolName}:\n${toolResultStr}\n\nNow answer the user's question naturally based on this live data. Be concise and skater-friendly.`, }, ], 'shakespeare');