[GH-ISSUE #812] The world-generation failure screen never tells you how big your selection was or how much the connection holds #419

Closed
opened 2026-10-20 17:27:22 +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-Agents/issues/812

Originally assigned to: @SpicyMarinara, @kolacheee on GitHub.

When Pixelforge world generation is refused for being too large, the screen tells the player to pick fewer lorebook entries or a bigger connection, but never says how big their request actually was or how much the connection can hold - even though the engine measured both numbers and sent them. And on one particular refusal (too many entries ticked at once) the screen blames the player's setting description, which is not what overflowed.

How to reproduce (try it yourself)

Part 1 - the refusal with no numbers:

  1. Open Settings -> Connections and create a connection with Max Context set to 1024. Give it a name you'll recognize.
  2. Start a new chat and open the Pixelforge Experience.
  3. In the Pixelforge setup wizard, set the connection dropdown to that 1024-context connection. This step matters: the dropdown is what the world call uses, and it defaults to your usual connection, so changing the chat's connection beforehand does nothing.
  4. Type any setting description, for example: A quiet valley, three days walk from the sea.
  5. Tick nothing in the lorebook picker - no lorebook is needed. Pixelforge's own instructions and schema are already about 1,600 tokens, and a 1024-context connection leaves room for roughly 400.
  6. Press the button that starts world generation.

What you'll see: "The world didn't finish being written. The selected lore and world request exceed the model's context limit. Choose fewer lorebook entries or a connection with a larger context." No sizes. And it tells you to untick lorebook entries you never ticked.

What should happen: the screen should name the two sizes the engine already measured and sent, e.g. "Your request comes to about 1,600 tokens; this connection holds about 400. Untick lorebook entries or pick a connection with a larger context." Open devtools -> Network on the failed call and you can see both figures sitting unused in the response, as estimatedInputTokens and inputBudget.

Part 2 - the refusal that blames the wrong thing (same screen, rarer path):

  1. Import a large third-party worldbook with more than about 2,500 entries.
  2. Open a Pixelforge chat, type any setting description, expand that book in the lorebook picker and press Select all.
  3. Press the button that starts world generation.

What you'll see: "The world didn't finish being written. The request was turned down rather than delayed, so another attempt may well get the same answer; a shorter, plainer setting description is the likeliest thing to change it."

What should happen: a sentence naming the real cause - too many entries ticked for one request - and telling the player to untick some. Shortening the setting description cannot help; the list of ticked entry IDs is what overflowed, not the setting text. (The wall is the request body passing 64 KB. Measured at these commits: 2,448 ticked entries go through, 2,449 are rejected with a 413; with a maxed-out 8,000-character setting description it's 2,125 vs 2,126. Devtools shows 413 and "The request body is larger than this endpoint accepts.")

Where it is

At Agents 49a9c10c:

  • packages/pixelforge/src/18-brief.js:955-957 - onFailure?.("context_limit") is called with the kind and nothing else; response.body, which carries both numbers, is never read on that branch.
  • packages/pixelforge/src/18-brief.js:1001-1014 - status classification: 404, 409, 429 and 500-and-up become unavailable, everything else becomes refused. A 413 is in neither list, so it lands on refused.
  • packages/pixelforge/src/60-save.js:1526, 1550-1551 - gateReason(kind, stage) takes only the kind and stage; the context_limit arm returns a fixed sentence with nowhere to put a number. (It uses a typographic apostrophe in "model's" - grep for U+2019 or it looks like the string is missing.)
  • packages/pixelforge/src/60-save.js:292-293 - the refused advice line that blames the setting description.
  • packages/pixelforge/src/60-save.js:2201-2203 and :2315-2317 - both call sites bind onFailure: (kind) => ..., one parameter, so no engine-side change alone could get a number to the screen.
  • Engine side, for reference, at staging 52799569c: packages/server/src/routes/game.routes.ts:11050-11059 sends the 422 with estimatedInputTokens and inputBudget; line 10775 sets the route's 64 KB body limit.

What's happening

The engine does the right thing: it checks the request against the connection's context window before spending a provider call, refuses, and puts both sides of the comparison in the response. Pixelforge's network layer throws those numbers away one function too early - the failure kind travels on alone, and the function that writes the screen text has no parameter that could carry a size even if one arrived. A search of the whole Pixelforge package finds zero readers of either field.

The second half is the same layer failing differently: a 413 (request body too large) isn't in the list of statuses the classifier recognizes, so it falls into the generic refused bucket, whose advice was written for a provider turning the prompt down - hence the pointer at the setting description.

The picker already shows the player a live estimate of their own selection ("N entries - about X tokens for the call"), so the interface has half the comparison and the refusal screen has neither half. Rendering inputBudget is the minimum that makes "choose fewer" a sized instruction instead of a guess.

Suggested fix

Carry the failure detail alongside the failure kind, and let the screen text interpolate it:

  • Widen onFailure in 18-brief.js to pass an optional detail object (estimatedInputTokens, inputBudget) with the kind, read off response.body on the context_limit branch, and widen both (kind) => binders in 60-save.js to keep it.
  • Give gateReason's context_limit arm an interpolated variant used when the detail is present, falling back to today's fixed sentence when it isn't. An older engine sends no such fields, and a missing number must never print as a blank or "undefined".
  • Give 413 its own failure kind in generate() with copy about the number of ticked entries, so the setting-description advice stops firing on it. (The alternative is an engine-side counted 422 for an over-long ID list; the package-side kind is cheaper and also protects players running an older engine, so it's worth doing either way.)

Both arms should degrade to today's copy rather than to a sentence with a hole in it.

Context

This is the remainder of a mostly-delivered pair. Engine PR #5977 closed Engine issues #5952 and #5953 by landing context fitting and refusing before a paid call; PR #761 closed #760 by adding the picker's live estimate and a dedicated context-limit sentence, and in the same commit removed the 100-entry selection cap, which is what opened the 413 path above. What neither delivered is the actual magnitudes - the shape the requester asked for by hand on Engine #5952 ("your selection is about 40,000 tokens; this model holds 8,000") - or a story for 413. Nothing currently tracks either. The Pixelforge half is released and in players' hands (shipped in 0.16.3, both sentences present in the built packages/pixelforge/client.js); the engine half is unreleased on staging, since #5977 landed after Engine v2.4.4. The engine-side companion (raising the route's body limit so the 413 never fires before the counted refusal) is filed separately on Marinara-Engine.

Found by an AI-assisted sweep of the merged PRs against their original issues, then re-verified against Engine staging 52799569c on 2026-09-13. Please verify before fixing.

Related issue from the same sweep: Pasta-Devs/Marinara-Engine#6122 (the Engine-side body limit that produces the 413).

Originally created by @kolacheee on GitHub (Sep 13, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/812 Originally assigned to: @SpicyMarinara, @kolacheee on GitHub. When Pixelforge world generation is refused for being too large, the screen tells the player to pick fewer lorebook entries or a bigger connection, but never says how big their request actually was or how much the connection can hold - even though the engine measured both numbers and sent them. And on one particular refusal (too many entries ticked at once) the screen blames the player's setting description, which is not what overflowed. ## How to reproduce (try it yourself) Part 1 - the refusal with no numbers: 1. Open Settings -> Connections and create a connection with **Max Context set to 1024**. Give it a name you'll recognize. 2. Start a new chat and open the Pixelforge Experience. 3. **In the Pixelforge setup wizard, set the connection dropdown to that 1024-context connection.** This step matters: the dropdown is what the world call uses, and it defaults to your usual connection, so changing the chat's connection beforehand does nothing. 4. Type any setting description, for example: `A quiet valley, three days walk from the sea.` 5. Tick nothing in the lorebook picker - no lorebook is needed. Pixelforge's own instructions and schema are already about 1,600 tokens, and a 1024-context connection leaves room for roughly 400. 6. Press the button that starts world generation. **What you'll see:** "The world didn't finish being written. The selected lore and world request exceed the model's context limit. Choose fewer lorebook entries or a connection with a larger context." No sizes. And it tells you to untick lorebook entries you never ticked. **What should happen:** the screen should name the two sizes the engine already measured and sent, e.g. "Your request comes to about 1,600 tokens; this connection holds about 400. Untick lorebook entries or pick a connection with a larger context." Open devtools -> Network on the failed call and you can see both figures sitting unused in the response, as `estimatedInputTokens` and `inputBudget`. Part 2 - the refusal that blames the wrong thing (same screen, rarer path): 1. Import a large third-party worldbook with more than about 2,500 entries. 2. Open a Pixelforge chat, type any setting description, expand that book in the lorebook picker and press **Select all**. 3. Press the button that starts world generation. **What you'll see:** "The world didn't finish being written. The request was turned down rather than delayed, so another attempt may well get the same answer; a shorter, plainer setting description is the likeliest thing to change it." **What should happen:** a sentence naming the real cause - too many entries ticked for one request - and telling the player to untick some. Shortening the setting description cannot help; the list of ticked entry IDs is what overflowed, not the setting text. (The wall is the request body passing 64 KB. Measured at these commits: 2,448 ticked entries go through, 2,449 are rejected with a 413; with a maxed-out 8,000-character setting description it's 2,125 vs 2,126. Devtools shows `413` and "The request body is larger than this endpoint accepts.") ## Where it is At Agents 49a9c10c: - `packages/pixelforge/src/18-brief.js:955-957` - `onFailure?.("context_limit")` is called with the kind and nothing else; `response.body`, which carries both numbers, is never read on that branch. - `packages/pixelforge/src/18-brief.js:1001-1014` - status classification: 404, 409, 429 and 500-and-up become `unavailable`, everything else becomes `refused`. A 413 is in neither list, so it lands on `refused`. - `packages/pixelforge/src/60-save.js:1526, 1550-1551` - `gateReason(kind, stage)` takes only the kind and stage; the `context_limit` arm returns a fixed sentence with nowhere to put a number. (It uses a typographic apostrophe in "model's" - grep for U+2019 or it looks like the string is missing.) - `packages/pixelforge/src/60-save.js:292-293` - the `refused` advice line that blames the setting description. - `packages/pixelforge/src/60-save.js:2201-2203` and `:2315-2317` - both call sites bind `onFailure: (kind) => ...`, one parameter, so no engine-side change alone could get a number to the screen. - Engine side, for reference, at staging 52799569c: `packages/server/src/routes/game.routes.ts:11050-11059` sends the 422 with `estimatedInputTokens` and `inputBudget`; line 10775 sets the route's 64 KB body limit. ## What's happening The engine does the right thing: it checks the request against the connection's context window before spending a provider call, refuses, and puts both sides of the comparison in the response. Pixelforge's network layer throws those numbers away one function too early - the failure kind travels on alone, and the function that writes the screen text has no parameter that could carry a size even if one arrived. A search of the whole Pixelforge package finds zero readers of either field. The second half is the same layer failing differently: a 413 (request body too large) isn't in the list of statuses the classifier recognizes, so it falls into the generic `refused` bucket, whose advice was written for a provider turning the prompt down - hence the pointer at the setting description. The picker already shows the player a live estimate of their own selection ("N entries - about X tokens for the call"), so the interface has half the comparison and the refusal screen has neither half. Rendering `inputBudget` is the minimum that makes "choose fewer" a sized instruction instead of a guess. ## Suggested fix Carry the failure detail alongside the failure kind, and let the screen text interpolate it: - Widen `onFailure` in `18-brief.js` to pass an optional detail object (`estimatedInputTokens`, `inputBudget`) with the kind, read off `response.body` on the `context_limit` branch, and widen both `(kind) =>` binders in `60-save.js` to keep it. - Give `gateReason`'s `context_limit` arm an interpolated variant used when the detail is present, falling back to today's fixed sentence when it isn't. An older engine sends no such fields, and a missing number must never print as a blank or "undefined". - Give 413 its own failure kind in `generate()` with copy about the number of ticked entries, so the setting-description advice stops firing on it. (The alternative is an engine-side counted 422 for an over-long ID list; the package-side kind is cheaper and also protects players running an older engine, so it's worth doing either way.) Both arms should degrade to today's copy rather than to a sentence with a hole in it. ## Context This is the remainder of a mostly-delivered pair. Engine PR #5977 closed Engine issues #5952 and #5953 by landing context fitting and refusing before a paid call; PR #761 closed #760 by adding the picker's live estimate and a dedicated context-limit sentence, and in the same commit removed the 100-entry selection cap, which is what opened the 413 path above. What neither delivered is the actual magnitudes - the shape the requester asked for by hand on Engine #5952 ("your selection is about 40,000 tokens; this model holds 8,000") - or a story for 413. Nothing currently tracks either. The Pixelforge half is released and in players' hands (shipped in 0.16.3, both sentences present in the built `packages/pixelforge/client.js`); the engine half is unreleased on staging, since #5977 landed after Engine v2.4.4. The engine-side companion (raising the route's body limit so the 413 never fires before the counted refusal) is filed separately on Marinara-Engine. Found by an AI-assisted sweep of the merged PRs against their original issues, then re-verified against Engine staging 52799569c on 2026-09-13. Please verify before fixing. Related issue from the same sweep: Pasta-Devs/Marinara-Engine#6122 (the Engine-side body limit that produces the 413).
Author
Owner

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

SpicyMarinara/Codex is handling this assigned issue in the release sweep, draft PR #836. We are checking the existing linked work before changing the owning package source, preserving the separate Slurp2 work in #816, and will close this issue only once its fix and validation are on staging.

<!-- gh-comment-id:5653121319 --> @SpicyMarinara commented on GitHub (Sep 13, 2026): SpicyMarinara/Codex is handling this assigned issue in the release sweep, draft PR #836. We are checking the existing linked work before changing the owning package source, preserving the separate Slurp2 work in #816, and will close this issue only once its fix and validation are on staging.
Author
Owner

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

Addendum after Engine PR #6137 (staging ac14dd704). Two more places where this same screen loses the cause.

1. The content pack call has no context_limit arm at all.

18-brief.js:955-958 learned the code. 61-pack.js:2054-2113 never did. Its ladder is: 409 wait out, truncated re-roll, thin, then 404/409/429/5xx to unavailable (:2102-2105), and everything else to onFailure?.("refused") (:2112). Line :2110 even logs response.body?.error to the console before discarding it. So a context refusal on the second call prints the pack stage's generic line, "The request was turned down rather than delayed, so another attempt may well get the same answer.", and offers a retry that re-sends the identical body and fails identically.

This got easier to hit, not harder, after #6137. The route now also refuses when the fitted output budget falls under 1,024 tokens (game.routes.ts:11076 and :11088-11103, closing Engine #6129), which raises the max context at which the pack call is refused by roughly 960 tokens. Measured against the real fit function and the real package payloads, with a sealed brief at the package's own caps (10 cast, 4 places):

setting length brief seals up to pack refused up to band where only the pack fails
0 2617 2990 2618 to 2990
2,000 3118 3497 3119 to 3497
5,000 3868 4247 3869 to 4247

At max context 4096 with a setting description of about 5,000 characters the brief seals (estimated 2,281 tokens) and the pack is refused (estimated 2,643, leaving 889 of the 1,024 output tokens required). That is a plain 4K local connection, with no connection swapping needed. Before #6137 the same band sat at 2,909 to 3,287, which is why this looked unreachable earlier.

To reproduce in the app: Settings, Connections, set Max Context to 4096. New chat, open the Pixelforge Experience, leave "Generate a unique world with your GM connection (two calls)" ticked, and point the wizard's connection dropdown at that connection. Paste a Setting description of about 5,000 characters. Tick nothing in the lorebook picker. Start world generation. The world appears, then the pack failure screen shows the generic refusal, while devtools Network on /experience-generation shows 422 {code:"context_limit", availableOutputTokens:889, minimumOutputTokens:1024}.

One warning for whoever fixes this: do not reuse the brief's sentence here. gateReason("context_limit") at 60-save.js:1550-1551 says "Choose fewer lorebook entries", and the pack request body carries no lorebookEntryIds key at all. The pack stage needs its own row beside refused and storage at 60-save.js:398-401, because the comment at :290 says those two are the only stage forked kinds, so the per stage override hook is the only way in.

2. That same sentence blames lore on the no selection path.

The route has written two different context_limit strings since #5977 and forks them on lorebookSelectionRequested (game.routes.ts:10852, :11094-11099). With nothing ticked it sends "The world-generation instructions exceed this connection's context window. Choose a larger-context connection or shorten the instructions." The package reads only the code (18-brief.js:955-956) and prints the lore wording regardless, so a player who ticked zero entries is told to untick some.

Surfacing the server's own error string for this kind fixes both halves of this issue at once, the missing numbers and the wrong advice: widen onFailure to carry the response detail, and let gateReason interpolate it.

Found by an AI-assisted sweep and re-verified against staging ac14dd704 on 2026-09-13. Please verify before fixing.

<!-- gh-comment-id:5653220722 --> @kolacheee commented on GitHub (Sep 13, 2026): Addendum after Engine PR #6137 (staging ac14dd704). Two more places where this same screen loses the cause. **1. The content pack call has no `context_limit` arm at all.** `18-brief.js:955-958` learned the code. `61-pack.js:2054-2113` never did. Its ladder is: 409 wait out, truncated re-roll, thin, then 404/409/429/5xx to `unavailable` (:2102-2105), and everything else to `onFailure?.("refused")` (:2112). Line :2110 even logs `response.body?.error` to the console before discarding it. So a context refusal on the second call prints the pack stage's generic line, "The request was turned down rather than delayed, so another attempt may well get the same answer.", and offers a retry that re-sends the identical body and fails identically. This got easier to hit, not harder, after #6137. The route now also refuses when the fitted output budget falls under 1,024 tokens (`game.routes.ts:11076` and :11088-11103, closing Engine #6129), which raises the max context at which the pack call is refused by roughly 960 tokens. Measured against the real fit function and the real package payloads, with a sealed brief at the package's own caps (10 cast, 4 places): | setting length | brief seals up to | pack refused up to | band where only the pack fails | |---|---|---|---| | 0 | 2617 | 2990 | 2618 to 2990 | | 2,000 | 3118 | 3497 | 3119 to 3497 | | 5,000 | 3868 | 4247 | 3869 to 4247 | At **max context 4096 with a setting description of about 5,000 characters** the brief seals (estimated 2,281 tokens) and the pack is refused (estimated 2,643, leaving 889 of the 1,024 output tokens required). That is a plain 4K local connection, with no connection swapping needed. Before #6137 the same band sat at 2,909 to 3,287, which is why this looked unreachable earlier. To reproduce in the app: Settings, Connections, set Max Context to 4096. New chat, open the Pixelforge Experience, leave "Generate a unique world with your GM connection (two calls)" ticked, and point the wizard's connection dropdown at that connection. Paste a Setting description of about 5,000 characters. Tick nothing in the lorebook picker. Start world generation. The world appears, then the pack failure screen shows the generic refusal, while devtools Network on `/experience-generation` shows `422 {code:"context_limit", availableOutputTokens:889, minimumOutputTokens:1024}`. One warning for whoever fixes this: **do not reuse the brief's sentence here.** `gateReason("context_limit")` at `60-save.js:1550-1551` says "Choose fewer lorebook entries", and the pack request body carries no `lorebookEntryIds` key at all. The pack stage needs its own row beside `refused` and `storage` at `60-save.js:398-401`, because the comment at :290 says those two are the only stage forked kinds, so the per stage override hook is the only way in. **2. That same sentence blames lore on the no selection path.** The route has written two different `context_limit` strings since #5977 and forks them on `lorebookSelectionRequested` (`game.routes.ts:10852`, :11094-11099). With nothing ticked it sends "The world-generation instructions exceed this connection's context window. Choose a larger-context connection or shorten the instructions." The package reads only the code (`18-brief.js:955-956`) and prints the lore wording regardless, so a player who ticked zero entries is told to untick some. Surfacing the server's own `error` string for this kind fixes both halves of this issue at once, the missing numbers and the wrong advice: widen `onFailure` to carry the response detail, and let `gateReason` interpolate it. Found by an AI-assisted sweep and re-verified against staging ac14dd704 on 2026-09-13. Please verify before fixing.
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-Agents#419
No description provided.