[PR #7331] [MERGED] fix(chat-settings): say when Advanced Memory sizes Roleplay history #7682

Closed
opened 2026-10-24 04:06:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7331
Author: @SpicyMarinara
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/7321-rp-context-message-limit


📝 Commits (7)

  • 941cb93 fix(chat-settings): say when Advanced Memory sizes Roleplay history
  • 473dc18 test(regressions): note the ceiling of the drawer wiring check
  • 00281a3 Merge origin/staging into fix/7321-rp-context-message-limit
  • d5a0ac4 test(regressions): check the note's display condition in Advanced Parameters
  • af1f086 Merge origin/staging into fix/7321-rp-context-message-limit
  • a421df7 Merge origin/staging into fix/7321-rp-context-message-limit
  • dc103be Move the CHANGELOG entry away from other open PRs

📊 Changes

6 files changed (+147 additions, -0 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/prompts/generation-parameters.md (+2 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+1 -0)
📝 packages/client/src/features/chat-settings/sections/AdvancedParametersSection.tsx (+8 -0)
📝 packages/client/src/localization/locales/en.json (+1 -0)
➕ scripts/regressions/context-message-limit-modes.regression.ts (+134 -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 #7321

Why this change

  • A Roleplay user on 2.5.0 set Limit Context Messages to 45 to cut token costs, but every reply still sent 200+ messages. Changing the value and restarting made no difference.
  • Cause: in Roleplay chats with Advanced Memory Recall on, the limit is skipped on purpose. generate.routes.ts (line 1909) and generate/dry-run-route.ts (line 758) apply it only when !advancedMemoryEnabled. Advanced Memory then sizes the history with its own token cap, Maximum allowed context before compression (default 65,000 tokens), so a long chat can send far more than 45 messages. Advanced Memory came out of Alpha in 2.5.0, which fits "it worked before the update".
  • scripts/regressions/advanced-memory-generation.regression.ts sets contextMessageLimit: 1 on its Advanced Memory chat and still expects earlier messages, such as HISTORY_9 at line 631. So Advanced Memory skipping the limit is intended, and this PR does not change it.
  • The bug the user saw is that Chat Settings → Advanced Parameters kept showing the limit as active and gave no hint that a different setting was in charge.
  • I checked Conversation, Game and plain Roleplay: all three already send only the last N messages.

What changed

  • Advanced Parameters: while Advanced Memory is on in a Roleplay chat and Limit Context Messages is on, a muted note under the limit says: "With Advanced Memory Recall on, its Maximum allowed context decides how much history is sent." It uses the drawer's existing advancedMemoryEnabled value. The new key is in en.json only.
  • Docs: docs/prompts/generation-parameters.md → Context message limit now explains that this limit is not used while Advanced Memory is on, and how to send less history in that case.
  • Regression: scripts/regressions/context-message-limit-modes.regression.ts uses /api/generate/dryRun to check that Conversation, Game and plain Roleplay send only the last 3 of 12 messages and that Advanced Memory sends all 12 while they fit its cap. It also checks that the drawer passes advancedMemoryEnabled to the section, that the section shows the note only while both the limit and Advanced Memory are on, and that the English key exists. The wiring check fails on current staging.
  • CHANGELOG: one entry under [Unreleased].

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

  • Manually verify in a browser: open a Roleplay chat with Advanced Memory Recall on, open Chat Settings → Advanced Parameters, and turn on Limit Context Messages. The note should appear under the number field.
  • Manually verify that the note disappears when Advanced Memory Recall is turned off, and that it never shows in Conversation or Game chats.
  • Manually verify that the note is readable in light and dark mode, on desktop and on a phone-width viewport, and in the popped-out Chat Settings window.
  • Manually verify with Peek Prompt that a Roleplay chat without Advanced Memory sends only the last N messages.

Agent-run checks: pnpm check passed. pnpm regression:prompt passed (prompt, prompt-attachments and context-fit). pnpm localization:check passed. node ./scripts/run-regressions.mjs --filter scripts/regressions/context-message-limit-modes passes, and with the client change removed it fails on the wiring check. scripts/regressions/advanced-memory-generation.regression.ts passes. Local CodeRabbit (--committed against the staging merge base) returned 1 trivial finding: it asked to replace the source-text wiring check with a rendered component test. I did not do that, because rendering AdvancedParametersSection needs a QueryClient, i18n and several connection hooks that no regression harness provides yet. The check follows the source-check pattern that floating-window.regression.ts already uses for this drawer. A ponytail: comment records its limit and how to replace it later. GitHub CodeRabbit then asked for a check of the section's display condition; that source check was added in d5a0ac489, and a second local CodeRabbit run on the final code returned no findings.

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)

Translation follow-up: #7330 ([docs-i18n] docs/prompts/generation-parameters.md).

UI evidence (if applicable)

No screenshots. The change is one line of muted helper text under an existing control.

Maintainer decision

If Limit Context Messages should also cap the live window under Advanced Memory, as the issue expected, that takes a small change in prepareImpl (packages/server/src/services/advanced-memory.ts). A message limit would trigger the same scene rollover and bounded earlier-scene excerpts that the token cap triggers today. That change breaks advanced-memory-generation.regression.ts line 631, because its fixture sets contextMessageLimit: 1. The fixture would need your approval to change, so this PR leaves that behaviour as it is.

Summary by CodeRabbit

  • Documentation
    • Clarified that in Roleplay chats with Advanced Memory enabled, the Advanced Memory maximum-context-before-compression setting—not Limit Context Messages—determines how much chat history is sent. Users can adjust the Advanced Memory setting to reduce history. The message limit remains effective in other chat modes and in Roleplay without Advanced Memory.
  • User Interface
    • Added an explanatory note under Limit Context Messages when Advanced Memory is enabled.

🔄 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/7331 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/7321-rp-context-message-limit` --- ### 📝 Commits (7) - [`941cb93`](https://github.com/Pasta-Devs/Marinara-Engine/commit/941cb9353c1640ee7b0587bb8c2ad23fbee70bd2) fix(chat-settings): say when Advanced Memory sizes Roleplay history - [`473dc18`](https://github.com/Pasta-Devs/Marinara-Engine/commit/473dc18130bcdc5dd9df460f11b6b81808bc33a8) test(regressions): note the ceiling of the drawer wiring check - [`00281a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/00281a31957886af5147f6687435d487ea107aa0) Merge origin/staging into fix/7321-rp-context-message-limit - [`d5a0ac4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d5a0ac489c244177fe03af5d7991c98698b9a06d) test(regressions): check the note's display condition in Advanced Parameters - [`af1f086`](https://github.com/Pasta-Devs/Marinara-Engine/commit/af1f0864f431c534b27d2cdf3c79ab8ab0aa8512) Merge origin/staging into fix/7321-rp-context-message-limit - [`a421df7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a421df754bc94fe53d42ef7c63c35aa714cb5c99) Merge origin/staging into fix/7321-rp-context-message-limit - [`dc103be`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dc103be28d5f96335338539865382b5e4c373011) Move the CHANGELOG entry away from other open PRs ### 📊 Changes **6 files changed** (+147 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/prompts/generation-parameters.md` (+2 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+1 -0) 📝 `packages/client/src/features/chat-settings/sections/AdvancedParametersSection.tsx` (+8 -0) 📝 `packages/client/src/localization/locales/en.json` (+1 -0) ➕ `scripts/regressions/context-message-limit-modes.regression.ts` (+134 -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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7321 ## Why this change - A Roleplay user on 2.5.0 set **Limit Context Messages** to 45 to cut token costs, but every reply still sent 200+ messages. Changing the value and restarting made no difference. - Cause: in Roleplay chats with **Advanced Memory Recall** on, the limit is skipped on purpose. `generate.routes.ts` (line 1909) and `generate/dry-run-route.ts` (line 758) apply it only when `!advancedMemoryEnabled`. Advanced Memory then sizes the history with its own token cap, **Maximum allowed context before compression** (default 65,000 tokens), so a long chat can send far more than 45 messages. Advanced Memory came out of Alpha in 2.5.0, which fits "it worked before the update". - `scripts/regressions/advanced-memory-generation.regression.ts` sets `contextMessageLimit: 1` on its Advanced Memory chat and still expects earlier messages, such as `HISTORY_9` at line 631. So Advanced Memory skipping the limit is intended, and this PR does not change it. - The bug the user saw is that **Chat Settings → Advanced Parameters** kept showing the limit as active and gave no hint that a different setting was in charge. - I checked Conversation, Game and plain Roleplay: all three already send only the last N messages. ## What changed - **Advanced Parameters**: while Advanced Memory is on in a Roleplay chat and **Limit Context Messages** is on, a muted note under the limit says: "With Advanced Memory Recall on, its Maximum allowed context decides how much history is sent." It uses the drawer's existing `advancedMemoryEnabled` value. The new key is in `en.json` only. - **Docs**: `docs/prompts/generation-parameters.md` → **Context message limit** now explains that this limit is not used while Advanced Memory is on, and how to send less history in that case. - **Regression**: `scripts/regressions/context-message-limit-modes.regression.ts` uses `/api/generate/dryRun` to check that Conversation, Game and plain Roleplay send only the last 3 of 12 messages and that Advanced Memory sends all 12 while they fit its cap. It also checks that the drawer passes `advancedMemoryEnabled` to the section, that the section shows the note only while both the limit and Advanced Memory are on, and that the English key exists. The wiring check fails on current `staging`. - **CHANGELOG**: one entry under `[Unreleased]`. ## 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 - Manually verify in a browser: open a Roleplay chat with **Advanced Memory Recall** on, open **Chat Settings → Advanced Parameters**, and turn on **Limit Context Messages**. The note should appear under the number field. - Manually verify that the note disappears when Advanced Memory Recall is turned off, and that it never shows in Conversation or Game chats. - Manually verify that the note is readable in light and dark mode, on desktop and on a phone-width viewport, and in the popped-out Chat Settings window. - Manually verify with **Peek Prompt** that a Roleplay chat without Advanced Memory sends only the last N messages. Agent-run checks: `pnpm check` passed. `pnpm regression:prompt` passed (prompt, prompt-attachments and context-fit). `pnpm localization:check` passed. `node ./scripts/run-regressions.mjs --filter scripts/regressions/context-message-limit-modes` passes, and with the client change removed it fails on the wiring check. `scripts/regressions/advanced-memory-generation.regression.ts` passes. Local CodeRabbit (`--committed` against the staging merge base) returned 1 trivial finding: it asked to replace the source-text wiring check with a rendered component test. I did not do that, because rendering `AdvancedParametersSection` needs a QueryClient, i18n and several connection hooks that no regression harness provides yet. The check follows the source-check pattern that `floating-window.regression.ts` already uses for this drawer. A `ponytail:` comment records its limit and how to replace it later. GitHub CodeRabbit then asked for a check of the section's display condition; that source check was added in d5a0ac489, and a second local CodeRabbit run on the final code returned no findings. ## 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) Translation follow-up: #7330 (`[docs-i18n] docs/prompts/generation-parameters.md`). ## UI evidence (if applicable) No screenshots. The change is one line of muted helper text under an existing control. ## Maintainer decision If **Limit Context Messages** should also cap the live window under Advanced Memory, as the issue expected, that takes a small change in `prepareImpl` (`packages/server/src/services/advanced-memory.ts`). A message limit would trigger the same scene rollover and bounded earlier-scene excerpts that the token cap triggers today. That change breaks `advanced-memory-generation.regression.ts` line 631, because its fixture sets `contextMessageLimit: 1`. The fixture would need your approval to change, so this PR leaves that behaviour as it is. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Clarified that in Roleplay chats with Advanced Memory enabled, the Advanced Memory maximum-context-before-compression setting—not **Limit Context Messages**—determines how much chat history is sent. Users can adjust the Advanced Memory setting to reduce history. The message limit remains effective in other chat modes and in Roleplay without Advanced Memory. * **User Interface** * Added an explanatory note under **Limit Context Messages** when Advanced Memory is enabled. <!-- 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-24 04:06:29 +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#7682
No description provided.