[PR #2462] [MERGED] Preserve prompt merge boundaries #5616

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2443-message-merge-boundaries


📝 Commits (2)

  • 0918d4f Preserve prompt merge boundaries
  • 7f09adc Normalize strict role same-role boundaries

📊 Changes

2 files changed (+81 additions, -33 deletions)

View changed files

📝 src/engine/generation-core/prompt/merger.ts (+20 -15)
📝 src/engine/generation/prompt-assembly.ts (+61 -18)

📄 Description

Linked issue

Closes #2443

Why this change

  • Refactor prompt shaping merged adjacent same-role messages even when legacy would preserve separate speaker or context boundaries.

What changed

  • Require prompt merge compatibility to include matching characterId values.
  • Preserve prompt/history/injection context boundaries when both adjacent messages carry incompatible context kinds.
  • Reuse the same merge compatibility check in strict-role prompt shaping's optional same-role merge path.
  • Added focused proof for differing characterId, incompatible contextKind, and still-valid same-speaker/context merges.

Refactor impact

Primary owner:

engine generation / runtime generation prompt shaping

Impact areas reviewed:

  • Provider-ready prompt messages for chat, roleplay, and game.
  • Strict role formatting's optional same-role merge path.
  • Image and provider metadata merging for still-compatible prompt messages.

Boundary notes:

  • Engine-only change under src/engine.
  • No React feature UI, shared API wrapper, Tauri/Rust, storage, import/export, or remote-runtime routing boundaries changed.

Pressure points touched:

  • Prompt assembly final shaping.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts
  • pnpm typecheck
  • pnpm check
  • Durable test rationale: this fixes a provider prompt regression where speaker/context boundaries could silently collapse. Existing line inspection was insufficient because both compatible and incompatible merge rows need to stay stable. The added test coverage is narrow and exercises only prompt message merge boundaries plus one positive merge row.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Internal provider-ready prompt shaping compatibility fix only.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

N/A; no UI changes.


🔄 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/2462 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/issue-2443-message-merge-boundaries` --- ### 📝 Commits (2) - [`0918d4f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0918d4f69e77ec12885d2e18c62274c768cd9cf4) Preserve prompt merge boundaries - [`7f09adc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7f09adcc24798cc07a9d1e30e34dc1d7958ac408) Normalize strict role same-role boundaries ### 📊 Changes **2 files changed** (+81 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation-core/prompt/merger.ts` (+20 -15) 📝 `src/engine/generation/prompt-assembly.ts` (+61 -18) </details> ### 📄 Description ## Linked issue Closes #2443 ## Why this change - Refactor prompt shaping merged adjacent same-role messages even when legacy would preserve separate speaker or context boundaries. ## What changed - Require prompt merge compatibility to include matching `characterId` values. - Preserve prompt/history/injection context boundaries when both adjacent messages carry incompatible context kinds. - Reuse the same merge compatibility check in strict-role prompt shaping's optional same-role merge path. - Added focused proof for differing `characterId`, incompatible `contextKind`, and still-valid same-speaker/context merges. ## Refactor impact Primary owner: engine generation / runtime generation prompt shaping Impact areas reviewed: - Provider-ready prompt messages for chat, roleplay, and game. - Strict role formatting's optional same-role merge path. - Image and provider metadata merging for still-compatible prompt messages. Boundary notes: - Engine-only change under `src/engine`. - No React feature UI, shared API wrapper, Tauri/Rust, storage, import/export, or remote-runtime routing boundaries changed. Pressure points touched: - Prompt assembly final shaping. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts` - `pnpm typecheck` - `pnpm check` - Durable test rationale: this fixes a provider prompt regression where speaker/context boundaries could silently collapse. Existing line inspection was insufficient because both compatible and incompatible merge rows need to stay stable. The added test coverage is narrow and exercises only prompt message merge boundaries plus one positive merge row. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Internal provider-ready prompt shaping compatibility fix only. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A; no UI changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:17:51 +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#5616
No description provided.