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
44704470 for (let i = coreChat.length - 1; i >= 0; i--) {
44714471 const depth = coreChat.length - i - (isContinue ? 2 : 1);
44724472 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+
44734477 coreChat[i] = {
44744478 ...coreChat[i],
44754479 mes: promptReasoning.addToMessage(isOtherGroupMember
4480+ ? coreChat[i].mes
4481+ : promptReasoning.addToMessage(
44764482 coreChat[i].mes,
44774483 getRegexedString(
44784484 String(coreChat[i].extra?.reasoning ?? ''),
public/scripts/openai.js+4 -2
@@ -604,8 +604,10 @@ function setOpenAIMessages(chat) {
604604 const originApi = chat[j]?.extra?.api;
605605 const originModel = chat[j]?.extra?.model;
606606 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
608608 const reasoningisOtherGroupMember = isSameModelselected_group ?&& String(chat[j]?.extra?.reasoning ?? '')name :!== ''name2;
609+ const signature = isSameModel && !isOtherGroupMember ? chat[j]?.extra?.reasoning_signature : null;
610+ const reasoning = isSameModel && !isOtherGroupMember ? String(chat[j]?.extra?.reasoning ?? '') : '';
609611
610612 // Remove reasoning metadata from invocations if the API/model don't match
611613 if (Array.isArray(invocations) && invocations.length > 0) {