[GH-ISSUE #2820] [Feature]: Rolling summary token compression for roleplay (auto-hide summarized messages with a tail) #1429

Closed
opened 2026-10-21 05:33:44 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Romuromylus on GitHub.

What problem does this solve?

In roleplay / visual-novel mode the rolling summary runs automatically every N user messages and injects a recap into the prompt, but it never hides the messages it just summarized. The originals stay in context, so each summary is a net token increase layered on top of the history it was meant to compress — the opposite of what a rolling summary is for. The only ways to actually save tokens today are to manually cap context messages in Advanced Parameters, or to manually generate a summary in the Summary popover with "Hide summarised messages" ticked — and even that hides everything the summary touched with no tail, so the most recent turns can vanish and break conversational flow.

Concretely, on staging (119df4d0):

  • Roleplay auto-summary builds a ChatSummaryEntry carrying messageIds but never calls the bulk-hide path, so the summarized originals stay visible (packages/server/src/routes/generate.routes.ts ~7329–7346).
  • "Hide summarised messages" is a browser-local UI preference (summaryPopoverSettings.hideSummarisedMessages), not part of ChatMetadata, so the server auto-summary cannot read it. It only fires on manual generation (packages/client/src/components/chat/SummaryPopover.tsx:500–534).
  • summaryTailMessages already exists in ChatMetadata and is honored for conversation-mode day/week summaries, but is not wired into roleplay summaries (packages/shared/src/types/chat.ts:476, read at packages/server/src/routes/generate.routes.ts:2654).
  • Deleting a summary entry never unhides the messages it covered, so removing or disabling a summary can leave permanently-orphaned hidden messages (packages/client/src/components/chat/SummaryPopover.tsx:643–666).

Proposed solution

Wire the pieces that already exist (hiddenFromAI, per-entry messageIds, the bulkSetMessagesHiddenFromAI API, the collapsible hidden-message UI) into the automatic roleplay summary path:

  1. Auto-hide summarized messages — when the roleplay rolling summary runs, mark the summarized messages hiddenFromAI, but respect a configurable tail so the last N messages always stay visible. This makes the summary actually compress context instead of inflating it.
  2. Unhide on summary delete — deleting a summary entry should unhide the messages it covered, except any still referenced by another enabled entry. No orphaned hidden messages.
  3. Wire summaryTailMessages for roleplay — reuse the existing field and slider (today conversation-mode only) so roleplay gets a per-chat control for how many recent messages stay visible after auto-hiding.
  4. Persist the "Hide summarised messages" toggle to chat metadata — promote it from a browser-local UI pref to a per-chat setting the server auto-summary can read, so behavior is consistent across the manual and automatic paths.

Alternatives considered

  • Manual context cap in Advanced Parameters — works, but it is a blunt global cap that does not scale and discards recent turns wholesale rather than compressing older ones.
  • Manual "Hide summarised messages" in the Summary popover — exists today, but only on manual generation; it hides everything with no tail (risking loss of recent context), does not persist so rolling/auto summaries cannot apply it, and orphans hidden messages on delete. Insufficient for the automatic token-compression use case this request is about.

Additional context

  • Prior art: #1526 ("Automated chat summaries do not honor hide-summarized-messages setting") covered part of this, but on the now-discontinued refactor line; the gap is still present on staging.
  • Came in as a community feature request; verified end-to-end against staging (119df4d0) before filing.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 23, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2820 Originally assigned to: @Romuromylus on GitHub. ## What problem does this solve? In roleplay / visual-novel mode the rolling summary runs automatically every N user messages and injects a recap into the prompt, but it never hides the messages it just summarized. The originals stay in context, so each summary is a net token *increase* layered on top of the history it was meant to compress — the opposite of what a rolling summary is for. The only ways to actually save tokens today are to manually cap context messages in Advanced Parameters, or to manually generate a summary in the Summary popover with "Hide summarised messages" ticked — and even that hides everything the summary touched with no tail, so the most recent turns can vanish and break conversational flow. Concretely, on `staging` (`119df4d0`): - Roleplay auto-summary builds a `ChatSummaryEntry` carrying `messageIds` but never calls the bulk-hide path, so the summarized originals stay visible (`packages/server/src/routes/generate.routes.ts` ~7329–7346). - "Hide summarised messages" is a browser-local UI preference (`summaryPopoverSettings.hideSummarisedMessages`), not part of `ChatMetadata`, so the server auto-summary cannot read it. It only fires on manual generation (`packages/client/src/components/chat/SummaryPopover.tsx:500–534`). - `summaryTailMessages` already exists in `ChatMetadata` and is honored for conversation-mode day/week summaries, but is not wired into roleplay summaries (`packages/shared/src/types/chat.ts:476`, read at `packages/server/src/routes/generate.routes.ts:2654`). - Deleting a summary entry never unhides the messages it covered, so removing or disabling a summary can leave permanently-orphaned hidden messages (`packages/client/src/components/chat/SummaryPopover.tsx:643–666`). ## Proposed solution Wire the pieces that already exist (`hiddenFromAI`, per-entry `messageIds`, the `bulkSetMessagesHiddenFromAI` API, the collapsible hidden-message UI) into the automatic roleplay summary path: 1. **Auto-hide summarized messages** — when the roleplay rolling summary runs, mark the summarized messages `hiddenFromAI`, but respect a configurable tail so the last N messages always stay visible. This makes the summary actually compress context instead of inflating it. 2. **Unhide on summary delete** — deleting a summary entry should unhide the messages it covered, except any still referenced by another enabled entry. No orphaned hidden messages. 3. **Wire `summaryTailMessages` for roleplay** — reuse the existing field and slider (today conversation-mode only) so roleplay gets a per-chat control for how many recent messages stay visible after auto-hiding. 4. **Persist the "Hide summarised messages" toggle to chat metadata** — promote it from a browser-local UI pref to a per-chat setting the server auto-summary can read, so behavior is consistent across the manual and automatic paths. ## Alternatives considered - **Manual context cap in Advanced Parameters** — works, but it is a blunt global cap that does not scale and discards recent turns wholesale rather than compressing older ones. - **Manual "Hide summarised messages" in the Summary popover** — exists today, but only on manual generation; it hides everything with no tail (risking loss of recent context), does not persist so rolling/auto summaries cannot apply it, and orphans hidden messages on delete. Insufficient for the automatic token-compression use case this request is about. ## Additional context - Prior art: #1526 ("Automated chat summaries do not honor hide-summarized-messages setting") covered part of this, but on the now-discontinued `refactor` line; the gap is still present on `staging`. - Came in as a community feature request; verified end-to-end against `staging` (`119df4d0`) before filing. ## Template check - [ ] I DID NOT read this template and provide the requested details.
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#1429
No description provided.