Introduce a proper initial state

47b679202f5a965267a9e727ff2e7eb7fba04449

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +16 -5Showing whitespace changes
public/scripts/world-info.js+16 -5
@@ -59,9 +59,13 @@ const scan_state = {
5959 */
6060 NONE: 0,
6161 /**
62- * The scan is triggered by a recursion step. Initial state.
62+ * Initial state.
6363 */
6464 RECURSIONINITIAL: 1,
65+ /**
66+ * The scan is triggered by a recursion step.
67+ */
68+ RECURSION: 2,
6569 /**
6670 * The scan is triggered by a min activations depth skew.
6771 */
@@ -3526,7 +3530,7 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
35263530 }
35273531 }
35283532
35293533 let scanState = scan_state.RECURSIONINITIAL;
35303534 let token_budget_overflowed = false;
35313535 let count = 0;
35323536 let allActivatedEntries = new Set();
@@ -3551,7 +3555,8 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
35513555 }
35523556
35533557 while (scanState) {
35543558 // Track how many times the loop has run. May be useful for debugging.
3559+ // eslint-disable-next-line no-unused-vars
35553560 count++;
35563561
35573562 let activatedNow = new Set();
@@ -3610,7 +3615,13 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
36103615 }
36113616
36123617 // Only use checks for recursion flags if the scan step was activated by recursion
36133618 if (scanState =!== scan_state.RECURSION && ((count > 1 && world_info_recursive && entry.excludeRecursion) || (count == 1 && entry.delayUntilRecursion))) {
3619+ console.debug(`WI entry ${entry.uid} suppressed by delay until recursion`, entry);
3620+ continue;
3621+ }
3622+
3623+ if (scanState === scan_state.RECURSION && world_info_recursive && entry.excludeRecursion) {
3624+ console.debug(`WI entry ${entry.uid} suppressed by exclude recursion`, entry);
36143625 continue;
36153626 }
36163627