[PR #7050] [MERGED] fix(ltm): limit recall input to conversation history (#7044) #7446

Closed
opened 2026-10-23 04:19:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7050
Author: @Promansis
Created: 10/4/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @Promansis

Base: staging ← Head: fix(ltm)/7044-recall-history-only


📝 Commits (7)

  • c44e1e0 fix(ltm): limit recall input to conversation history (#7044)
  • f384002 Merge upstream/staging into fix(ltm)/7044-recall-history-only
  • be36665 style(test): format prompt regression fixture (#7044)
  • c02c4b5 test(ltm): streamline recall handoff regression coverage (#7044)
  • 05290fc Merge remote-tracking branch 'upstream/staging' into fix(ltm)/7044-recall-history-only
  • fe681c7 test(ltm): remove LTM-specific route regression from Engine (#7044)
  • b006025 Merge remote-tracking branch 'upstream/staging' into fix(ltm)/7044-recall-history-only

📊 Changes

5 files changed (+175 additions, -19 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 packages/server/src/routes/generate.routes.ts (+6 -1)
📝 packages/server/src/routes/generate/conversation-history-runtime.ts (+28 -11)
📝 packages/server/src/services/generation/prompt-message-scope.ts (+13 -0)
📝 scripts/regressions/prompt.regression.ts (+126 -7)

📄 Description

Linked issue

Closes #7044

Why this change

Marinara Engine sent the fully assembled prompt — preset sections, agent
injections and other non-history text — to Long-Term Memory as recall input.
The package takes the last configured number of supplied messages as its query
window, so tail injections could enter the query and displace recent
conversation turns, adding or displacing recalled memories unrelated to the
actual conversation.

What changed

  • Added selectHistoryMessagesForRecall, which filters by contextKind === "history" instead of by role, so legitimate narrator/system history is kept while prompt and injection text is excluded.
  • The LTM handoff now passes that history-only selection, still after the existing Advanced Memory history filtering.
  • Conversation mode builds a detached recall copy of history (including summarized-day tail turns, excluding synthesized summaries) without changing the normal prompt's metadata.
  • Engine-side regression coverage is limited to the prompt-scope history selector and the Conversation recall-copy provenance (metadata preservation, summary exclusion, history retention, wrap format). LTM package behavior is out of Engine scope.

Other agents' inputs, query-window settings and the final provider prompt 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

Manual verification notes

  • Not yet performed by a human in a real browser. Engine handoff was exercised
    at the route level with a stubbed capability runtime and a fake provider. The
    activated Agents package query was not captured locally.

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)

UI evidence (if applicable)

  • None; no user-facing UI change.

Summary by CodeRabbit

  • Bug Fixes
    • Long-Term Memory recall now uses conversation history only, excluding preset prompts, agent injections, and other non-history text. Normal generation prompts and other agents’ inputs remain unchanged.
    • Recall history is prepared only when Long-Term Memory is active and the request is not a regeneration.
  • Tests
    • Added regression coverage for history selection, prompt preservation, and memory filtering.

🔄 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/7050 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/4/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(ltm)/7044-recall-history-only` --- ### 📝 Commits (7) - [`c44e1e0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c44e1e0b6120e00d9975e909afcd9c90cea3cadf) fix(ltm): limit recall input to conversation history (#7044) - [`f384002`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f384002fc97ed21d0251a5347768fde175eb59b2) Merge upstream/staging into fix(ltm)/7044-recall-history-only - [`be36665`](https://github.com/Pasta-Devs/Marinara-Engine/commit/be36665372677f8d1eb2d02251830dee682e36f4) style(test): format prompt regression fixture (#7044) - [`c02c4b5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c02c4b572c66e68effd40cd01f9d56d27397fb57) test(ltm): streamline recall handoff regression coverage (#7044) - [`05290fc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/05290fc5fb57caba0210b9237d7ec2cf411062b7) Merge remote-tracking branch 'upstream/staging' into fix(ltm)/7044-recall-history-only - [`fe681c7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fe681c7998fb6b031cdf417798139dee2dc91bc7) test(ltm): remove LTM-specific route regression from Engine (#7044) - [`b006025`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b006025495e5b2413a8825a3587e33a31102d61c) Merge remote-tracking branch 'upstream/staging' into fix(ltm)/7044-recall-history-only ### 📊 Changes **5 files changed** (+175 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+6 -1) 📝 `packages/server/src/routes/generate/conversation-history-runtime.ts` (+28 -11) 📝 `packages/server/src/services/generation/prompt-message-scope.ts` (+13 -0) 📝 `scripts/regressions/prompt.regression.ts` (+126 -7) </details> ### 📄 Description ## Linked issue Closes #7044 ## Why this change Marinara Engine sent the fully assembled prompt — preset sections, agent injections and other non-history text — to Long-Term Memory as recall input. The package takes the last configured number of supplied messages as its query window, so tail injections could enter the query and displace recent conversation turns, adding or displacing recalled memories unrelated to the actual conversation. ## What changed - Added `selectHistoryMessagesForRecall`, which filters by `contextKind === "history"` instead of by role, so legitimate narrator/system history is kept while prompt and injection text is excluded. - The LTM handoff now passes that history-only selection, still after the existing Advanced Memory history filtering. - Conversation mode builds a detached recall copy of history (including summarized-day tail turns, excluding synthesized summaries) without changing the normal prompt's metadata. - Engine-side regression coverage is limited to the prompt-scope history selector and the Conversation recall-copy provenance (metadata preservation, summary exclusion, history retention, wrap format). LTM package behavior is out of Engine scope. Other agents' inputs, query-window settings and the final provider prompt 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` ### Manual verification notes - Not yet performed by a human in a real browser. Engine handoff was exercised at the route level with a stubbed capability runtime and a fake provider. The activated Agents package query was not captured locally. ## 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) ## UI evidence (if applicable) - None; no user-facing UI change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Long-Term Memory recall now uses conversation history only, excluding preset prompts, agent injections, and other non-history text. Normal generation prompts and other agents’ inputs remain unchanged. * Recall history is prepared only when Long-Term Memory is active and the request is not a regeneration. * **Tests** * Added regression coverage for history selection, prompt preservation, and memory filtering. <!-- 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-23 04:19:53 +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#7446
No description provided.