[GH-ISSUE #5952] Experience-generation prompt is never fitted to the model's context window #3296

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Flagged by CodeRabbit on PR #5944 just as it merged; verified real and pre-existing — filing rather than reopening.

POST /game/:chatId/experience-generation sends its prompt to the provider without fitMessagesToModelAccessContext, which this same file applies on six other generation paths (e.g. /session/conclude, /storyboard/generate). The route accepts up to 16,000 chars of instructions plus 8,000 of userContent, and since #5944 an opted-in lore selection can add up to the 3,000-token forced-entry budget on top. On a small-context model the combination can exceed the input window with no trimming — the player sees an opaque provider rejection (which the package's retry ladder reads as a transient) instead of a graceful degradation.

The gap predates #5944 — the route has never fitted — but the lore budget makes it meaningfully easier to hit.

Likely shape: reuse the model access policy already resolved for the connection (resolveGameModelAccessPolicy, used elsewhere in the file) and fit the composed messages before the call, preserving content when it fits. One design note for whoever picks this up: naive tail-trimming would eat the lore block first (it is appended to the system slot), silently defeating the just-shipped selection — the fit should prefer trimming userContent/instructions padding or fail with an honest, non-transient message the package can surface.

Originally created by @kolacheee on GitHub (Sep 8, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5952 Originally assigned to: @SpicyMarinara on GitHub. Flagged by CodeRabbit on PR #5944 just as it merged; verified real and **pre-existing** — filing rather than reopening. `POST /game/:chatId/experience-generation` sends its prompt to the provider without `fitMessagesToModelAccessContext`, which this same file applies on six other generation paths (e.g. `/session/conclude`, `/storyboard/generate`). The route accepts up to 16,000 chars of `instructions` plus 8,000 of `userContent`, and since #5944 an opted-in lore selection can add up to the 3,000-token forced-entry budget on top. On a small-context model the combination can exceed the input window with no trimming — the player sees an opaque provider rejection (which the package's retry ladder reads as a transient) instead of a graceful degradation. The gap predates #5944 — the route has never fitted — but the lore budget makes it meaningfully easier to hit. Likely shape: reuse the model access policy already resolved for the connection (`resolveGameModelAccessPolicy`, used elsewhere in the file) and fit the composed messages before the call, preserving content when it fits. One design note for whoever picks this up: naive tail-trimming would eat the lore block first (it is appended to the system slot), silently defeating the just-shipped selection — the fit should prefer trimming `userContent`/instructions padding or fail with an honest, non-transient message the package can surface.
bsakaguchi 2026-10-21 06:01:45 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

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

Scope note, after #5953 was filed: this is now a prerequisite rather than a cleanup, and its likely behavior changes.

#5953 is the maintainer call that world generation shouldn't cap how much lorebook a player can feed it. That matters here because the 3,000-token lore budget on this route is, accidentally, the only thing keeping its prompt inside any model's window today — it was never designed as a context guard, but it functions as one. Removing it without real fitting deletes the guardrail while widening the road: the provider rejects the oversized request, the rejection arrives in the shape that does not trigger the truncation retry, and Pixelforge reports it with copy blaming the player's typed setting rather than their lore picks.

The two issues resolve to one coherent position: the Engine stops inventing a limit, and the model's real context window becomes the limit — which is only possible if this route knows what that window is. That's this issue.

Suggested change of shape: prefer refusing with a number over trimming, on this route specifically. The lore block is appended to the system slot, so a naive tail-trim eats the player's hand-picked entries first and silently defeats the selection they just made. Better behavior here is to check before spending the call and say something the player can act on — "your selection is about 40,000 tokens; this model holds 8,000" — rather than burning a paid generation to discover it, or quietly dropping lore they chose. Trimming may well stay the right answer for the five sibling paths in this file that already fit; this route is the one where the oversized content was deliberately selected by a person.

One thing implementation has to settle: whether the fitting machinery has a real context number for every connection or only for models it recognizes. If an unknown or custom endpoint yields no number, the honest fallback needs deciding — most likely "send it and let the provider answer, then report that answer plainly," rather than inventing a cap, which is the thing #5953 exists to stop.

<!-- gh-comment-id:5584618739 --> @kolacheee commented on GitHub (Sep 8, 2026): **Scope note, after #5953 was filed: this is now a prerequisite rather than a cleanup, and its likely behavior changes.** #5953 is the maintainer call that world generation shouldn't cap how much lorebook a player can feed it. That matters here because the 3,000-token lore budget on this route is, accidentally, the only thing keeping its prompt inside any model's window today — it was never designed as a context guard, but it functions as one. Removing it without real fitting deletes the guardrail while widening the road: the provider rejects the oversized request, the rejection arrives in the shape that does **not** trigger the truncation retry, and Pixelforge reports it with copy blaming the player's typed setting rather than their lore picks. The two issues resolve to one coherent position: **the Engine stops inventing a limit, and the model's real context window becomes the limit** — which is only possible if this route knows what that window is. That's this issue. **Suggested change of shape: prefer refusing with a number over trimming, on this route specifically.** The lore block is appended to the system slot, so a naive tail-trim eats the player's hand-picked entries first and silently defeats the selection they just made. Better behavior here is to check before spending the call and say something the player can act on — *"your selection is about 40,000 tokens; this model holds 8,000"* — rather than burning a paid generation to discover it, or quietly dropping lore they chose. Trimming may well stay the right answer for the five sibling paths in this file that already fit; this route is the one where the oversized content was deliberately selected by a person. **One thing implementation has to settle:** whether the fitting machinery has a real context number for every connection or only for models it recognizes. If an unknown or custom endpoint yields no number, the honest fallback needs deciding — most likely "send it and let the provider answer, then report that answer plainly," rather than inventing a cap, which is the thing #5953 exists to stop.
Author
Owner

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

Ownership: @SpicyMarinara, implemented by Codex in this sweep. No existing open PR covers this route. A draft on fix/worldgen-selected-lore-context-5952-5953 will check composed world-generation prompts, including repair rounds, using the existing model-access policy; oversized requests will fail explicitly before a provider call.

<!-- gh-comment-id:5592500621 --> @SpicyMarinara commented on GitHub (Sep 8, 2026): Ownership: @SpicyMarinara, implemented by Codex in this sweep. No existing open PR covers this route. A draft on fix/worldgen-selected-lore-context-5952-5953 will check composed world-generation prompts, including repair rounds, using the existing model-access policy; oversized requests will fail explicitly before a provider call.
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#3296
No description provided.