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, +19 -11Ignore whitespace
public/script.js+15 -9
@@ -4470,18 +4470,24 @@ 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
44764480 ? coreChat[i].mes,
4477- getRegexedString(
4481+ : promptReasoning.addToMessage(
44784482 String(coreChat[i].extra?.reasoning ?? '')mes,
4479- regex_placement.REASONING,
4483+ getRegexedString(
4480- { isPrompt: true, depth: depth },
4484+ String(coreChat[i].extra?.reasoning ?? ''),
4485+ regex_placement.REASONING,
4486+ { isPrompt: true, depth: depth },
4487+ ),
4488+ isPrefix,
4489+ coreChat[i].extra?.reasoning_duration,
44814490 ),
4482- isPrefix,
4483- coreChat[i].extra?.reasoning_duration,
4484- ),
44854491 };
44864492 if (promptReasoning.isLimitReached()) {
44874493 break;
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) {