[GH-ISSUE #5953] World generation shouldn't cap how much lorebook a player can feed it #3294

Closed
opened 2026-10-21 06:01:45 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Maintainer call: there shouldn't be a cap here. If a player wants to throw a 200k-token lorebook at world generation, that's their prerogative.

Three walls stand between a selection and the model today, and removing the obvious one barely helps.

  1. The call-wide 3,000-token budget — EXPERIENCE_LORE_TOKEN_BUDGET (packages/server/src/routes/game.routes.ts:10772), passed as currentLocationTokenBudget and applied in applyCurrentLocationLoreBudget (services/lorebook/index.ts:641-673). Whole entries are dropped once the running total exceeds it. 0 disables it, following the same convention as every other budget in that file.
  2. Each book's own tokenBudget — default 2,048 (db/schema/lorebooks.ts:13), applied after the first wall in trySelectBudgetedLorebookEntry (services/lorebook/index.ts:692-694), and not overridable by any caller: there's no field for it on the processLorebooks options bag, and every read comes straight off the DB row. It's editable by the book's owner in the lorebook editor (LorebookEditor.tsx:2302-2318, 0 = unlimited and persists as 0).
  3. A 100-entry count cap — the wire schema (game.routes.ts:10818) and each book's entryLimit (default 100). Neither is about tokens.

So raising or deleting the constant in (1) buys nothing once a selection exceeds 2,048 tokens from a single book — the book's own wall cuts it, and the player has no way to know why. The route also never wires the chat's own configured lorebook budget (resolveLorebookTokenBudget), silently using the 8,192 default instead — worth deciding deliberately while we're here.

Suggested shape: an explicitly picked entry bypasses both budget walls. Those budgets exist to stop automatic keyword/semantic activation from eating a chat's context. An entry the player ticked by hand isn't automatic — it's an instruction. That makes the feature behave the way the picker's UI already implies, without asking players to go edit the token budget of every book they own.

Prerequisite: #5952, or this fails badly instead of failing usefully. Nothing else in the Engine binds first — there's no per-entry content cap, the request body limit never sees the lore (the server resolves it from storage), and the output cap is independent. The first real wall is the model's own context window, and this route never calls fitMessagesToModelAccessContext the way its six siblings do. Today an oversized prompt comes back as a generic provider rejection → 422 with truncated: false (game.routes.ts:11089-11101), which is not the truncation shape that triggers a retry. Pixelforge then shows "The world didn't finish being written… a shorter, plainer setting description is the likeliest thing to change it" (packages/pixelforge/src/60-save.js:291-293) — blaming the player's typed setting when the real cause was their lore picks, which are never mentioned and only visible in devtools.

So either land context-fitting first, or uncap and fix that failure message in the same change so an over-large selection says so plainly.

Package side follows, not leads: Pixelforge 0.16.2's picker computes its own running counts against these same walls so it never promises a selection the server will trim. Whatever the server does here, the picker's arithmetic has to move with it or it will start refusing selections the server would happily accept.

Originally created by @kolacheee on GitHub (Sep 8, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5953 Originally assigned to: @SpicyMarinara on GitHub. Maintainer call: there shouldn't be a cap here. If a player wants to throw a 200k-token lorebook at world generation, that's their prerogative. **Three walls stand between a selection and the model today, and removing the obvious one barely helps.** 1. **The call-wide 3,000-token budget** — `EXPERIENCE_LORE_TOKEN_BUDGET` (`packages/server/src/routes/game.routes.ts:10772`), passed as `currentLocationTokenBudget` and applied in `applyCurrentLocationLoreBudget` (`services/lorebook/index.ts:641-673`). Whole entries are dropped once the running total exceeds it. `0` disables it, following the same convention as every other budget in that file. 2. **Each book's own `tokenBudget`** — default 2,048 (`db/schema/lorebooks.ts:13`), applied *after* the first wall in `trySelectBudgetedLorebookEntry` (`services/lorebook/index.ts:692-694`), and **not overridable by any caller**: there's no field for it on the `processLorebooks` options bag, and every read comes straight off the DB row. It's editable by the book's owner in the lorebook editor (`LorebookEditor.tsx:2302-2318`, `0` = unlimited and persists as `0`). 3. **A 100-entry count cap** — the wire schema (`game.routes.ts:10818`) and each book's `entryLimit` (default 100). Neither is about tokens. So raising or deleting the constant in (1) buys nothing once a selection exceeds 2,048 tokens *from a single book* — the book's own wall cuts it, and the player has no way to know why. The route also never wires the chat's own configured lorebook budget (`resolveLorebookTokenBudget`), silently using the 8,192 default instead — worth deciding deliberately while we're here. **Suggested shape: an explicitly picked entry bypasses both budget walls.** Those budgets exist to stop *automatic* keyword/semantic activation from eating a chat's context. An entry the player ticked by hand isn't automatic — it's an instruction. That makes the feature behave the way the picker's UI already implies, without asking players to go edit the token budget of every book they own. **Prerequisite: #5952, or this fails badly instead of failing usefully.** Nothing else in the Engine binds first — there's no per-entry content cap, the request body limit never sees the lore (the server resolves it from storage), and the output cap is independent. The first real wall is the model's own context window, and this route never calls `fitMessagesToModelAccessContext` the way its six siblings do. Today an oversized prompt comes back as a generic provider rejection → `422` with `truncated: false` (`game.routes.ts:11089-11101`), which is *not* the truncation shape that triggers a retry. Pixelforge then shows "The world didn't finish being written… a shorter, plainer setting description is the likeliest thing to change it" (`packages/pixelforge/src/60-save.js:291-293`) — blaming the player's typed setting when the real cause was their lore picks, which are never mentioned and only visible in devtools. So either land context-fitting first, or uncap and fix that failure message in the same change so an over-large selection says so plainly. **Package side follows, not leads:** Pixelforge 0.16.2's picker computes its own running counts against these same walls so it never promises a selection the server will trim. Whatever the server does here, the picker's arithmetic has to move with it or it will start refusing selections the server would happily accept.
Author
Owner

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

Ownership: @SpicyMarinara, implemented by Codex in this sweep together with #5952. The Engine draft on fix/worldgen-selected-lore-context-5952-5953 will preserve explicit selections in full and enforce the model context boundary. Pixelforge picker arithmetic and error copy belong to Marinara-Agents and will be updated there in a linked staging PR.

<!-- gh-comment-id:5592500913 --> @SpicyMarinara commented on GitHub (Sep 8, 2026): Ownership: @SpicyMarinara, implemented by Codex in this sweep together with #5952. The Engine draft on fix/worldgen-selected-lore-context-5952-5953 will preserve explicit selections in full and enforce the model context boundary. Pixelforge picker arithmetic and error copy belong to Marinara-Agents and will be updated there in a linked staging PR.
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#3294
No description provided.