[PR #7601] [MERGED] fix(memory): default the summary and recall budget to 10% of the context #7828

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

📋 Pull Request Information

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

Base: staging ← Head: fix/memory-budget-default-10pct


📝 Commits (2)

  • 76ebb3d fix(memory): default the summary and recall budget to 10% of the context
  • 1a1366f Merge branch 'staging' into fix/memory-budget-default-10pct

📊 Changes

3 files changed (+33 additions, -4 deletions)

View changed files

📝 packages/shared/src/types/advanced-memory.ts (+10 -3)
📝 scripts/regressions/advanced-memory-post-generation.regression.ts (+7 -1)
📝 scripts/regressions/advanced-memory-recall.regression.ts (+16 -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

No linked issue: decided by the maintainer on 2026-10-14.

Why this change

  • The Advanced Memory help (#7595) recommends a Summary and recall budget of at least 10% of the maximum allowed context. New chats started at 4,096 of 65,000 tokens, which is about 6%, so the default went against the advice next to it.
  • Mari decided that new chats should start at 10% of the context limit (6,500 for the 65,000 default), and that existing chats keep the budget they have.

What changed

  • packages/shared/src/types/advanced-memory.ts: DEFAULT_ADVANCED_MEMORY_SETTINGS now sets the budget to 10% of the default context limit, rounded to whole tokens (6,500). normalizeAdvancedMemorySettings uses these defaults when a chat has no saved Advanced Memory settings.
  • Existing chats keep their budget:
    • Saved settings keep their own budget. updateSettings saves the whole settings object, so any chat that has saved settings already stores a budget.
    • Settings saved without a budget still read as 4,096. The schema fallback is unchanged, so these chats don't move to 6,500 either.
    • A chat with no saved settings has Advanced Memory off. It gets 6,500 when it is first switched on. That first save creates the settings.
  • The 10% doesn't follow a later context change. The context field appears only after Advanced Memory is switched on, and switching it on already saves the 6,500 budget. Changing the context afterwards leaves the budget as it is. The existing rule still keeps it below the context limit.
  • Regressions:
    • advanced-memory-recall now checks that a new chat saves 6,500. It also checks that a chat saved with 4,096, and a chat saved without a budget, both still store 4,096 after an unrelated settings change.
    • advanced-memory-post-generation: two fixtures spread the defaults and had summaries sized to go over 70% of the old 4,096 default. They now set summaryBudgetTokens: 4096 explicitly. Their assertions are unchanged.

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

Commands run by the agent:

  • node ./scripts/run-regressions.mjs --filter scripts/regressions/advanced-memory-recall.regression.ts:
    • Fails before the fix: actual 4096, expected 6500.
    • Passes after the fix.
    • Also fails if the schema default is simply changed to 6500: a chat saved without a budget gets 6500, expected 4096. So the existing-chat check catches that shortcut.
  • node ./scripts/run-regressions.mjs --filter advanced-memory: 16/16 passed.
  • memory-recall-exclusivity, roleplay-regeneration-context, roleplay-interrupt-generation, roleplay-whisper-hidden-recipient, context-message-limit-modes regressions: all passed.
  • pnpm localization:check: passed.
  • pnpm check: passed. One existing lint warning in a client file this PR doesn't touch.
  • Local CodeRabbit (coderabbit review --agent --committed): one trivial finding, no change needed. It asked to confirm that the UI doesn't show 10% for settings saved without a budget. It doesn't: the panel reads the same normalizeAdvancedMemorySettings result as the server and shows the saved 4,096.
  • Playwright e2e was not run.

Manual verification notes

  • Manually verify in the browser: in a new Roleplay chat, switch on Advanced Memory Recall in Chat Settings → Memory Recall. Summary and recall budget (tokens) shows 6500 next to a 65000 context limit.
  • Manually verify the same in the Roleplay setup wizard (Automatic context and memory handling).
  • Manually verify that an existing chat where Advanced Memory was already on still shows its earlier budget (for example 4096) after updating.
  • Manually verify that changing the context limit after switching Advanced Memory on leaves the budget as it was, unless the new limit is at or below it.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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)

docs/agents/memory.md doesn't mention the budget's default, so this PR changes no docs and needs no translation follow-up. A sentence about the new default could go into the budget bullet after #7595 merges, since #7595 edits that line.

UI evidence (if applicable)

None. No UI code changed; the budget field only shows a different starting value.

Summary by CodeRabbit

  • New Features
    • New Advanced Memory settings now allocate a summary budget of 10% of the context limit by default (6,500 tokens for a 65,000-token context).
  • Bug Fixes
    • Existing saved settings retain their 4,096-token summary budget, including older settings that did not explicitly save a budget.

🔄 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/7601 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/memory-budget-default-10pct` --- ### 📝 Commits (2) - [`76ebb3d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/76ebb3d04688da17f6049581688c50cba4121645) fix(memory): default the summary and recall budget to 10% of the context - [`1a1366f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1a1366fd4fa21896587e13e79d288568094c6d42) Merge branch 'staging' into fix/memory-budget-default-10pct ### 📊 Changes **3 files changed** (+33 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/shared/src/types/advanced-memory.ts` (+10 -3) 📝 `scripts/regressions/advanced-memory-post-generation.regression.ts` (+7 -1) 📝 `scripts/regressions/advanced-memory-recall.regression.ts` (+16 -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 No linked issue: decided by the maintainer on 2026-10-14. ## Why this change - The Advanced Memory help (#7595) recommends a **Summary and recall budget** of at least 10% of the maximum allowed context. New chats started at 4,096 of 65,000 tokens, which is about 6%, so the default went against the advice next to it. - Mari decided that new chats should start at 10% of the context limit (6,500 for the 65,000 default), and that existing chats keep the budget they have. ## What changed - `packages/shared/src/types/advanced-memory.ts`: `DEFAULT_ADVANCED_MEMORY_SETTINGS` now sets the budget to 10% of the default context limit, rounded to whole tokens (6,500). `normalizeAdvancedMemorySettings` uses these defaults when a chat has no saved Advanced Memory settings. - Existing chats keep their budget: - Saved settings keep their own budget. `updateSettings` saves the whole settings object, so any chat that has saved settings already stores a budget. - Settings saved without a budget still read as 4,096. The schema fallback is unchanged, so these chats don't move to 6,500 either. - A chat with no saved settings has Advanced Memory off. It gets 6,500 when it is first switched on. That first save creates the settings. - The 10% doesn't follow a later context change. The context field appears only after Advanced Memory is switched on, and switching it on already saves the 6,500 budget. Changing the context afterwards leaves the budget as it is. The existing rule still keeps it below the context limit. - Regressions: - `advanced-memory-recall` now checks that a new chat saves 6,500. It also checks that a chat saved with 4,096, and a chat saved without a budget, both still store 4,096 after an unrelated settings change. - `advanced-memory-post-generation`: two fixtures spread the defaults and had summaries sized to go over 70% of the old 4,096 default. They now set `summaryBudgetTokens: 4096` explicitly. Their assertions are unchanged. ## 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` Commands run by the agent: - `node ./scripts/run-regressions.mjs --filter scripts/regressions/advanced-memory-recall.regression.ts`: - Fails before the fix: actual 4096, expected 6500. - Passes after the fix. - Also fails if the schema default is simply changed to 6500: a chat saved without a budget gets 6500, expected 4096. So the existing-chat check catches that shortcut. - `node ./scripts/run-regressions.mjs --filter advanced-memory`: 16/16 passed. - `memory-recall-exclusivity`, `roleplay-regeneration-context`, `roleplay-interrupt-generation`, `roleplay-whisper-hidden-recipient`, `context-message-limit-modes` regressions: all passed. - `pnpm localization:check`: passed. - `pnpm check`: passed. One existing lint warning in a client file this PR doesn't touch. - Local CodeRabbit (`coderabbit review --agent --committed`): one trivial finding, no change needed. It asked to confirm that the UI doesn't show 10% for settings saved without a budget. It doesn't: the panel reads the same `normalizeAdvancedMemorySettings` result as the server and shows the saved 4,096. - Playwright e2e was not run. ### Manual verification notes - Manually verify in the browser: in a new Roleplay chat, switch on **Advanced Memory Recall** in Chat Settings → Memory Recall. **Summary and recall budget (tokens)** shows 6500 next to a 65000 context limit. - Manually verify the same in the Roleplay setup wizard (**Automatic context and memory handling**). - Manually verify that an existing chat where Advanced Memory was already on still shows its earlier budget (for example 4096) after updating. - Manually verify that changing the context limit after switching Advanced Memory on leaves the budget as it was, unless the new limit is at or below it. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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) `docs/agents/memory.md` doesn't mention the budget's default, so this PR changes no docs and needs no translation follow-up. A sentence about the new default could go into the budget bullet after #7595 merges, since #7595 edits that line. ## UI evidence (if applicable) None. No UI code changed; the budget field only shows a different starting value. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * New Advanced Memory settings now allocate a summary budget of 10% of the context limit by default (6,500 tokens for a 65,000-token context). * **Bug Fixes** * Existing saved settings retain their 4,096-token summary budget, including older settings that did not explicitly save a budget. <!-- 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:07:55 +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#7828
No description provided.