[PR #5198] [MERGED] Fix Roleplay summary fallback and Tracker lorebook context #6670

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

📋 Pull Request Information

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

Base: staging ← Head: fix/5196-5197-roleplay-context


📝 Commits (7)

  • f9f8015 fix(roleplay): preserve summary and gate tracker lorebooks
  • fc8e043 fix(localization): sort tracker lorebook labels
  • ec59cc5 fix(agents): normalize retry chat mode type
  • 0461f2a refactor(agents): reuse tracker batch context key
  • 0b5a92f fix(agents): withhold semantic lorebook context
  • 2b534cd fix(agents): tolerate legacy vector context
  • 26648d9 fix(agents): isolate automatic batch contexts

📊 Changes

11 files changed (+309 additions, -30 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+26 -12)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/routes/generate.routes.ts (+37 -5)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+22 -3)
📝 packages/server/src/services/agents/agent-pipeline.ts (+7 -8)
➕ packages/server/src/services/generation/tracker-agent-context.ts (+41 -0)
📝 packages/server/src/services/prompt/assembler.ts (+1 -1)
📝 packages/server/src/services/prompt/index.ts (+1 -0)
📝 packages/shared/src/types/chat.ts (+2 -0)
📝 scripts/regressions/prompt.regression.ts (+168 -1)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote the repository staging branch or a same-repository hotfix/* branch to main.

Linked issue

Closes #5196
Closes #5197

Why this change

  • Preset-less Roleplay generation bypassed the prompt assembler summary fallback, so an active summary could disappear from the model context.
  • Tracker prompts received main-generation lorebook matches unconditionally, with no per-chat control, and Tracker-only scheduling controls appeared before a Tracker was attached.

What changed

  • Reuses the existing Chat Summary fallback for preset-less Roleplay prompts while preserving explicit preset-marker placement.
  • Adds an opt-in Attach Lorebooks to Trackers Roleplay setting, off by default.
  • Applies the setting to automatic post-processing and manual Tracker retries using the lorebook activation snapshot stored on the main response.
  • Separates Tracker batches from non-Tracker batches when their context policies differ.
  • Keeps Author Notes attached to Tracker prompts and leaves non-Tracker agent context unchanged.
  • Hides Manual Trackers, the lorebook toggle, and the individual schedule until an active Tracker is attached.
  • Adds focused prompt/context regressions and changelog entries.

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

  • pnpm check passes locally: Impeccable context guard, localization, Prettier, ESLint/TypeScript, server build, and client production build.
  • pnpm regression:prompt passes, including preset-less summary placement, Tracker lorebook opt-in/off behavior, Author Notes preservation, retry routing, and conditional UI wiring.
  • The in-app browser surface was unavailable in this session, so no click-through or screenshot is claimed. Manually verify the three Tracker controls appear only after attaching a Tracker and that the new toggle persists per chat.

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)

Not captured because the in-app browser surface was unavailable.

Summary by CodeRabbit

  • New Features

    • Added an optional setting to include activated Lorebook entries in Roleplay Tracker prompts.
    • Tracker controls now appear only when relevant agents and tracking features are active.
    • Roleplay summaries are automatically included when no prompt preset or summary marker is selected.
  • Bug Fixes

    • Improved fallback placement of active Roleplay summaries before conversation history.
    • Ensured Tracker processing and retries consistently respect Lorebook preferences and context separation.
  • Tests

    • Added regression coverage for summaries, Lorebook handling, settings, retries, and context consistency.

🔄 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/5198 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/17/2026 **Status:** ✅ Merged **Merged:** 8/17/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/5196-5197-roleplay-context` --- ### 📝 Commits (7) - [`f9f8015`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f9f8015931dd208b7203687fbc63f99fd974a190) fix(roleplay): preserve summary and gate tracker lorebooks - [`fc8e043`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fc8e043fb6600588f2b8c263b3ac07ebfbf6b76f) fix(localization): sort tracker lorebook labels - [`ec59cc5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ec59cc51642130b6ece8ef9bf7b82487bce5d5ca) fix(agents): normalize retry chat mode type - [`0461f2a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0461f2a043588d022d96ab146eec4d72898935e7) refactor(agents): reuse tracker batch context key - [`0b5a92f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0b5a92f6db2d4dadd3d629bf79d2592608b8f9d5) fix(agents): withhold semantic lorebook context - [`2b534cd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2b534cd830499e2816d2745ca4b4203075e33c21) fix(agents): tolerate legacy vector context - [`26648d9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/26648d920ef0fb836d1eff1ab8386d0af0f73283) fix(agents): isolate automatic batch contexts ### 📊 Changes **11 files changed** (+309 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+26 -12) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+37 -5) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+22 -3) 📝 `packages/server/src/services/agents/agent-pipeline.ts` (+7 -8) ➕ `packages/server/src/services/generation/tracker-agent-context.ts` (+41 -0) 📝 `packages/server/src/services/prompt/assembler.ts` (+1 -1) 📝 `packages/server/src/services/prompt/index.ts` (+1 -0) 📝 `packages/shared/src/types/chat.ts` (+2 -0) 📝 `scripts/regressions/prompt.regression.ts` (+168 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote the repository `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Closes #5196 Closes #5197 ## Why this change - Preset-less Roleplay generation bypassed the prompt assembler summary fallback, so an active summary could disappear from the model context. - Tracker prompts received main-generation lorebook matches unconditionally, with no per-chat control, and Tracker-only scheduling controls appeared before a Tracker was attached. ## What changed - Reuses the existing Chat Summary fallback for preset-less Roleplay prompts while preserving explicit preset-marker placement. - Adds an opt-in **Attach Lorebooks to Trackers** Roleplay setting, off by default. - Applies the setting to automatic post-processing and manual Tracker retries using the lorebook activation snapshot stored on the main response. - Separates Tracker batches from non-Tracker batches when their context policies differ. - Keeps Author Notes attached to Tracker prompts and leaves non-Tracker agent context unchanged. - Hides Manual Trackers, the lorebook toggle, and the individual schedule until an active Tracker is attached. - Adds focused prompt/context regressions and changelog entries. ## 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 - `pnpm check` passes locally: Impeccable context guard, localization, Prettier, ESLint/TypeScript, server build, and client production build. - `pnpm regression:prompt` passes, including preset-less summary placement, Tracker lorebook opt-in/off behavior, Author Notes preservation, retry routing, and conditional UI wiring. - The in-app browser surface was unavailable in this session, so no click-through or screenshot is claimed. Manually verify the three Tracker controls appear only after attaching a Tracker and that the new toggle persists per chat. ## 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) Not captured because the in-app browser surface was unavailable. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added an optional setting to include activated Lorebook entries in Roleplay Tracker prompts. * Tracker controls now appear only when relevant agents and tracking features are active. * Roleplay summaries are automatically included when no prompt preset or summary marker is selected. * **Bug Fixes** * Improved fallback placement of active Roleplay summaries before conversation history. * Ensured Tracker processing and retries consistently respect Lorebook preferences and context separation. * **Tests** * Added regression coverage for summaries, Lorebook handling, settings, retries, and context consistency. <!-- 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:12:35 +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#6670
No description provided.