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
Signed| @@ -4470,9 +4470,15 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 4470 | 4470 | for (let i = coreChat.length - 1; i >= 0; i--) { |
| 4471 | 4471 | const depth = coreChat.length - i - (isContinue ? 2 : 1); |
| 4472 | 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 | 4477 | coreChat[i] = { |
| 4474 | 4478 | ...coreChat[i], |
| 4475 | 4479 | mes: promptReasoning.addToMessage(isOtherGroupMember |
| 4480 | + ? coreChat[i].mes | |
| 4481 | + : promptReasoning.addToMessage( | |
| 4476 | 4482 | coreChat[i].mes, |
| 4477 | 4483 | getRegexedString( |
| 4478 | 4484 | String(coreChat[i].extra?.reasoning ?? ''), |
| @@ -604,8 +604,10 @@ function setOpenAIMessages(chat) { | ||
| 604 | 604 | const originApi = chat[j]?.extra?.api; |
| 605 | 605 | const originModel = chat[j]?.extra?.model; |
| 606 | 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 | 608 | 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 ?? '') : ''; | |
| 609 | 611 | |
| 610 | 612 | // Remove reasoning metadata from invocations if the API/model don't match |
| 611 | 613 | if (Array.isArray(invocations) && invocations.length > 0) { |