diff --git a/index.js b/index.js
index 1a1bcb9..27c8b7b 100644
--- a/index.js
+++ b/index.js
@@ -330,14 +330,22 @@ eventSource.on(event_types.CHAT_COMPLETION_PROMPT_READY, async (data) => {
     const n = data.chat.length - system_message_count;
     const messages = data.chat.slice(-n);
     const separator = { newline: '\n', space: ' ' }[activeSet.messages_separator] || '\n\n';
+    let lastMessage = null;

+    // Only separate last assistant message if we're not squashing as assistant
+    if (messages[messages.length - 1].role === MessageRole.ASSISTANT &&
+        extension_settings.NoAss.squash_role !== MessageRole.ASSISTANT) {
+        lastMessage = messages.pop();
+    }
+
+    // Build chat history from remaining messages
     let chatHistory = messages.slice(1).reduce((history, message, idx) => {
         const timestampDict = { timestamp: getSendDate(idx) };
         let prefix = substituteParamsExtended(message.role === MessageRole.USER ? activeSet.user_prefix : activeSet.char_prefix, timestampDict);
-        let suffix = substituteParamsExtended(message.role === MessageRole.USER ? activeSet.user_suffix: activeSet.char_suffix, timestampDict);
+        let suffix = substituteParamsExtended(message.role === MessageRole.USER ? activeSet.user_suffix : activeSet.char_suffix, timestampDict);
         return `${history}${separator}${prefix}${message.content}${suffix}`;
     }, messages[0].content);
-        
+
     if (extension_settings.NoAss.enable_zero_prefill) {
         const pseudoPrefill = separator + substituteParamsExtended(activeSet.char_prefix, {timestamp: getSendDate()});
         chatHistory += (messages[messages.length - 1].role === MessageRole.ASSISTANT ? '' : pseudoPrefill);
@@ -351,11 +359,17 @@ eventSource.on(event_types.CHAT_COMPLETION_PROMPT_READY, async (data) => {
         };
     }

+    // Replace messages with squashed history
     data.chat.splice(-n, n, {
         role: extension_settings.NoAss.squash_role,
         content: chatHistory
     });

+    // If we had a last assistant message, add it back
+    if (lastMessage) {
+        data.chat.push(lastMessage);
+    }
+
     if (extension_settings.NoAss.human_prompt_active) {
         const humanPromptBefore = substituteParamsExtended(extension_settings.NoAss.human_prompt_before, { timestamp: getSendDate() });
         const humanPromptAfter = substituteParamsExtended(extension_settings.NoAss.human_prompt_after, { timestamp: getSendDate() });
Edit

Pub: 23 Jan 2025 10:13 UTC

Edit: 23 Jan 2025 10:21 UTC

Views: 295