mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6122] Picking thousands of lorebook entries makes world generation fail with a refusal that never mentions lore #3401
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3401
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6122
Originally assigned to: @SpicyMarinara on GitHub.
When a player ticks a very large number of lorebook entries for an Experience's world generation, the request is turned away by the server before anything is generated, and the refusal says only that the request body is too large. Nothing tells the player how many entries they picked, how many the server will take, or that lore is the cause at all - so in Pixelforge the failure surfaces as generic "refused" copy telling them to shorten their setting description, which is the wrong advice and cannot fix it. Unticking entries clears it immediately, but there is no way for the player to learn that.
How to reproduce (try it yourself)
The quick way, on the wire (30 seconds, no giant lorebook needed). With your own Engine running, run this against a chat id that does not exist - a real id would run a live, paid generation call for the first request:
What you'll see:
101 2603 404 {"error":"Chat not found"}and3000 75078 413 {"error":"The request body is larger than this endpoint accepts."}. The 404 on 101 ids proves validation accepted the list (the id check runs after validation). The 3,000-id call never reaches the handler - it dies at the socket with a message that names no count and carries no machine-readable code.What should happen: the over-long selection should come back as a counted refusal that names how many entries were sent and how many are accepted, in the same family as the
context_limit422 this route already returns when the selection is too big for the model's context.The in-app way (the path a player actually walks):
A damp river town under a broken aqueduct.What you'll see: the world-generation step drops straight to the retry screen reading "The request was turned down rather than delayed... a shorter, plainer setting description is the likeliest thing to change it." Retry fails identically. The browser console shows
413 The request body is larger than this endpoint accepts.What should happen: the refusal should say the selection is too large and that unticking entries is the fix.
The exact threshold depends on how much the player typed - measured against the real request body it sits at about 2,450 ticked entries (2,446 once a world name and a setting line are in the body). Tick one fewer and generation proceeds normally.
Where it is
At staging
52799569c:packages/server/src/routes/game.routes.ts:10770-lorebookEntryIds: z.array(z.string()).optional()(no.max), with{ bodyLimit: 64 * 1024 }on the route at:10775.packages/server/src/routes/game.routes.ts:10769- the field's own comment says "The complete selection is checked against model context before generation", which is not what happens past the byte limit: the request never reaches the context fit at:11050.packages/server/src/middleware/error-handler.ts:20-26- the 413 body is deliberately number-free, because the app-wide limit and the per-route limits differ.packages/server/src/services/lorebook/index.ts:1085-1087andpackages/server/src/services/storage/lorebooks.storage.ts:662- the forced-entries path passesunlimited: true, so nothing downstream re-imposes a count.LIMITS.MAX_LOREBOOK_ENTRIES(packages/shared/src/constants/defaults.ts:100) is now unreachable on this path.What's happening
The route's 64 KB body limit was sized when the route was created (#5135), for a body of instructions plus user content plus schema - before
lorebookEntryIdsexisted. #5944 later added the id array under a count cap of 100, which kept the byte limit out of reach. #5977 removed that cap on purpose (per #5953) and did not revisit the byte limit, so the byte limit is now the only surviving ceiling on how many entries a player can pick. Nobody chose 2,450; it is what 64 KB divides into at roughly 24 bytes per entry id. Because the request dies at the transport layer, the handler's well-shaped counted refusals never run, and the caller gets a bare 413.Suggested fix
This is not a request to re-impose a count cap - #5953 settled that there should not be one. Two parts:
bodyLimitso a lore selection can never hit the byte wall before the checks that produce a good message. The body is a list of short ids plus a fixed prompt, so the ceiling can be generous.context_limitrefusal - a distinctcode, the number the player sent, and the number accepted - so a client can say "you picked N entries; untick some" instead of inheriting a transport-level error with no count.A useful place to surface such a limit in the picker would be the "Select all" readout, which currently reports a total with no upper bound.
Context
Introduced by merged PR #5977 (commit
848e8fa3d), which implemented the maintainer call in #5953 by removing the.max(LIMITS.MAX_LOREBOOK_ENTRIES)that PR #5944 had added, and deleted the regression scenario that pinned the old counted 400. #5953 anticipated this gap ("uncap and fix that failure message in the same change so an over-large selection says so plainly"); thecontext_limithalf landed, this half did not. Unreleased on staging -848e8fa3dis not in any tag, and the latest release is v2.4.4. The client half (Pixelforge has no branch for a 413 in its failure ladder, so it lands on "refused" copy that blames the setting description) is a separate Marinara-Agents issue and should be fixed there too, since a 413 can also arrive from an older Engine.Found by an AI-assisted sweep of merged PR #5977 against issue #5953, then re-verified against staging
52799569con 2026-09-13. Please verify before fixing.Related issue from the same sweep: Pasta-Devs/Marinara-Agents#812 (the Pixelforge-side failure copy for the same 413).
@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.
@SpicyMarinara commented on GitHub (Sep 13, 2026):
Fixed in #6137, now merged to staging (
e044997a2). World generation accepts large lore selections with a larger bounded request limit.