[PR #2731] [MERGED] [codex] Normalize post-history system prompt roles #5717

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2731
Author: @SpicyMarinara
Created: 6/21/2026
Status: ✅ Merged
Merged: 6/21/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/prompt-post-history-role-normalization


📝 Commits (2)

  • e1ca5ab Normalize post-history system prompt roles
  • 324111f Preserve prompt metadata when appending system content

📊 Changes

4 files changed (+101 additions, -24 deletions)

View changed files

📝 packages/server/src/routes/chats.routes.ts (+10 -2)
📝 packages/server/src/routes/generate.routes.ts (+3 -11)
📝 packages/server/src/routes/generate/dry-run-route.ts (+3 -11)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+85 -0)

📄 Description

Linked issue

No linked issue. Maintainer-requested fix from a prompt preview / preset assembly bug report; open a tracking issue if public discussion is needed.

Why this change

Roleplay prompt presets can include system-role sections after the chat history marker. Those sections should not be hoisted or sent as mid-conversation system messages; they need to preserve provider-safe system/user/assistant alternation.

What changed

  • Added shared provider-safe prompt role normalization for non-leading system messages.
  • Updated live generation, dry-run prompt preview, and Peek Prompt live preview to share the same normalization.
  • Preserved depth-injected system sections by converting them to user role in place, instead of moving them to the latest user turn.

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

Manual verification notes

Commands run locally:

  • pnpm --filter @marinara-engine/server lint
  • pnpm --filter @marinara-engine/server build
  • pnpm check
  • git diff --check

pnpm check completed successfully. Local environment still prints the existing Node/Vite version warnings.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Server-side prompt assembly fix; no screenshot attached.

Summary by CodeRabbit

  • Bug Fixes
    • Improved system message handling in chat generation pipeline for more consistent prompt processing across routes.
    • Enhanced handling of mid-prompt system messages to better preserve injection-type prompts during provider message preparation.

🔄 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/2731 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 6/21/2026 **Status:** ✅ Merged **Merged:** 6/21/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/prompt-post-history-role-normalization` --- ### 📝 Commits (2) - [`e1ca5ab`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e1ca5ab6526c5747918b8efe187316cfc4455c51) Normalize post-history system prompt roles - [`324111f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/324111f86d7504a4ada89b6f79098c95db4ef417) Preserve prompt metadata when appending system content ### 📊 Changes **4 files changed** (+101 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/chats.routes.ts` (+10 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+3 -11) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+3 -11) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+85 -0) </details> ### 📄 Description ## Linked issue No linked issue. Maintainer-requested fix from a prompt preview / preset assembly bug report; open a tracking issue if public discussion is needed. ## Why this change Roleplay prompt presets can include system-role sections after the chat history marker. Those sections should not be hoisted or sent as mid-conversation system messages; they need to preserve provider-safe system/user/assistant alternation. ## What changed - Added shared provider-safe prompt role normalization for non-leading system messages. - Updated live generation, dry-run prompt preview, and Peek Prompt live preview to share the same normalization. - Preserved depth-injected system sections by converting them to user role in place, instead of moving them to the latest user turn. ## 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` ### Manual verification notes Commands run locally: - `pnpm --filter @marinara-engine/server lint` - `pnpm --filter @marinara-engine/server build` - `pnpm check` - `git diff --check` `pnpm check` completed successfully. Local environment still prints the existing Node/Vite version warnings. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Server-side prompt assembly fix; no screenshot attached. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved system message handling in chat generation pipeline for more consistent prompt processing across routes. * Enhanced handling of mid-prompt system messages to better preserve injection-type prompts during provider message preparation. <!-- 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-22 04:18:48 +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#5717
No description provided.