fix: exclude other group members' reasoning from prompt context in group chats (#5473) In group chats, only include reasoning from the currently generating character instead of all group members. This prevents reasoning from other characters being injected into the prompt context when generating responses. - Filter reasoning in coreChat loop based on message author matching name2 - Filter reasoning in setOpenAIMessages based on message author matching name2 - Add isOtherGroupMember check before adding reasoning to messages

552936a0d8c623e2ffde13c074e99743a4cd40ce

Wolfsblvt <wolfsblvt@gmail.com>

Signed
2 files changed, +11 -3Showing whitespace changes
public/script.js+7 -1
@@ -4470,9 +4470,15 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
4470 for (let i = coreChat.length - 1; i >= 0; i--) {4470 for (let i = coreChat.length - 1; i >= 0; i--) {
4471 const depth = coreChat.length - i - (isContinue ? 2 : 1);4471 const depth = coreChat.length - i - (isContinue ? 2 : 1);
4472 const isPrefix = isContinue && i === coreChat.length - 1;4472 const isPrefix = isContinue && i === coreChat.length - 1;
4473
4474 // In group chats, only include reasoning from the currently generating character
4475 const isOtherGroupMember = selected_group && coreChat[i].name !== name2;
4476
4473 coreChat[i] = {4477 coreChat[i] = {
4474 ...coreChat[i],4478 ...coreChat[i],
4475 mes: promptReasoning.addToMessage(4479 mes: isOtherGroupMember
4480 ? coreChat[i].mes
4481 : promptReasoning.addToMessage(
4476 coreChat[i].mes,4482 coreChat[i].mes,
4477 getRegexedString(4483 getRegexedString(
4478 String(coreChat[i].extra?.reasoning ?? ''),4484 String(coreChat[i].extra?.reasoning ?? ''),
public/scripts/openai.js+4 -2
@@ -604,8 +604,10 @@ function setOpenAIMessages(chat) {
604 const originApi = chat[j]?.extra?.api;604 const originApi = chat[j]?.extra?.api;
605 const originModel = chat[j]?.extra?.model;605 const originModel = chat[j]?.extra?.model;
606 const isSameModel = originApi === currentApi && originModel === currentModel;606 const isSameModel = originApi === currentApi && originModel === currentModel;
607 const signature = isSameModel ? chat[j]?.extra?.reasoning_signature : null;607 // In group chats, only include reasoning from the currently generating character
608 const reasoning = isSameModel ? String(chat[j]?.extra?.reasoning ?? '') : '';608 const isOtherGroupMember = selected_group && chat[j].name !== name2;
609 const signature = isSameModel && !isOtherGroupMember ? chat[j]?.extra?.reasoning_signature : null;
610 const reasoning = isSameModel && !isOtherGroupMember ? String(chat[j]?.extra?.reasoning ?? '') : '';
609611
610 // Remove reasoning metadata from invocations if the API/model don't match612 // Remove reasoning metadata from invocations if the API/model don't match
611 if (Array.isArray(invocations) && invocations.length > 0) {613 if (Array.isArray(invocations) && invocations.length > 0) {