[PR #5977] [MERGED] fix(game): preserve selected world lore and check context limits #7010

Closed
opened 2026-10-23 04:15:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5977
Author: @SpicyMarinara
Created: 9/8/2026
Status: ✅ Merged
Merged: 9/9/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/worldgen-selected-lore-context-5952-5953


📝 Commits (10+)

  • b3d03b2 chore: begin selected world lore and context handling
  • 848e8fa fix(game): preserve chosen world lore within the model context
  • 8a125ce Merge remote-tracking branch 'origin/staging' into fix/worldgen-selected-lore-context-5952-5953
  • 4d9528b test(game): retain automatic lore budget coverage
  • df7166b test(game): scope ordinary budget assertion to its book
  • 7773566 Merge remote-tracking branch 'origin/staging' into fix/worldgen-selected-lore-context-5952-5953
  • 86b7211 docs: align world-generation release note with exact selections
  • 226247c Merge remote-tracking branch 'origin/staging' into fix/worldgen-selected-lore-context-5952-5953
  • b47b793 Merge remote-tracking branch 'origin/staging' into fix/worldgen-selected-lore-context-5952-5953
  • 33ec650 docs: distinguish explicit world lore from automatic budgets

📊 Changes

5 files changed (+150 additions, -217 deletions)

View changed files

📝 CHANGELOG.md (+3 -2)
📝 packages/server/src/routes/game.routes.ts (+35 -51)
📝 packages/server/src/services/lorebook/index.ts (+16 -6)
📝 packages/server/src/services/storage/lorebooks.storage.ts (+3 -2)
📝 scripts/regressions/experience-lore-entries.regression.ts (+93 -156)

📄 Description

Linked issue

Closes #5952
Partially addresses #5953; the paired Pixelforge picker change belongs to Marinara-Agents and must land before closing that issue.

Why this change

World generation silently discarded explicitly selected lore at automatic lorebook token/count budgets, and sent oversized prompts to small-context models without checking the connection limit. The package then blamed a generic provider failure on the player's description.

What changed

  • Exact player selections bypass automatic location, chat, per-book token and entry-count limits. Ordinary lorebook callers keep their existing budgets, scopes, and activation gates.
  • Preserve large literal entries with the macro resolver's existing bounded output option; retain its recursion and expansion-count safeguards. Include explicitly selected outlet entries in the world prompt.
  • Check the full initial and JSON-repair prompt with the existing model-access policy. Keep the prompt intact when it fits, applying the calculated output-token ceiling. Otherwise return a non-transient context_limit response before contacting the provider, identifying selected lore when present.
  • Update the existing route/storage regression and Unreleased changelog. No new dependency or setting.

Validation

Automated checks completed:

  • pnpm check and pnpm regression:prompt passed on the updated staging base.

  • node scripts/run-regressions.mjs --filter experience-lore-entries passed, including 101 selected entries from one default-budget book, roughly 200,000 tokens of literal lore on a large-context connection, explicitly picked outlets, disabled/deleted selections, ordinary budget preservation, oversized initial prompts and oversized JSON repairs.

  • The updated selection regression fails against the previous automatic-budget implementation. With only the new route context check removed, the context regression fails because an oversized request reaches the provider and returns success.

  • pnpm check passes locally

  • Container (Docker / Podman) built and ran without issue

  • Ran the app, clicked through the changes manually

  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)

  • Above manual verification completed (describe below)

  • Read and followed CONTRIBUTING.md

Manual verification notes

Manually verify world generation through the paired Pixelforge picker with a live provider, including a large selection and a small-context rejection. These checks are not claimed as completed. Local regressions use a synthetic HTTP provider and real route/storage code.

Docs and release impact

Unreleased changelog only; no version or user-guide changes. Pixelforge picker arithmetic and context-limit copy are handled in the package repository against staging.

Summary by CodeRabbit

  • Bug Fixes
    • World generation now preserves all explicitly selected lorebook entries, including large selections and entries with additional content.
    • Automatic lorebook token and entry limits no longer truncate exact player selections.
    • Oversized prompts and repair requests now return a clear context-limit error before being sent for generation.
    • Generation requests are adjusted to fit within the model’s available context window.
    • Added coverage to verify that ordinary lorebook selection limits continue to apply.

