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');