[PR #99] [MERGED] fix(hierarchical-maps): enough output budget for reasoning-model map drafts (Engine #4026) #805

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/99
Author: @SpicyMarinara
Created: 7/24/2026
Status: ✅ Merged
Merged: 7/24/2026
Merged by: @SpicyMarinara

Base: main ← Head: fix/4026-map-draft-token-budget


📝 Commits (1)

  • fdb0a7e fix(hierarchical-maps): give map drafts enough output budget for reasoning models

📊 Changes

9 files changed (+105 additions, -66 deletions)

View changed files

➕ artifacts/hierarchical-maps-1.1.8.zip (+0 -0)
📝 catalog/catalog.json (+7 -7)
📝 catalog/v2/catalog.json (+7 -7)
📝 catalog/v3/catalog.json (+1 -1)
📝 packages/hierarchical-maps/manifest.json (+3 -3)
📝 packages/hierarchical-maps/server.mjs (+24 -24)
📝 packages/hierarchical-maps/src/engine/packages/server/src/routes/spatial-context.routes.ts (+52 -20)
📝 packages/hierarchical-maps/src/engine/packages/server/src/services/spatial-context/ai-draft.ts (+10 -3)
📝 scripts/build-feature-packages.mjs (+1 -1)

📄 Description

Linked issue

Closes #100
Refs Pasta-Devs/Marinara-Engine#4026

Why this change

In GM/Roleplay Hierarchical Maps, map-draft generation is truncated into invalid JSON for reasoning-heavy models (e.g. glm-*:thinking), and raising the connection's Max Output Tokens doesn't help.

The draft/expansion requests used small hardcoded per-size output budgets (small 6k / medium 10k / large 16k). Reasoning models spend much of that budget on hidden thinking, so the visible JSON is cut off and rejected. The connection's Max Output Tokens only ever caps the request (the Engine host applies min(request, override)), so a higher value can't raise the ceiling — exactly what the reporter saw after setting 16000. The capability resolves its model through the Engine host (languageModels.resolve() → chatComplete()), which exposes only connectionId, model, and chatComplete — not the connection's Max Output Tokens — so it cannot read that setting to honor it directly. Raising the requested budget lets the Engine cap govern instead: a higher connection setting now takes effect, a lower one is still respected.

What changed

  • packages/hierarchical-maps/src/engine/.../services/spatial-context/ai-draft.ts: raised the per-size request budgets — small 6k→12k, medium 10k→24k, large 16k→40k — with a comment explaining the Engine-cap interaction.
  • packages/hierarchical-maps/src/engine/.../routes/spatial-context.routes.ts: the /spatial-context/generate handler now distinguishes failure modes instead of one generic error — empty response, invalid/truncated JSON (with a hint to raise Max Output Tokens or pick a smaller size), and structure mismatch (surfacing the normalizer's reason).
  • Rebuilt hierarchical-maps to 1.1.8: server bundle, manifest, catalog lanes v1/v2/v3, and artifacts/hierarchical-maps-1.1.8.zip. client.js unchanged.

Package and security impact

  • Affected package IDs: hierarchical-maps (1.1.7 → 1.1.8)
  • Engine compatibility impact: none (min 2.3.3, maxExclusive 3.0.0 unchanged)
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact: none beyond the normal package update; server-only bundle change, no schema/storage change

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Ran node scripts/build-feature-packages.mjs hierarchical-maps and node scripts/validate-catalog.mjs in the authoring session; both succeeded (catalog valid: 29 packages; lanes v2=29, v3=6). Please re-verify locally.
  • Manually verify: with a reasoning model (e.g. glm-*:thinking) and a connection Max Output Tokens ~16000+, a medium hierarchical world map completes instead of truncating.
  • Manually verify: a low connection Max Output Tokens is still respected (request capped down).
  • Manually verify: a forced truncation returns the invalid/truncated-JSON message suggesting a higher Max Output Tokens or smaller size.
  • Manually verify: expanding an existing location benefits from the same budgets.

Documentation impact

  • No documentation changes needed

UI evidence (if applicable)

Not applicable — server-only change.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Agents/pull/99 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/24/2026 **Status:** ✅ Merged **Merged:** 7/24/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `fix/4026-map-draft-token-budget` --- ### 📝 Commits (1) - [`fdb0a7e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/fdb0a7e78c00e9b5bbab200dc375a95945ee298c) fix(hierarchical-maps): give map drafts enough output budget for reasoning models ### 📊 Changes **9 files changed** (+105 additions, -66 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/hierarchical-maps-1.1.8.zip` (+0 -0) 📝 `catalog/catalog.json` (+7 -7) 📝 `catalog/v2/catalog.json` (+7 -7) 📝 `catalog/v3/catalog.json` (+1 -1) 📝 `packages/hierarchical-maps/manifest.json` (+3 -3) 📝 `packages/hierarchical-maps/server.mjs` (+24 -24) 📝 `packages/hierarchical-maps/src/engine/packages/server/src/routes/spatial-context.routes.ts` (+52 -20) 📝 `packages/hierarchical-maps/src/engine/packages/server/src/services/spatial-context/ai-draft.ts` (+10 -3) 📝 `scripts/build-feature-packages.mjs` (+1 -1) </details> ### 📄 Description ## Linked issue Closes #100 Refs Pasta-Devs/Marinara-Engine#4026 ## Why this change In GM/Roleplay **Hierarchical Maps**, map-draft generation is truncated into invalid JSON for reasoning-heavy models (e.g. `glm-*:thinking`), and raising the connection's **Max Output Tokens** doesn't help. The draft/expansion requests used small hardcoded per-size output budgets (`small` 6k / `medium` 10k / `large` 16k). Reasoning models spend much of that budget on hidden thinking, so the visible JSON is cut off and rejected. The connection's Max Output Tokens only ever **caps** the request (the Engine host applies `min(request, override)`), so a *higher* value can't raise the ceiling — exactly what the reporter saw after setting 16000. The capability resolves its model through the Engine host (`languageModels.resolve()` → `chatComplete()`), which exposes only `connectionId`, `model`, and `chatComplete` — **not** the connection's Max Output Tokens — so it cannot read that setting to honor it directly. Raising the requested budget lets the Engine cap govern instead: a higher connection setting now takes effect, a lower one is still respected. ## What changed - `packages/hierarchical-maps/src/engine/.../services/spatial-context/ai-draft.ts`: raised the per-size request budgets — `small` 6k→**12k**, `medium` 10k→**24k**, `large` 16k→**40k** — with a comment explaining the Engine-cap interaction. - `packages/hierarchical-maps/src/engine/.../routes/spatial-context.routes.ts`: the `/spatial-context/generate` handler now distinguishes failure modes instead of one generic error — empty response, invalid/truncated JSON (with a hint to raise Max Output Tokens or pick a smaller size), and structure mismatch (surfacing the normalizer's reason). - Rebuilt `hierarchical-maps` to **1.1.8**: server bundle, manifest, catalog lanes v1/v2/v3, and `artifacts/hierarchical-maps-1.1.8.zip`. `client.js` unchanged. ## Package and security impact - Affected package IDs: `hierarchical-maps` (1.1.7 → 1.1.8) - Engine compatibility impact: none (min 2.3.3, maxExclusive 3.0.0 unchanged) - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: none beyond the normal package update; server-only bundle change, no schema/storage change ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Ran `node scripts/build-feature-packages.mjs hierarchical-maps` and `node scripts/validate-catalog.mjs` in the authoring session; both succeeded (catalog valid: 29 packages; lanes v2=29, v3=6). Please re-verify locally. - Manually verify: with a reasoning model (e.g. `glm-*:thinking`) and a connection Max Output Tokens ~16000+, a **medium** hierarchical world map completes instead of truncating. - Manually verify: a low connection Max Output Tokens is still respected (request capped down). - Manually verify: a forced truncation returns the invalid/truncated-JSON message suggesting a higher Max Output Tokens or smaller size. - Manually verify: expanding an existing location benefits from the same budgets. ## Documentation impact - [x] No documentation changes needed ## UI evidence (if applicable) Not applicable — server-only change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-20 17:31:07 +07:00
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#805
No description provided.