[GH-ISSUE #2975] [Issue]: Ephemeral activation counter is decremented on sticky carry-over, auto-disabling entries after a single real trigger #1550

Closed
opened 2026-10-21 05:38:53 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2975

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

An entry that uses both ephemeral (activations remaining before auto-disable) and sticky (stay active for N messages after a trigger) burns an ephemeral charge on every turn it is kept alive by sticky, even though no fresh keyword match occurred. The timing subsystem deliberately treats sticky carry-over as not a real activation, but the ephemeral countdown does not. Result: an entry configured for, say, 2 ephemeral activations with sticky = 5 is disabled after a single real trigger (the sticky tail eats the remaining charge), so it never fires again on a later genuine keyword match in that chat.

How to reproduce (try it yourself)

  1. Create a lorebook entry with keys = ["dragon"], ephemeral = 2, sticky = 5, in a chat (a chatId is present so per-chat overrides are tracked).
  2. Turn 1: user says "dragon". Entry activates via the keyword; ephemeral decrements 2→1; sticky count is set to 5.
  3. Turn 2: user says something with no "dragon". The entry re-activates via sticky carry-over.

You'll see: ephemeral decrements 1→0 and the entry is written enabled:false for this chat. A later real "dragon" mention does not re-activate it.
Expected: sticky carry-over does not consume an ephemeral charge; the entry retains its second allotted activation.

Where it is

  • packages/server/src/services/lorebook/index.ts:975-984 (per-chat overrides block) and :988-996 (legacy chatId block) — both decrement on if (a.entry.ephemeral !== null && a.entry.ephemeral > 0) with no !a.sticky guard.
  • The scanner emits sticky carry-overs as activated entries with sticky: true and matchedKeys: ["[sticky]"] at packages/server/src/services/lorebook/keyword-scanner.ts:475-484.
  • Intent reference: packages/server/src/services/lorebook/keyword-scanner.ts:257 gates the fresh-activation branch on !activated.sticky.

What's happening

The ephemeral decrement loop iterates finalActivated and decrements any entry with ephemeral > 0 unconditionally, without skipping entries whose activation came from sticky carry-over (a.sticky === true). This contradicts updateTimingStatesForScan, which already establishes that sticky carry-over is not a new activation. Since ephemeral means "activations remaining", sticky carry-overs should not consume a charge.

Suggested fix

Guard the ephemeral decrement on a non-sticky activation, mirroring the timing logic — change the condition to if (!a.sticky && a.entry.ephemeral !== null && a.entry.ephemeral > 0) in both the overrides block (:975-984) and the legacy chatId block (:988-996). Only [sticky] carry-overs set a.sticky === true, so fresh keyword and constant activations still decrement as before.


AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2975 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** An entry that uses both `ephemeral` (activations remaining before auto-disable) and `sticky` (stay active for N messages after a trigger) burns an ephemeral charge on **every** turn it is kept alive by sticky, even though no fresh keyword match occurred. The timing subsystem deliberately treats sticky carry-over as **not** a real activation, but the ephemeral countdown does not. Result: an entry configured for, say, 2 ephemeral activations with `sticky = 5` is disabled after a **single** real trigger (the sticky tail eats the remaining charge), so it never fires again on a later genuine keyword match in that chat. **How to reproduce (try it yourself)** 1. Create a lorebook entry with `keys = ["dragon"]`, `ephemeral = 2`, `sticky = 5`, in a chat (a chatId is present so per-chat overrides are tracked). 2. Turn 1: user says "dragon". Entry activates via the keyword; ephemeral decrements 2→1; sticky count is set to 5. 3. Turn 2: user says something with no "dragon". The entry re-activates via sticky carry-over. **You'll see:** ephemeral decrements 1→0 and the entry is written `enabled:false` for this chat. A later real "dragon" mention does **not** re-activate it. **Expected:** sticky carry-over does not consume an ephemeral charge; the entry retains its second allotted activation. **Where it is** - `packages/server/src/services/lorebook/index.ts:975-984` (per-chat overrides block) and `:988-996` (legacy chatId block) — both decrement on `if (a.entry.ephemeral !== null && a.entry.ephemeral > 0)` with **no** `!a.sticky` guard. - The scanner emits sticky carry-overs as activated entries with `sticky: true` and `matchedKeys: ["[sticky]"]` at `packages/server/src/services/lorebook/keyword-scanner.ts:475-484`. - Intent reference: `packages/server/src/services/lorebook/keyword-scanner.ts:257` gates the fresh-activation branch on `!activated.sticky`. **What's happening** The ephemeral decrement loop iterates `finalActivated` and decrements any entry with `ephemeral > 0` unconditionally, without skipping entries whose activation came from sticky carry-over (`a.sticky === true`). This contradicts `updateTimingStatesForScan`, which already establishes that sticky carry-over is not a new activation. Since `ephemeral` means "activations remaining", sticky carry-overs should not consume a charge. **Suggested fix** Guard the ephemeral decrement on a non-sticky activation, mirroring the timing logic — change the condition to `if (!a.sticky && a.entry.ephemeral !== null && a.entry.ephemeral > 0)` in both the overrides block (`:975-984`) and the legacy chatId block (`:988-996`). Only `[sticky]` carry-overs set `a.sticky === true`, so fresh keyword and constant activations still decrement as before. --- *AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 29, 2026):

Fixed in the v2.0.7 branch: sticky carry-over activations no longer decrement ephemeral counters; only fresh activations spend the ephemeral budget. Validated with pnpm check and pnpm regression:prompt.

<!-- gh-comment-id:4831161993 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Fixed in the v2.0.7 branch: sticky carry-over activations no longer decrement ephemeral counters; only fresh activations spend the ephemeral budget. Validated with pnpm check and pnpm regression:prompt.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1550
No description provided.