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
This commit is contained in:
Wolfsblvt
2026-04-19 15:08:52 +02:00
committed by GitHub
parent d1e719eb48
commit 552936a0d8
2 changed files with 19 additions and 11 deletions
+15 -9
View File
@@ -4470,18 +4470,24 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
for (let i = coreChat.length - 1; i >= 0; i--) {
const depth = coreChat.length - i - (isContinue ? 2 : 1);
const isPrefix = isContinue && i === coreChat.length - 1;
// In group chats, only include reasoning from the currently generating character
const isOtherGroupMember = selected_group && coreChat[i].name !== name2;
coreChat[i] = {
...coreChat[i],
mes: promptReasoning.addToMessage(
coreChat[i].mes,
getRegexedString(
String(coreChat[i].extra?.reasoning ?? ''),
regex_placement.REASONING,
{ isPrompt: true, depth: depth },
mes: isOtherGroupMember
? coreChat[i].mes
: promptReasoning.addToMessage(
coreChat[i].mes,
getRegexedString(
String(coreChat[i].extra?.reasoning ?? ''),
regex_placement.REASONING,
{ isPrompt: true, depth: depth },
),
isPrefix,
coreChat[i].extra?.reasoning_duration,
),
isPrefix,
coreChat[i].extra?.reasoning_duration,
),
};
if (promptReasoning.isLimitReached()) {
break;
+4 -2
View File
@@ -604,8 +604,10 @@ function setOpenAIMessages(chat) {
const originApi = chat[j]?.extra?.api;
const originModel = chat[j]?.extra?.model;
const isSameModel = originApi === currentApi && originModel === currentModel;
const signature = isSameModel ? chat[j]?.extra?.reasoning_signature : null;
const reasoning = isSameModel ? String(chat[j]?.extra?.reasoning ?? '') : '';
// In group chats, only include reasoning from the currently generating character
const isOtherGroupMember = selected_group && chat[j].name !== name2;
const signature = isSameModel && !isOtherGroupMember ? chat[j]?.extra?.reasoning_signature : null;
const reasoning = isSameModel && !isOtherGroupMember ? String(chat[j]?.extra?.reasoning ?? '') : '';
// Remove reasoning metadata from invocations if the API/model don't match
if (Array.isArray(invocations) && invocations.length > 0) {