diff --git a/src/extension.ts b/src/extension.ts index e47cca3..fd9a4d0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1475,10 +1475,16 @@ class SidebarChatProvider implements vscode.WebviewViewProvider { const internetCtx = internetEnabled ? `\n\n[CRITICAL DIRECTIVE: INTERNET ACCESS IS ENABLED]\nCurrent Time: ${new Date().toLocaleString('ko-KR')}\nYou have FULL internet access via the tool. You MUST NEVER say you cannot search, or that your capabilities are limited. To search, ALWAYS output:\nhttps://html.duckduckgo.com/html/?q=YOUR+SEARCH+TERM\nIf the user asks to search, or asks for recent info, DO NOT apologize. Just use the tag.` : ''; - reqMessages[0] = { - role: 'system', - content: `${this._systemPrompt}\n\n[BACKGROUND CONTEXT]\n${contextBlock}\n${workspaceCtx}\n${brainCtx}${internetCtx}` - }; + const systemContent = `${this._systemPrompt}\n\n[BACKGROUND CONTEXT]\n${contextBlock}\n${workspaceCtx}\n${brainCtx}${internetCtx}`; + reqMessages.shift(); // Remove system message to avoid Jinja template issues in some models + + const firstUserIdx = reqMessages.findIndex(m => m.role === 'user'); + if (firstUserIdx >= 0) { + reqMessages[firstUserIdx] = { + ...reqMessages[firstUserIdx], + content: `${systemContent}\n\n[USER QUERY]\n${reqMessages[firstUserIdx].content}` + }; + } } // Build image payload for vision models @@ -1657,10 +1663,16 @@ class SidebarChatProvider implements vscode.WebviewViewProvider { const internetCtx = internetEnabled ? `\n\n[CRITICAL DIRECTIVE: INTERNET ACCESS IS ENABLED]\nCurrent Time: ${new Date().toLocaleString('ko-KR')}\nYou have FULL internet access via the tool. You MUST NEVER say you cannot search, or that your capabilities are limited. To search, ALWAYS output:\nhttps://html.duckduckgo.com/html/?q=YOUR+SEARCH+TERM\nIf the user asks to search, or asks for recent info, DO NOT apologize. Just use the tag.` : ''; - reqMessages[0] = { - role: 'system', - content: `${SYSTEM_PROMPT}\n\n[BACKGROUND CONTEXT - DO NOT EXPLAIN THIS TO THE USER UNLESS ASKED]\n${contextBlock}\n${workspaceCtx}\n${brainCtx}${internetCtx}` - }; + const systemContent = `${SYSTEM_PROMPT}\n\n[BACKGROUND CONTEXT - DO NOT EXPLAIN THIS TO THE USER UNLESS ASKED]\n${contextBlock}\n${workspaceCtx}\n${brainCtx}${internetCtx}`; + reqMessages.shift(); // Remove system message to avoid Jinja template issues in some models + + const firstUserIdx = reqMessages.findIndex(m => m.role === 'user'); + if (firstUserIdx >= 0) { + reqMessages[firstUserIdx] = { + ...reqMessages[firstUserIdx], + content: `${systemContent}\n\n[USER QUERY]\n${reqMessages[firstUserIdx].content}` + }; + } } let isLMStudio = ollamaBase.includes('1234') || ollamaBase.includes('v1');