🔄 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-Engine/pull/5977 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/8/2026 **Status:** ✅ Merged **Merged:** 9/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/worldgen-selected-lore-context-5952-5953` --- ### 📝 Commits (10+) - [`b3d03b2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b3d03b2cf3e76aad9e0aae7c935eda9879609945) chore: begin selected world lore and context handling - [`848e8fa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/848e8fa3d4311b0423be620acfcc808a8fbbb33f) fix(game): preserve chosen world lore within the model context - [`8a125ce`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8a125ce0b85362ce0307ce5e685ba00cdeaeeb6b) Merge remote-tracking branch 'origin/staging' into fix/worldgen-selected-lore-context-5952-5953 - [`4d9528b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4d9528bf073dea25e0b13e3af7f54a8011de7c3f) test(game): retain automatic lore budget coverage - [`df7166b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/df7166beb39a286987c89341c574f7f23559e291) test(game): scope ordinary budget assertion to its book - [`7773566`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7773566d29a4817eadbe432ecb77c957471c1af4) Merge remote-tracking branch 'origin/staging' into fix/worldgen-selected-lore-context-5952-5953 - [`86b7211`](https://github.com/Pasta-Devs/Marinara-Engine/commit/86b7211d68da42a168ba12cd63b40e57d1e3aed5) docs: align world-generation release note with exact selections - [`226247c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/226247c52c082d8c3aa5853c4ebc8fdd2312516a) Merge remote-tracking branch 'origin/staging' into fix/worldgen-selected-lore-context-5952-5953 - [`b47b793`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b47b79364b8ec971d4f6a22ad7bc070c628823e2) Merge remote-tracking branch 'origin/staging' into fix/worldgen-selected-lore-context-5952-5953 - [`33ec650`](https://github.com/Pasta-Devs/Marinara-Engine/commit/33ec6506743bef775af8d7c9dace18a965b6c7e4) docs: distinguish explicit world lore from automatic budgets ### 📊 Changes **5 files changed** (+150 additions, -217 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -2) 📝 `packages/server/src/routes/game.routes.ts` (+35 -51) 📝 `packages/server/src/services/lorebook/index.ts` (+16 -6) 📝 `packages/server/src/services/storage/lorebooks.storage.ts` (+3 -2) 📝 `scripts/regressions/experience-lore-entries.regression.ts` (+93 -156) </details> ### 📄 Description ## Linked issue Closes #5952 Partially addresses #5953; the paired Pixelforge picker change belongs to Marinara-Agents and must land before closing that issue. ## Why this change World generation silently discarded explicitly selected lore at automatic lorebook token/count budgets, and sent oversized prompts to small-context models without checking the connection limit. The package then blamed a generic provider failure on the player's description. ## What changed - Exact player selections bypass automatic location, chat, per-book token and entry-count limits. Ordinary lorebook callers keep their existing budgets, scopes, and activation gates. - Preserve large literal entries with the macro resolver's existing bounded output option; retain its recursion and expansion-count safeguards. Include explicitly selected outlet entries in the world prompt. - Check the full initial and JSON-repair prompt with the existing model-access policy. Keep the prompt intact when it fits, applying the calculated output-token ceiling. Otherwise return a non-transient `context_limit` response before contacting the provider, identifying selected lore when present. - Update the existing route/storage regression and Unreleased changelog. No new dependency or setting. ## Validation Automated checks completed: - `pnpm check` and `pnpm regression:prompt` passed on the updated staging base. - `node scripts/run-regressions.mjs --filter experience-lore-entries` passed, including 101 selected entries from one default-budget book, roughly 200,000 tokens of literal lore on a large-context connection, explicitly picked outlets, disabled/deleted selections, ordinary budget preservation, oversized initial prompts and oversized JSON repairs. - The updated selection regression fails against the previous automatic-budget implementation. With only the new route context check removed, the context regression fails because an oversized request reaches the provider and returns success. - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Manually verify world generation through the paired Pixelforge picker with a live provider, including a large selection and a small-context rejection. These checks are not claimed as completed. Local regressions use a synthetic HTTP provider and real route/storage code. ## Docs and release impact Unreleased changelog only; no version or user-guide changes. Pixelforge picker arithmetic and context-limit copy are handled in the package repository against staging. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - World generation now preserves all explicitly selected lorebook entries, including large selections and entries with additional content. - Automatic lorebook token and entry limits no longer truncate exact player selections. - Oversized prompts and repair requests now return a clear context-limit error before being sent for generation. - Generation requests are adjusted to fit within the model’s available context window. - Added coverage to verify that ordinary lorebook selection limits continue to apply. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:15:42 +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-Engine#7010
No description provided.