Introduce a proper initial state
| @@ -59,9 +59,13 @@ const scan_state = { | |||
| 59 | */ | 59 | */ |
| 60 | NONE: 0, | 60 | NONE: 0, |
| 61 | /** | 61 | /** |
| 62 | * The scan is triggered by a recursion step. Initial state. | 62 | * Initial state. |
| 63 | */ | 63 | */ |
| 64 | RECURSION: 1, | 64 | INITIAL: 1, |
| 65 | /** | ||
| 66 | * The scan is triggered by a recursion step. | ||
| 67 | */ | ||
| 68 | RECURSION: 2, | ||
| 65 | /** | 69 | /** |
| 66 | * The scan is triggered by a min activations depth skew. | 70 | * The scan is triggered by a min activations depth skew. |
| 67 | */ | 71 | */ |
| @@ -3526,7 +3530,7 @@ async function checkWorldInfo(chat, maxContext, isDryRun) { | |||
| 3526 | } | 3530 | } |
| 3527 | } | 3531 | } |
| 3528 | 3532 | ||
| 3529 | let scanState = scan_state.RECURSION; | 3533 | let scanState = scan_state.INITIAL; |
| 3530 | let token_budget_overflowed = false; | 3534 | let token_budget_overflowed = false; |
| 3531 | let count = 0; | 3535 | let count = 0; |
| 3532 | let allActivatedEntries = new Set(); | 3536 | let allActivatedEntries = new Set(); |
| @@ -3551,7 +3555,8 @@ async function checkWorldInfo(chat, maxContext, isDryRun) { | |||
| 3551 | } | 3555 | } |
| 3552 | 3556 | ||
| 3553 | while (scanState) { | 3557 | while (scanState) { |
| 3554 | // Track how many times the loop has run | 3558 | // Track how many times the loop has run. May be useful for debugging. |
| 3559 | // eslint-disable-next-line no-unused-vars | ||
| 3555 | count++; | 3560 | count++; |
| 3556 | 3561 | ||
| 3557 | let activatedNow = new Set(); | 3562 | let activatedNow = new Set(); |
| @@ -3610,7 +3615,13 @@ async function checkWorldInfo(chat, maxContext, isDryRun) { | |||
| 3610 | } | 3615 | } |
| 3611 | 3616 | ||
| 3612 | // Only use checks for recursion flags if the scan step was activated by recursion | 3617 | // Only use checks for recursion flags if the scan step was activated by recursion |
| 3613 | if (scanState === scan_state.RECURSION && ((count > 1 && world_info_recursive && entry.excludeRecursion) || (count == 1 && entry.delayUntilRecursion))) { | 3618 | if (scanState !== scan_state.RECURSION && 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); | ||
| 3614 | continue; | 3625 | continue; |
| 3615 | } | 3626 | } |
| 3616 | 3627 | ||