[GH-ISSUE #218] [Issue]: Balanced malformed World Map JSON is reported as a token-limit truncation #109

Closed
opened 2026-10-20 17:24:28 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @thetopham on GitHub (Aug 3, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/218

Originally assigned to: @thetopham on GitHub.

Summary

A World Map draft generated through the Game Mode setup guide failed JSON parsing and was reported as a token-limit truncation. The captured response is structurally complete but contains malformed JSON, so the current error message gives unsupported Max Output Tokens guidance and hides the actual parse failure.

Affected package

World Maps (hierarchical-maps), v1.3.0.

Expected behavior

  • Distinguish a provider response that actually ended because of an output limit from balanced but malformed JSON.
  • Only recommend raising Max Output Tokens or choosing a smaller map when the finish reason or response structure supports truncation.
  • For malformed JSON, report a retryable formatting failure and retain useful debug evidence such as finish reason, response length, and parser detail.
  • Where supported, use structured JSON output and/or one controlled repair/retry rather than categorizing every parse error as truncation.

Actual behavior

The route catches every parseJsonish failure and returns:

The model's map draft was not valid JSON, most likely because the response was cut off. Raise the connection's Max Output Tokens or choose a smaller map size, then try again.

In the supplied 33,716-character response, the object and arrays close, but one location contains an invalid unquoted property:

"name": "The Green Man",
typeKeyPlaceholder: null,
"typeKey": "pub",

This proves a parse error in the captured response. The provider finish reason was not included, so an actual output-limit finish cannot be confirmed.

Steps to reproduce

  1. Create a new Game Mode with World Maps enabled.
  2. Use the Game Mode setup guide to generate a large World Map.
  3. Allow the model to return a large, structurally complete draft containing malformed JSON.
  4. Observe the map-draft parse failure.
  5. Observe that the package reports a likely token-limit cutoff and recommends increasing Max Output Tokens.

Environment

  • Marinara Engine version: v2.4.1
  • Engine build: 6a6fccb (the same report thread also mentions a89b71f)
  • Package version: World Maps v1.3.0
  • Install type: Not provided
  • OS + version: Not provided
  • Browser or app shell: Not provided
  • Provider/model/Max Output Tokens: Not provided

Logs, screenshots, or video

Relevant debug excerpt:

[debug/spatial/map-draft] raw response ... chars=33716:
...
"name": "The Green Man",
typeKeyPlaceholder: null,
"typeKey": "pub",
...
[spatial/map-draft] Model response was not valid JSON ... (33716 chars, likely truncated)

The full 38 KB debug log is available from the reporter if provider-specific context is needed.

Additional context

The current spatial-context.routes.ts catch path labels every parse failure as likely truncation without checking the generation finish reason.

This was observed through Game Mode setup; previous large map generations outside that flow reportedly succeeded. That difference may help reproduction, but it does not establish the cause.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @thetopham on GitHub (Aug 3, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/218 Originally assigned to: @thetopham on GitHub. ## Summary A World Map draft generated through the Game Mode setup guide failed JSON parsing and was reported as a token-limit truncation. The captured response is structurally complete but contains malformed JSON, so the current error message gives unsupported Max Output Tokens guidance and hides the actual parse failure. ## Affected package World Maps (`hierarchical-maps`), v1.3.0. ## Expected behavior - Distinguish a provider response that actually ended because of an output limit from balanced but malformed JSON. - Only recommend raising Max Output Tokens or choosing a smaller map when the finish reason or response structure supports truncation. - For malformed JSON, report a retryable formatting failure and retain useful debug evidence such as finish reason, response length, and parser detail. - Where supported, use structured JSON output and/or one controlled repair/retry rather than categorizing every parse error as truncation. ## Actual behavior The route catches every `parseJsonish` failure and returns: > The model's map draft was not valid JSON, most likely because the response was cut off. Raise the connection's Max Output Tokens or choose a smaller map size, then try again. In the supplied 33,716-character response, the object and arrays close, but one location contains an invalid unquoted property: ```text "name": "The Green Man", typeKeyPlaceholder: null, "typeKey": "pub", ``` This proves a parse error in the captured response. The provider finish reason was not included, so an actual output-limit finish cannot be confirmed. ## Steps to reproduce 1. Create a new Game Mode with World Maps enabled. 2. Use the Game Mode setup guide to generate a large World Map. 3. Allow the model to return a large, structurally complete draft containing malformed JSON. 4. Observe the map-draft parse failure. 5. Observe that the package reports a likely token-limit cutoff and recommends increasing Max Output Tokens. ## Environment - Marinara Engine version: v2.4.1 - Engine build: 6a6fccb (the same report thread also mentions a89b71f) - Package version: World Maps v1.3.0 - Install type: Not provided - OS + version: Not provided - Browser or app shell: Not provided - Provider/model/Max Output Tokens: Not provided ## Logs, screenshots, or video Relevant debug excerpt: ```text [debug/spatial/map-draft] raw response ... chars=33716: ... "name": "The Green Man", typeKeyPlaceholder: null, "typeKey": "pub", ... [spatial/map-draft] Model response was not valid JSON ... (33716 chars, likely truncated) ``` The full 38 KB debug log is available from the reporter if provider-specific context is needed. ## Additional context The current [`spatial-context.routes.ts`](https://github.com/Pasta-Devs/Marinara-Agents/blob/8318164b79221073e39edf63f74264f62b12ce8a/packages/hierarchical-maps/src/engine/packages/server/src/routes/spatial-context.routes.ts#L1630-L1653) catch path labels every parse failure as likely truncation without checking the generation finish reason. This was observed through Game Mode setup; previous large map generations outside that flow reportedly succeeded. That difference may help reproduction, but it does not establish the cause. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:24:28 +07:00
  • closed this issue
  • added the
    bug
    label
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#109
No description provided.