@@ -283,23 +283,39 @@ export async function getAIResponse(message, chatHistory, settings, generateRand
283283
284284 // CUSTOM: If Unity model is selected, use Mistral with Unity system prompt and tool calling
285285 let actualModel = settings . model ;
286- let effectiveSystemPrompt = settings . systemPrompt ;
286+ let effectiveSystemPrompt = '' ;
287287 let useToolCalling = supportsTools ;
288288
289289 if ( settings . model === 'unity' ) {
290290 // Use Mistral model with Unity persona and enable tool calling
291291 actualModel = 'mistral' ;
292- effectiveSystemPrompt = unitySystemPrompt + TOOL_CALLING_ADDON ;
292+ // Append user's system prompt to Unity prompt if provided
293+ if ( settings . systemPrompt && settings . systemPrompt . trim ( ) ) {
294+ effectiveSystemPrompt = unitySystemPrompt + '\n\n' + settings . systemPrompt + '\n\n' + TOOL_CALLING_ADDON ;
295+ console . log ( 'Unity model: appending user system prompt to Unity persona' ) ;
296+ } else {
297+ effectiveSystemPrompt = unitySystemPrompt + TOOL_CALLING_ADDON ;
298+ }
293299 useToolCalling = true ;
294300 console . log ( 'Unity model selected: using Mistral with Unity persona and tool calling' ) ;
301+ } else if ( isCommunityModel ) {
302+ // Community models: ignore user system prompts, only add tool calling addon if supported
303+ if ( supportsTools ) {
304+ effectiveSystemPrompt = TOOL_CALLING_ADDON . trim ( ) ;
305+ } else {
306+ effectiveSystemPrompt = '' ;
307+ }
308+ console . log ( 'Community model: user system prompts are disabled' ) ;
295309 } else if ( supportsTools ) {
296- // Add tool calling addon to system prompt for models that support it
297- // This includes community models - voice playback is already disabled for them separately
298- if ( effectiveSystemPrompt ) {
299- effectiveSystemPrompt += TOOL_CALLING_ADDON ;
310+ // Non-community models with tool support: use user system prompt + tool calling addon
311+ if ( settings . systemPrompt && settings . systemPrompt . trim ( ) ) {
312+ effectiveSystemPrompt = settings . systemPrompt + '\n\n' + TOOL_CALLING_ADDON ;
300313 } else {
301314 effectiveSystemPrompt = TOOL_CALLING_ADDON . trim ( ) ;
302315 }
316+ } else {
317+ // Non-community models without tool support: use user system prompt as-is
318+ effectiveSystemPrompt = settings . systemPrompt || '' ;
303319 }
304320
305321 // If model supports tool calling, use OpenAI endpoint
@@ -509,17 +525,21 @@ async function getAIResponseLegacy(message, model, systemPrompt, chatHistory, se
509525 url += url . includes ( '?' ) ? '&' : '?' ;
510526 url += 'private=true' ;
511527
512- // Add system prompt if specified
528+ // Add system prompt if specified (but not for community models, except Unity which is handled separately)
513529 const currentModel = getCurrentModelMetadata ( settings . model ) ;
514530 const isCommunityModel = currentModel && currentModel . community === true ;
531+ const isUnityModel = settings . model === 'unity' ;
515532
516533 if ( systemPrompt ) {
534+ // Use the provided system prompt (this should already be processed correctly)
517535 url += url . includes ( '?' ) ? '&' : '?' ;
518536 url += `system=${ encodeURIComponent ( systemPrompt ) } ` ;
519537 } else if ( settings . systemPrompt && ! isCommunityModel ) {
538+ // For non-community models, use user's system prompt
520539 url += url . includes ( '?' ) ? '&' : '?' ;
521540 url += `system=${ encodeURIComponent ( settings . systemPrompt ) } ` ;
522541 }
542+ // For community models (excluding Unity), system prompts are ignored
523543
524544 // Add reasoning effort if specified and model supports it
525545 const supportsReasoning = currentModel && currentModel . reasoning === true ;
0 commit comments