diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 8fc8a19a2..abb559d64 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -3940,8 +3940,16 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) { } console.debug(`[WI] Search done. Found ${activatedNow.size} possible entries.`); + + // Sort the entries for the probability and the budget limit checks const newEntries = [...activatedNow] - .sort((a, b) => sortedEntries.indexOf(a) - sortedEntries.indexOf(b)); + .sort((a, b) => { + const isASticky = timedEffects.isEffectActive('sticky', a) ? 1 : 0; + const isBSticky = timedEffects.isEffectActive('sticky', b) ? 1 : 0; + return isBSticky - isASticky || sortedEntries.indexOf(a) - sortedEntries.indexOf(b); + }); + + let newContent = ''; const textToScanTokens = await getTokenCountAsync(allActivatedText);