[GH-ISSUE #1796] Restore roleplay scene planner grounding and background validation #878

Closed
opened 2026-10-21 05:22:48 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Xelvanis on GitHub (Jun 1, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1796

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Roleplay scene planning appears to have lost important grounding from the legacy implementation. The current planner mostly gives the model selected character IDs, recent conversation, and the user request, but it does not appear to provide selected character card context, active persona context, or the real list of available backgrounds.

This can produce weaker scene openings, mismatched POV/persona grounding, and invalid background filenames even though the scene plan contract says background should be a filename from the available list or null.

Evidence

Current refactor path:

  • src/engine/modes/roleplay/scene/scene-service.ts:46 defines planRoleplayScene.
  • src/engine/modes/roleplay/scene/scene-service.ts:65 builds recent history from recent chat messages.
  • src/engine/modes/roleplay/scene/scene-service.ts:84 builds a planner prompt around scene JSON, IDs, and recent conversation.
  • src/engine/modes/roleplay/scene/scene-service.ts:396 sanitizes background but accepts any non-null string.
  • src/engine/contracts/types/scene.ts:46 documents background as a filename from the available list or null.

Legacy behavior had more grounding:

  • packages/server/src/routes/scene.routes.ts:721 loaded character and persona context before planning.
  • packages/server/src/routes/scene.routes.ts:726 loaded available backgrounds and told the planner to choose from that list or use null.
  • packages/server/src/routes/scene.routes.ts:739 included character, persona, available character IDs, backgrounds, and recent conversation in the prompt.
  • packages/server/src/routes/scene.routes.ts:843 validated the chosen background against the available background list before returning the plan.

Related quality gap:

  • src/engine/modes/roleplay/scene/scene-service.ts:317 summarizes concluded scenes with a much more generic transcript-based prompt.
  • Legacy summary generation included character, persona, scene description, scenario, and date context before writing scene memory.

Expected behavior

Scene planning should have enough context to produce a grounded scene setup:

  • selected character card context is available to the planner
  • active persona context is available to the planner
  • available backgrounds are provided as an explicit list
  • returned background is either an exact available filename or null
  • invalid background names are rejected or normalized to null

Scene conclusion summaries should also use the relevant scene, character, and persona context so character scene memories remain high quality.

Suggested fix

  • Add or extend a roleplay scene-planning capability/read model that can supply selected character context, active persona context, and available background filenames while preserving the current engine/feature/runtime boundaries.
  • Pass that data into planRoleplayScene and include it in the planner prompt.
  • Validate the returned background against the available list before creating the scene.
  • Enrich summarizeScene with the scene metadata and selected character/persona context.
  • Keep the current refactor improvements: fallback summary behavior, scene memory dedupe, scene option carryover, and tracker snapshot copying during fork/convert.

Acceptance criteria

  • Scene planning prompts include selected character context, active persona context, and available background filenames.
  • SceneFullPlan.background cannot contain arbitrary or unavailable filenames.
  • Concluded scene summaries include enough scene/persona/character grounding for useful later memory.
  • Existing scene conclude/fork durability behavior remains intact.
Originally created by @Xelvanis on GitHub (Jun 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1796 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Roleplay scene planning appears to have lost important grounding from the legacy implementation. The current planner mostly gives the model selected character IDs, recent conversation, and the user request, but it does not appear to provide selected character card context, active persona context, or the real list of available backgrounds. This can produce weaker scene openings, mismatched POV/persona grounding, and invalid background filenames even though the scene plan contract says `background` should be a filename from the available list or `null`. ## Evidence Current refactor path: - `src/engine/modes/roleplay/scene/scene-service.ts:46` defines `planRoleplayScene`. - `src/engine/modes/roleplay/scene/scene-service.ts:65` builds recent history from recent chat messages. - `src/engine/modes/roleplay/scene/scene-service.ts:84` builds a planner prompt around scene JSON, IDs, and recent conversation. - `src/engine/modes/roleplay/scene/scene-service.ts:396` sanitizes `background` but accepts any non-null string. - `src/engine/contracts/types/scene.ts:46` documents `background` as a filename from the available list or `null`. Legacy behavior had more grounding: - `packages/server/src/routes/scene.routes.ts:721` loaded character and persona context before planning. - `packages/server/src/routes/scene.routes.ts:726` loaded available backgrounds and told the planner to choose from that list or use `null`. - `packages/server/src/routes/scene.routes.ts:739` included character, persona, available character IDs, backgrounds, and recent conversation in the prompt. - `packages/server/src/routes/scene.routes.ts:843` validated the chosen background against the available background list before returning the plan. Related quality gap: - `src/engine/modes/roleplay/scene/scene-service.ts:317` summarizes concluded scenes with a much more generic transcript-based prompt. - Legacy summary generation included character, persona, scene description, scenario, and date context before writing scene memory. ## Expected behavior Scene planning should have enough context to produce a grounded scene setup: - selected character card context is available to the planner - active persona context is available to the planner - available backgrounds are provided as an explicit list - returned `background` is either an exact available filename or `null` - invalid background names are rejected or normalized to `null` Scene conclusion summaries should also use the relevant scene, character, and persona context so character scene memories remain high quality. ## Suggested fix - Add or extend a roleplay scene-planning capability/read model that can supply selected character context, active persona context, and available background filenames while preserving the current engine/feature/runtime boundaries. - Pass that data into `planRoleplayScene` and include it in the planner prompt. - Validate the returned background against the available list before creating the scene. - Enrich `summarizeScene` with the scene metadata and selected character/persona context. - Keep the current refactor improvements: fallback summary behavior, scene memory dedupe, scene option carryover, and tracker snapshot copying during fork/convert. ## Acceptance criteria - Scene planning prompts include selected character context, active persona context, and available background filenames. - `SceneFullPlan.background` cannot contain arbitrary or unavailable filenames. - Concluded scene summaries include enough scene/persona/character grounding for useful later memory. - Existing scene conclude/fork durability behavior remains intact.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 1, 2026):

On it, queen.

<!-- gh-comment-id:4591561062 --> @SpicyMarinara commented on GitHub (Jun 1, 2026): On it, queen.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 1, 2026):

Fixed on refactor in a2461f33.\n\nWhat changed:\n- Restored scene planner grounding with selected character card context, active persona context, and available background filenames.\n- Enforced exact background filename validation during planning and scene creation, including connected-command overrides.\n- Enriched concluded scene summaries with scene metadata, date, selected character context, persona context, and transcript grounding.\n- Wired the visual asset gateway through roleplay hooks, slash commands, and connected command scene creation without breaking engine/shared API boundaries.\n\nVerification:\n- pnpm typecheck\n- pnpm check:architecture\n- git diff --check

<!-- gh-comment-id:4591766855 --> @SpicyMarinara commented on GitHub (Jun 1, 2026): Fixed on `refactor` in `a2461f33`.\n\nWhat changed:\n- Restored scene planner grounding with selected character card context, active persona context, and available background filenames.\n- Enforced exact background filename validation during planning and scene creation, including connected-command overrides.\n- Enriched concluded scene summaries with scene metadata, date, selected character context, persona context, and transcript grounding.\n- Wired the visual asset gateway through roleplay hooks, slash commands, and connected command scene creation without breaking engine/shared API boundaries.\n\nVerification:\n- `pnpm typecheck`\n- `pnpm check:architecture`\n- `git diff --check`
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#878
No description provided.