[GH-ISSUE #6126] Generating a game world uses lorebook entries you switched off for that chat #3404

Closed
opened 2026-10-21 06:02:44 +07:00 by bsakaguchi · 2 comments
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Switching a lorebook entry off for a single chat - the switch whose tooltip reads "Only affects this chat" - keeps that entry out of ordinary messages, but world generation ignores it completely. The entry's full text is still written into the prompt that creates the world, so the thing you turned off turns up in the world you get. The chat's book-level switch is respected on the same request; only the per-entry switch is ignored.

How to reproduce (try it yourself)

You need a Game Mode chat whose first world generation did not finish. That is the only window in which the per-chat switch can be set before the world call runs, because the setup screen covers Chat Settings while it is open, and closing setup on a brand-new chat deletes the chat.

  1. Start a new Game Mode chat. In the setup screen's own lorebook list, select a book that has an always-on (Constant) entry named "Shrine" whose body is The Shrine of Ash stands on the eastern ridge. It has to be Constant: this scan runs with no messages, so keyword-only entries never fire here.
  2. Finish setup using a GM connection that will fail - a wrong API key is enough. World generation fails. The campaign itself was already created, so the chat survives.
  3. Close the setup screen. You get "Game setup dismissed - the campaign was kept."
  4. Open Chat Settings (the gear on the chat header) and go to Lorebooks. The book is listed as active. Expand it, find the "Shrine" row, and flip its right-hand switch off. Hover it first: the tooltip says "Only affects this chat", and the section header says "Enable or disable entries for this chat only." The entry stays on in the shared book.
  5. Re-open setup - it re-arms by itself because the campaign is still in setup - and finish it again, this time with a working connection.

What you'll see: the Shrine of Ash is in the generated world. Its text went into the world-generation prompt.

What should happen: an entry you switched off for this chat should be left out of the world-generation prompt, exactly as it is left out of every ordinary message in that same chat.

Worth doing in the same sitting, because it shows this is one specific gap and not a general rule: instead of the per-entry switch, use the book-level exclude control in that same Lorebooks section and run it again. The whole book is correctly kept out of the world prompt. Adjacent controls, the same saved chat settings, opposite treatment.

The same leak happens on the Pixelforge path, at a second call:

  1. Sidebar -> New -> Game, switch Pixelforge on as the Experience, then make the launch fail to finish (unreachable connection, or reload while it reads "Setting up…"). The chat keeps session status setup, which is what lets you back into the setup screen.
  2. Reopen the chat, close the setup screen with the X, accept the "campaign was kept" toast.
  3. Chat Settings -> Lorebooks -> "Add lorebook" -> your book, click the pencil on its row, and switch an entry off for this chat.
  4. Reopen the chat, switch Experiences -> Pixelforge back on, tick that same entry under "Lorebook entries to read before writing the world", and press "Begin in ".

What you'll see: the stored selection is re-sent as-is and the entry you just turned off is back in the world's lore. The picker also still offers chat-disabled entries, unmarked.

Where it is

At staging 52799569c, packages/server/src/routes/game.routes.ts builds two processLorebooks option bags and neither passes entryStateOverrides:

  • line 6729, in the POST /setup handler; the resulting lore text goes straight into the setup system prompt at line 6775.
  • lines 10859-10881, in POST /:chatId/experience-generation (Pixelforge world writing). That bag passes forcedEntryIds, forcedEntriesOnly, ignoreForcedEntryProbability, generationTriggers: ["game_setup", "game"] and excludedLorebookIds from resolveLorebookScopeExclusions("game", meta) - but no entryStateOverrides.

grep -c entryStateOverrides packages/server/src/routes/game.routes.ts returns 0; nine other server files read it. The filter that would drop the entry is packages/server/src/services/lorebook/index.ts:1122-1141, and it only runs when the caller passes the option - there is no fallback that reads the chat itself. For contrast, the turn path passes both together (packages/server/src/routes/generate.routes.ts:2798 and :2806). The switch is written by PATCH /:id/lorebook-entries/:entryId in packages/server/src/routes/chats.routes.ts:1363-1387.

What's happening

The per-chat disable is stored on the chat as metadata.entryStateOverrides. The lorebook assembler applies it only if the caller hands it over. Both world-generation call sites hand over the chat's book-level exclusions but not the entry-level ones, so the chat's book-level scope is honoured on exactly the same request that ignores its entry-level scope. Nothing needs to trigger it - a Constant entry gets in on its own. A probe replaying this route's own option bag activated the chat-disabled entry and put its text in the lore block; adding entryStateOverrides to the same bag dropped it.

Suggested fix

Resolve the chat's entryStateOverrides next to resolveLorebookScopeExclusions and pass it into both processLorebooks calls in this route, the same way the chats, generate, prompts, lorebooks and dry-run routes already do. The filter runs before the forced-entry list is rebuilt, so the single added option also covers the Pixelforge "entries the player ticked" path. If the two scopes are ever meant to diverge, make that a named, documented option on the call rather than an omission. Worth a regression that pins the world-generation option bag against the turn path's, since this is the second per-chat scope to go missing on this route.

That leaves one product call, on the Pixelforge path only: a player can tick, in the world-setup picker, an entry they had switched off for that chat. Either the standing chat disable wins or the explicit tick wins, but the current behaviour is neither - the picker offers such entries with no marking, because the package can only see the global on/off column. Whichever rule you choose, this route still has to read entryStateOverrides, so the picker can be told what it is overriding. The picker half is filed separately against Marinara-Agents.

Context

PR #5981 (for issue #5954, merged 2026-09-09) added the "Only affects this chat" switch and the route that stores it, but did not touch game.routes.ts; before it merged the per-chat disable had no working writer, so nobody could reach this gap, and #5954 explicitly scoped itself away from the Pixelforge setup picker. The two world-generation option bags came from PRs #5944 and #5977, with #5942 adding the ticked-entry plumbing at the experience-generation call - all before the switch existed, so this is an omission nobody ruled on rather than a decision. Not to be confused with #3376, which was the book-level exclusion doing the same thing on this very route; that one is fixed and still works correctly. Unreleased on staging - the switch that makes this reachable landed after v2.4.4 (tagged 2026-08-25).

Found by an AI-assisted sweep of merged PR #5981 against issue #5954, then re-verified against staging 52799569c on 2026-09-13. Please verify before fixing.

Related issue from the same sweep: Pasta-Devs/Marinara-Agents#813 (the Pixelforge picker half).

Originally created by @kolacheee on GitHub (Sep 13, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6126 Originally assigned to: @SpicyMarinara on GitHub. Switching a lorebook entry off for a single chat - the switch whose tooltip reads "Only affects this chat" - keeps that entry out of ordinary messages, but world generation ignores it completely. The entry's full text is still written into the prompt that creates the world, so the thing you turned off turns up in the world you get. The chat's book-level switch is respected on the same request; only the per-entry switch is ignored. ## How to reproduce (try it yourself) You need a Game Mode chat whose first world generation did not finish. That is the only window in which the per-chat switch can be set before the world call runs, because the setup screen covers Chat Settings while it is open, and closing setup on a brand-new chat deletes the chat. 1. Start a new Game Mode chat. In the setup screen's own lorebook list, select a book that has an always-on (Constant) entry named "Shrine" whose body is `The Shrine of Ash stands on the eastern ridge.` It has to be Constant: this scan runs with no messages, so keyword-only entries never fire here. 2. Finish setup using a GM connection that will fail - a wrong API key is enough. World generation fails. The campaign itself was already created, so the chat survives. 3. Close the setup screen. You get "Game setup dismissed - the campaign was kept." 4. Open Chat Settings (the gear on the chat header) and go to Lorebooks. The book is listed as active. Expand it, find the "Shrine" row, and flip its right-hand switch off. Hover it first: the tooltip says "Only affects this chat", and the section header says "Enable or disable entries for this chat only." The entry stays on in the shared book. 5. Re-open setup - it re-arms by itself because the campaign is still in setup - and finish it again, this time with a working connection. **What you'll see:** the Shrine of Ash is in the generated world. Its text went into the world-generation prompt. **What should happen:** an entry you switched off for this chat should be left out of the world-generation prompt, exactly as it is left out of every ordinary message in that same chat. Worth doing in the same sitting, because it shows this is one specific gap and not a general rule: instead of the per-entry switch, use the book-level exclude control in that same Lorebooks section and run it again. The whole book is correctly kept out of the world prompt. Adjacent controls, the same saved chat settings, opposite treatment. The same leak happens on the Pixelforge path, at a second call: 1. Sidebar -> New -> Game, switch Pixelforge on as the Experience, then make the launch fail to finish (unreachable connection, or reload while it reads "Setting up…"). The chat keeps session status `setup`, which is what lets you back into the setup screen. 2. Reopen the chat, close the setup screen with the X, accept the "campaign was kept" toast. 3. Chat Settings -> Lorebooks -> "Add lorebook" -> your book, click the pencil on its row, and switch an entry off for this chat. 4. Reopen the chat, switch Experiences -> Pixelforge back on, tick that same entry under "Lorebook entries to read before writing the world", and press "Begin in <name>". **What you'll see:** the stored selection is re-sent as-is and the entry you just turned off is back in the world's lore. The picker also still offers chat-disabled entries, unmarked. ## Where it is At staging 52799569c, `packages/server/src/routes/game.routes.ts` builds two `processLorebooks` option bags and neither passes `entryStateOverrides`: - line 6729, in the `POST /setup` handler; the resulting lore text goes straight into the setup system prompt at line 6775. - lines 10859-10881, in `POST /:chatId/experience-generation` (Pixelforge world writing). That bag passes `forcedEntryIds`, `forcedEntriesOnly`, `ignoreForcedEntryProbability`, `generationTriggers: ["game_setup", "game"]` and `excludedLorebookIds` from `resolveLorebookScopeExclusions("game", meta)` - but no `entryStateOverrides`. `grep -c entryStateOverrides packages/server/src/routes/game.routes.ts` returns 0; nine other server files read it. The filter that would drop the entry is `packages/server/src/services/lorebook/index.ts:1122-1141`, and it only runs when the caller passes the option - there is no fallback that reads the chat itself. For contrast, the turn path passes both together (`packages/server/src/routes/generate.routes.ts:2798` and `:2806`). The switch is written by `PATCH /:id/lorebook-entries/:entryId` in `packages/server/src/routes/chats.routes.ts:1363-1387`. ## What's happening The per-chat disable is stored on the chat as `metadata.entryStateOverrides`. The lorebook assembler applies it only if the caller hands it over. Both world-generation call sites hand over the chat's book-level exclusions but not the entry-level ones, so the chat's book-level scope is honoured on exactly the same request that ignores its entry-level scope. Nothing needs to trigger it - a Constant entry gets in on its own. A probe replaying this route's own option bag activated the chat-disabled entry and put its text in the lore block; adding `entryStateOverrides` to the same bag dropped it. ## Suggested fix Resolve the chat's `entryStateOverrides` next to `resolveLorebookScopeExclusions` and pass it into both `processLorebooks` calls in this route, the same way the chats, generate, prompts, lorebooks and dry-run routes already do. The filter runs before the forced-entry list is rebuilt, so the single added option also covers the Pixelforge "entries the player ticked" path. If the two scopes are ever meant to diverge, make that a named, documented option on the call rather than an omission. Worth a regression that pins the world-generation option bag against the turn path's, since this is the second per-chat scope to go missing on this route. That leaves one product call, on the Pixelforge path only: a player can tick, in the world-setup picker, an entry they had switched off for that chat. Either the standing chat disable wins or the explicit tick wins, but the current behaviour is neither - the picker offers such entries with no marking, because the package can only see the global on/off column. Whichever rule you choose, this route still has to read `entryStateOverrides`, so the picker can be told what it is overriding. The picker half is filed separately against Marinara-Agents. ## Context PR #5981 (for issue #5954, merged 2026-09-09) added the "Only affects this chat" switch and the route that stores it, but did not touch `game.routes.ts`; before it merged the per-chat disable had no working writer, so nobody could reach this gap, and #5954 explicitly scoped itself away from the Pixelforge setup picker. The two world-generation option bags came from PRs #5944 and #5977, with #5942 adding the ticked-entry plumbing at the experience-generation call - all before the switch existed, so this is an omission nobody ruled on rather than a decision. Not to be confused with #3376, which was the book-level exclusion doing the same thing on this very route; that one is fixed and still works correctly. Unreleased on staging - the switch that makes this reachable landed after v2.4.4 (tagged 2026-08-25). Found by an AI-assisted sweep of merged PR #5981 against issue #5954, then re-verified against staging 52799569c on 2026-09-13. Please verify before fixing. Related issue from the same sweep: Pasta-Devs/Marinara-Agents#813 (the Pixelforge picker half).
bsakaguchi 2026-10-21 06:02:44 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 13, 2026):

@SpicyMarinara is taking this report through the issue sweep in draft PR #6137, with Codex assisting. The affected current-code path has been checked; implementation and focused regression verification are in progress.

<!-- gh-comment-id:5651923611 --> @SpicyMarinara commented on GitHub (Sep 13, 2026): @SpicyMarinara is taking this report through the issue sweep in draft PR #6137, with Codex assisting. The affected current-code path has been checked; implementation and focused regression verification are in progress.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 13, 2026):

Fixed in #6137, now merged to staging (e044997a2). World generation respects canonical and legacy chat-local disabled lore-entry state.

<!-- gh-comment-id:5652784107 --> @SpicyMarinara commented on GitHub (Sep 13, 2026): Fixed in #6137, now merged to staging (`e044997a2`). World generation respects canonical and legacy chat-local disabled lore-entry state.
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#3404
No description provided.