[PR #7756] [MERGED] fix(prompt): preserve long manual summaries in model context #7915

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

📋 Pull Request Information

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

Base: staging ← Head: fix/7754-manual-summary-context


📝 Commits (2)

  • 016a897 test: reproduce long manual summary truncation
  • 96742aa fix: preserve authored text beyond macro output ceiling

📊 Changes

2 files changed (+143 additions, -2 deletions)

View changed files

📝 packages/shared/src/utils/macro-engine.ts (+8 -2)
📝 scripts/regressions/prompt.regression.ts (+135 -0)

📄 Description

Linked issue

Closes #7754

Why this change

Long chats silently lost the newest manual summaries before the model context-budget check. The macro resolver clipped all output to 200,000 characters, even text containing no macros. A synthetic 95-summary chat reproduced the reported apparent cutoff at 73 summaries despite ample model capacity.

What changed

  • Preserve authored input during macro resolution by allowing its original length plus a bounded 200,000 characters of additional expansion.
  • Share that computed ceiling with recursive calls, preserve shared expansion counters, and keep explicit caller-provided output caps absolute.
  • Add regression coverage for 95 manual summaries through fallback and explicit summary-marker assembly, deferred character substitutions, disabled summaries, semantic recent-only selection, reused options, and expansion-limit controls.

Validation

Completed locally on the final source in 96742aad4e9da4ec3b9f93b35fbac0fd1b18d430:

  • pnpm install; pnpm check passed. The existing client hook/build warnings remain unchanged.
  • Shared build, formatting, and prompt, prompt-attachment, and context-fit regressions passed. The three new cases failed before the production fix and passed afterward.
  • pnpm smoke:ui: 7 passed.
  • pnpm smoke:production: 3 passed (desktop Chromium, mobile Chromium, mobile WebKit).
  • docker build -t marinara-7754:local . passed; the isolated container served a healthy API, compiled frontend, and built asset, then shut down cleanly.
  • Local CodeRabbit review completed on both changed files with one minor suggestion dismissed: baseline already mutates options through getMacroBudget, and summary scoping intentionally shares that counter across parts/readers. Resetting it would alter the existing expansion guard. An independent baseline-versus-patch probe confirmed identical frozen/reused-options behavior.
  • Complete Node run (node scripts/run-regressions.mjs): 908/909 files passed. The sole failure was an avatar-renderer import while browser setup concurrently rewrote shared build output; its isolated rerun passed (1/1). All 909 files passed across the run and that rerun; the initial aggregate command itself exited nonzero.
  • All eight required GitHub checks passed for the final head. Hosted CodeRabbit completed substantive review of both changed files; the same pre-existing budget-sharing finding was explained and resolved, with zero unresolved threads. The supplemental hosted full Node lane was still running at this verification.

Human verification checklist:

  • Manually verify the reporter's long chat includes all enabled manual summaries when semantic retrieval is disabled and model context has room.
  • Manually verify the affected Android/Termux installation after updating to staging.

Claim boundary and remaining risks

The runnable proof covers shared host prompt assembly with synthetic summaries, both placement paths, positive retention, disabled-entry exclusion, semantic-selection behavior, and explicit/default macro-limit controls. It does not use the reporter's unavailable chat export or physical device. Actual model context fitting can still remove content when capacity is exhausted. Extremely large macro expansions, including encoded deferred conditional payloads, remain subject to the expansion guard.

Docs and release impact

No storage format, release metadata, or user-facing documentation changes.

Summary by CodeRabbit

  • Bug Fixes
    • Macro output limits now preserve authored text by default while capping macro-generated additions. Explicit limits continue to cap the full result.
    • Roleplay summaries are retained more reliably when fitting prompts, including their endings when space is available. With semantic retrieval disabled, all enabled summaries are included; when enabled, selection follows the configured recent-summary count.

🔄 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/7756 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/7754-manual-summary-context` --- ### 📝 Commits (2) - [`016a897`](https://github.com/Pasta-Devs/Marinara-Engine/commit/016a897f7fa427d51a77c076436dbfa5790b7ac2) test: reproduce long manual summary truncation - [`96742aa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/96742aad4e9da4ec3b9f93b35fbac0fd1b18d430) fix: preserve authored text beyond macro output ceiling ### 📊 Changes **2 files changed** (+143 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/shared/src/utils/macro-engine.ts` (+8 -2) 📝 `scripts/regressions/prompt.regression.ts` (+135 -0) </details> ### 📄 Description ## Linked issue Closes #7754 ## Why this change Long chats silently lost the newest manual summaries before the model context-budget check. The macro resolver clipped all output to 200,000 characters, even text containing no macros. A synthetic 95-summary chat reproduced the reported apparent cutoff at 73 summaries despite ample model capacity. ## What changed - Preserve authored input during macro resolution by allowing its original length plus a bounded 200,000 characters of additional expansion. - Share that computed ceiling with recursive calls, preserve shared expansion counters, and keep explicit caller-provided output caps absolute. - Add regression coverage for 95 manual summaries through fallback and explicit summary-marker assembly, deferred character substitutions, disabled summaries, semantic recent-only selection, reused options, and expansion-limit controls. ## Validation Completed locally on the final source in `96742aad4e9da4ec3b9f93b35fbac0fd1b18d430`: - `pnpm install`; `pnpm check` passed. The existing client hook/build warnings remain unchanged. - Shared build, formatting, and prompt, prompt-attachment, and context-fit regressions passed. The three new cases failed before the production fix and passed afterward. - `pnpm smoke:ui`: 7 passed. - `pnpm smoke:production`: 3 passed (desktop Chromium, mobile Chromium, mobile WebKit). - `docker build -t marinara-7754:local .` passed; the isolated container served a healthy API, compiled frontend, and built asset, then shut down cleanly. - Local CodeRabbit review completed on both changed files with one minor suggestion dismissed: baseline already mutates options through `getMacroBudget`, and summary scoping intentionally shares that counter across parts/readers. Resetting it would alter the existing expansion guard. An independent baseline-versus-patch probe confirmed identical frozen/reused-options behavior. - Complete Node run (`node scripts/run-regressions.mjs`): 908/909 files passed. The sole failure was an avatar-renderer import while browser setup concurrently rewrote shared build output; its isolated rerun passed (1/1). All 909 files passed across the run and that rerun; the initial aggregate command itself exited nonzero. - All eight required GitHub checks passed for the final head. Hosted CodeRabbit completed substantive review of both changed files; the same pre-existing budget-sharing finding was explained and resolved, with zero unresolved threads. The supplemental hosted full Node lane was still running at this verification. Human verification checklist: - [ ] Manually verify the reporter's long chat includes all enabled manual summaries when semantic retrieval is disabled and model context has room. - [ ] Manually verify the affected Android/Termux installation after updating to staging. ### Claim boundary and remaining risks The runnable proof covers shared host prompt assembly with synthetic summaries, both placement paths, positive retention, disabled-entry exclusion, semantic-selection behavior, and explicit/default macro-limit controls. It does not use the reporter's unavailable chat export or physical device. Actual model context fitting can still remove content when capacity is exhausted. Extremely large macro expansions, including encoded deferred conditional payloads, remain subject to the expansion guard. ## Docs and release impact No storage format, release metadata, or user-facing documentation changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Macro output limits now preserve authored text by default while capping macro-generated additions. Explicit limits continue to cap the full result. * Roleplay summaries are retained more reliably when fitting prompts, including their endings when space is available. With semantic retrieval disabled, all enabled summaries are included; when enabled, selection follows the configured recent-summary count. <!-- 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:08: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#7915
No description provided.