[PR #4301] [MERGED] Fix Dynamic LLM Prompt context for Game backgrounds #6327

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4301
Author: @SpicyMarinara
Created: 7/30/2026
Status: ✅ Merged
Merged: 7/30/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/4300-game-background-dynamic-turn-context


📝 Commits (4)

  • 7ea55db Fix dynamic Game background turn context
  • c542fa1 Merge branch 'staging' into fix/4300-game-background-dynamic-turn-context
  • 229b293 fix: tighten dynamic background prompt context
  • 8bef9fb Merge remote-tracking branch 'origin/staging' into fix/4300-game-background-dynamic-turn-context

📊 Changes

4 files changed (+143 additions, -2 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/routes/game.routes.ts (+45 -2)
📝 packages/server/src/services/prompt-overrides/registry/game-assets.ts (+10 -0)
📝 scripts/regressions/prompt.regression.ts (+87 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #4300

Why this change

  • Dynamic LLM Prompt generation for Game backgrounds was given setup/state fields and Marinara's deterministic draft, but not the completed GM turn. Scene-analysis backgrounds could therefore reduce to an unresolved tag, while Gallery backgrounds only supplied a short assembled description, causing the prompt model to paraphrase fallback data rather than author the image prompt from the actual scene.

What changed

  • select the latest non-empty assistant or narrator Game turn on the server and remove GM command tags
  • include that turn as a first-class <latest_gm_turn> block for background prompt-director requests
  • make the latest turn authoritative for visible environment details while retaining the deterministic prompt as supporting context
  • apply the shared context to both prompt preview and final /game/generate-assets generation paths
  • expose latestTurnBlock to custom Game Image Prompt Director templates
  • add regression coverage and an Unreleased changelog note

Validation

  • 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

Automated evidence completed:

  • pnpm check — passed
  • pnpm regression:prompt — passed
  • git diff --check — passed

Manual verification notes

  • With Dynamic LLM Prompt enabled, generate a missing background from scene analysis and verify the prompt-model request contains the completed GM turn.
  • Use Gallery → Background after a distinctive GM turn and verify the prompt-model request and provider-facing prompt describe that turn.
  • Disable Dynamic LLM Prompt and verify the deterministic background prompt remains unchanged.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Not applicable; this is a server-side prompt-routing fix with no UI changes.

Summary by CodeRabbit

  • New Features

    • Dynamic game background images now use the latest completed Game Master turn as the primary scene context.
    • Scene analysis and Gallery background requests produce prompts that better reflect the current visible environment.
  • Bug Fixes

    • Improved narration handling for completed Game Master turns.
    • Preserved portrait-specific instructions without adding background-scene context where it does not apply.
  • Tests

    • Added regression coverage for current-scene background prompts and portrait prompt isolation.

🔄 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/4301 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/30/2026 **Status:** ✅ Merged **Merged:** 7/30/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/4300-game-background-dynamic-turn-context` --- ### 📝 Commits (4) - [`7ea55db`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7ea55dbcc34ee4dcd7f0e74edfb59425abf0919b) Fix dynamic Game background turn context - [`c542fa1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c542fa12608e7fb356ad24a4134b1e5aebb2de10) Merge branch 'staging' into fix/4300-game-background-dynamic-turn-context - [`229b293`](https://github.com/Pasta-Devs/Marinara-Engine/commit/229b293bb2fe2141307ce21eda388811adc485fd) fix: tighten dynamic background prompt context - [`8bef9fb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8bef9fb8fb77bd443b0bcb466b3d3002166732fe) Merge remote-tracking branch 'origin/staging' into fix/4300-game-background-dynamic-turn-context ### 📊 Changes **4 files changed** (+143 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/routes/game.routes.ts` (+45 -2) 📝 `packages/server/src/services/prompt-overrides/registry/game-assets.ts` (+10 -0) 📝 `scripts/regressions/prompt.regression.ts` (+87 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #4300 ## Why this change - Dynamic LLM Prompt generation for Game backgrounds was given setup/state fields and Marinara's deterministic draft, but not the completed GM turn. Scene-analysis backgrounds could therefore reduce to an unresolved tag, while Gallery backgrounds only supplied a short assembled description, causing the prompt model to paraphrase fallback data rather than author the image prompt from the actual scene. ## What changed - select the latest non-empty assistant or narrator Game turn on the server and remove GM command tags - include that turn as a first-class `<latest_gm_turn>` block for background prompt-director requests - make the latest turn authoritative for visible environment details while retaining the deterministic prompt as supporting context - apply the shared context to both prompt preview and final `/game/generate-assets` generation paths - expose `latestTurnBlock` to custom Game Image Prompt Director templates - add regression coverage and an Unreleased changelog note ## Validation - [ ] `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` Automated evidence completed: - `pnpm check` — passed - `pnpm regression:prompt` — passed - `git diff --check` — passed ### Manual verification notes - [ ] With Dynamic LLM Prompt enabled, generate a missing background from scene analysis and verify the prompt-model request contains the completed GM turn. - [ ] Use Gallery → Background after a distinctive GM turn and verify the prompt-model request and provider-facing prompt describe that turn. - [ ] Disable Dynamic LLM Prompt and verify the deterministic background prompt remains unchanged. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Not applicable; this is a server-side prompt-routing fix with no UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Dynamic game background images now use the latest completed Game Master turn as the primary scene context. * Scene analysis and Gallery background requests produce prompts that better reflect the current visible environment. * **Bug Fixes** * Improved narration handling for completed Game Master turns. * Preserved portrait-specific instructions without adding background-scene context where it does not apply. * **Tests** * Added regression coverage for current-scene background prompts and portrait prompt isolation. <!-- 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:09:22 +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#6327
No description provided.