Fix min activations not checking recursion

5e89dc35e38e53c41365b8d3a108a49ed5912077

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +15 -1Ignore whitespace
public/scripts/world-info.js+15 -1
@@ -300,6 +300,14 @@ class WorldInfoBuffer {
300 }300 }
301301
302 /**302 /**
303 * Checks if the recursion buffer is not empty.
304 * @returns {boolean} Returns true if the recursion buffer is not empty, otherwise false
305 */
306 hasRecurse() {
307 return this.#recurseBuffer.length > 0;
308 }
309
310 /**
303 * Increments skew and sets startDepth to previous depth.311 * Increments skew and sets startDepth to previous depth.
304 */312 */
305 advanceScanPosition() {313 advanceScanPosition() {
@@ -3847,11 +3855,17 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
3847 console.debug(`[WI] Sucessfully activated ${successfulNewEntries.length} new entries to prompt. ${allActivatedEntries.size} total entries activated.`, successfulNewEntries);3855 console.debug(`[WI] Sucessfully activated ${successfulNewEntries.length} new entries to prompt. ${allActivatedEntries.size} total entries activated.`, successfulNewEntries);
3848 }3856 }
38493857
3850 // After processing and rolling entries is done, see if we should continue with recursion3858 // After processing and rolling entries is done, see if we should continue with normal recursion
3851 if (world_info_recursive && !token_budget_overflowed && successfulNewEntriesForRecursion.length) {3859 if (world_info_recursive && !token_budget_overflowed && successfulNewEntriesForRecursion.length) {
3852 nextScanState = scan_state.RECURSION;3860 nextScanState = scan_state.RECURSION;
3853 }3861 }
38543862
3863 // If we are inside min activations scan, and we have recursive buffer, we should do a recursive scan before increasing the buffer again
3864 // There might be recurse-trigger-able entries that match the buffer, so we need to check that
3865 if (world_info_recursive && !token_budget_overflowed && scanState === scan_state.MIN_ACTIVATIONS && buffer.hasRecurse()) {
3866 nextScanState = scan_state.RECURSION;
3867 }
3868
3855 // If scanning is planned to stop, but min activations is set and not satisfied, check if we should continue3869 // If scanning is planned to stop, but min activations is set and not satisfied, check if we should continue
3856 const minActivationsNotSatisfied = world_info_min_activations > 0 && (allActivatedEntries.size < world_info_min_activations);3870 const minActivationsNotSatisfied = world_info_min_activations > 0 && (allActivatedEntries.size < world_info_min_activations);
3857 if (!nextScanState && !token_budget_overflowed && minActivationsNotSatisfied) {3871 if (!nextScanState && !token_budget_overflowed && minActivationsNotSatisfied) {