Preserve user input on tool call recursion (#5134)

Supersedes #5129
This commit is contained in:
Cohee
2026-02-11 22:49:39 +02:00
committed by GitHub
parent 00a61d370b
commit 9714374749
+5 -5
View File
@@ -4140,7 +4140,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
const isInstruct = power_user.instruct.enabled && main_api !== 'openai';
const isImpersonate = type == 'impersonate';
if (!(dryRun || type == 'regenerate' || type == 'swipe' || type == 'quiet')) {
if (!(dryRun || depth || type == 'regenerate' || type == 'swipe' || type == 'quiet')) {
const interruptedByCommand = await processCommands(String($('#send_textarea').val()));
if (interruptedByCommand) {
@@ -4229,7 +4229,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
const lastMessage = chat[chat.length - 1];
let textareaText;
if (type !== 'regenerate' && type !== 'swipe' && type !== 'quiet' && !isImpersonate && !dryRun) {
if (type !== 'regenerate' && type !== 'swipe' && type !== 'quiet' && !isImpersonate && !dryRun && !depth) {
is_send_press = true;
textareaText = String($('#send_textarea').val());
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
@@ -4238,7 +4238,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
if (chat.length && lastMessage.is_user) {
//do nothing? why does this check exist?
}
else if (type !== 'quiet' && type !== 'swipe' && !isImpersonate && !dryRun && chat.length) {
else if (type !== 'quiet' && type !== 'swipe' && !isImpersonate && !dryRun && !depth && chat.length) {
deleteItemizedPromptForMessage(chat.length - 1);
chat.length = chat.length - 1;
await removeLastMessage();
@@ -4279,7 +4279,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
'continue',
];
//for normal messages sent from user..
if ((textareaText != '' || (hasPendingFileAttachment() && !noAttachTypes.includes(type))) && !automatic_trigger && type !== 'quiet' && !dryRun) {
if ((textareaText != '' || (hasPendingFileAttachment() && !noAttachTypes.includes(type))) && !automatic_trigger && type !== 'quiet' && !dryRun && !depth) {
// If user message contains no text other than bias - send as a system message
if (messageBias && !removeMacros(textareaText)) {
sendSystemMessage(system_message_types.GENERIC, ' ', { bias: messageBias });
@@ -4288,7 +4288,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
await sendMessageAsUser(textareaText, messageBias);
}
}
else if (textareaText == '' && !automatic_trigger && !dryRun && [undefined, 'normal'].includes(type) && main_api == 'openai' && oai_settings.send_if_empty.trim().length > 0) {
else if (textareaText == '' && !automatic_trigger && !dryRun && [undefined, 'normal'].includes(type) && main_api == 'openai' && oai_settings.send_if_empty.trim().length > 0 && !depth) {
// Use send_if_empty if set and the user message is empty. Only when sending messages normally
await sendMessageAsUser(oai_settings.send_if_empty.trim(), messageBias);
}