[PR #5193] [MERGED] Add Read Behind to custom lorebook agents #6667

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

📋 Pull Request Information

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

Base: staging ← Head: fix/5191-custom-agent-read-behind


📝 Commits (5)

  • d41fd84 chore: coordinate issue 5191
  • 0ff469d fix: add read behind to custom lorebook agents
  • 26f287a fix: harden lorebook read-behind scheduling
  • 41ec522 Merge remote-tracking branch 'origin/staging' into fix/5191-custom-agent-read-behind
  • a542c43 fix: preserve read-behind result ownership

📊 Changes

13 files changed (+450 additions, -81 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/agents/AgentEditor.tsx (+73 -3)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+4 -4)
📝 packages/client/src/localization/locales/en.json (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+74 -17)
📝 packages/server/src/routes/generate/lorebook-keeper-utils.ts (+43 -4)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+54 -8)
📝 packages/server/src/services/agents/agent-pipeline.ts (+6 -0)
📝 packages/server/src/services/generation/agent-event-dispatcher.ts (+2 -2)
📝 packages/server/src/services/storage/agents.storage.ts (+17 -0)
📝 scripts/regressions/assigned-issue-sweep.regression.ts (+6 -1)
📝 scripts/regressions/manual-agent-retry-resolution.regression.ts (+20 -2)
📝 scripts/regressions/open-issues.regression.ts (+149 -40)

📄 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 #5191

Why this change

  • Custom lorebook-capable agents cannot currently skip the newest messages, so swipes and regenerations can make them process the same turn repeatedly.
  • The Backfill Unprocessed action can overflow its mobile container instead of wrapping to a stable second row.

What changed

  • Added a bounded Read Behind control to the custom-agent Lorebook Writer section and preserved it through save/export.
  • Shifted automatic and manual custom lorebook-agent calls to the selected historical assistant reply, with their run records anchored to that reply.
  • Prevented duplicate delayed runs after swipes by checking persisted successes and guarding the same target while a prior run is still active.
  • Kept agents with different delayed contexts out of the same LLM batch.
  • Stacked Lorebook Keeper actions inside their settings card at mobile widths so Backfill Unprocessed cannot overflow.
  • Added focused regression coverage and an Unreleased changelog entry.

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

  • The in-app browser surface was unavailable in this environment. The responsive class contract is covered by the focused regression and the production client bundle compiled successfully.
  • Manually verify the custom-agent editor's enabled/disabled Read Behind control and the Lorebook Keeper action stack at a phone viewport.

Automated verification performed

  • scripts/regressions/open-issues.regression.ts
  • Localization audit
  • Prettier check
  • Workspace lint/typecheck
  • Shared, server, and production client builds (run separately with matching local native build binaries)

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: the in-app browser surface was unavailable during this run.

Summary by CodeRabbit

  • New Features

    • Custom lorebook-writing agents can look back through previous messages when processing replies.
    • Read-behind settings are validated, saved, and included when exporting agent configurations.
    • Delayed processing can attach results to the relevant historical reply.
  • Bug Fixes

    • Prevented duplicate processing after message swipes or retries.
    • Improved reliability when handling delayed lorebook updates.
  • Style

    • Updated Lorebook Keeper controls for a more usable mobile layout.

🔄 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/5193 **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/5191-custom-agent-read-behind` --- ### 📝 Commits (5) - [`d41fd84`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d41fd84bf32a39baf44c71b890aec9f70e83f230) chore: coordinate issue 5191 - [`0ff469d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0ff469d26f9fff9a878cca0889010d708e4265fc) fix: add read behind to custom lorebook agents - [`26f287a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/26f287a74557b963cc0b56ef1473e5f0504027b9) fix: harden lorebook read-behind scheduling - [`41ec522`](https://github.com/Pasta-Devs/Marinara-Engine/commit/41ec5220ff0bff84f74e00050729b175292c8357) Merge remote-tracking branch 'origin/staging' into fix/5191-custom-agent-read-behind - [`a542c43`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a542c43318f0e46c862e8c2fac60574b65d2d8fb) fix: preserve read-behind result ownership ### 📊 Changes **13 files changed** (+450 additions, -81 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+73 -3) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+4 -4) 📝 `packages/client/src/localization/locales/en.json` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+74 -17) 📝 `packages/server/src/routes/generate/lorebook-keeper-utils.ts` (+43 -4) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+54 -8) 📝 `packages/server/src/services/agents/agent-pipeline.ts` (+6 -0) 📝 `packages/server/src/services/generation/agent-event-dispatcher.ts` (+2 -2) 📝 `packages/server/src/services/storage/agents.storage.ts` (+17 -0) 📝 `scripts/regressions/assigned-issue-sweep.regression.ts` (+6 -1) 📝 `scripts/regressions/manual-agent-retry-resolution.regression.ts` (+20 -2) 📝 `scripts/regressions/open-issues.regression.ts` (+149 -40) </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`. ## Linked issue Closes #5191 ## Why this change - Custom lorebook-capable agents cannot currently skip the newest messages, so swipes and regenerations can make them process the same turn repeatedly. - The Backfill Unprocessed action can overflow its mobile container instead of wrapping to a stable second row. ## What changed - Added a bounded **Read Behind** control to the custom-agent Lorebook Writer section and preserved it through save/export. - Shifted automatic and manual custom lorebook-agent calls to the selected historical assistant reply, with their run records anchored to that reply. - Prevented duplicate delayed runs after swipes by checking persisted successes and guarding the same target while a prior run is still active. - Kept agents with different delayed contexts out of the same LLM batch. - Stacked Lorebook Keeper actions inside their settings card at mobile widths so **Backfill Unprocessed** cannot overflow. - Added focused regression coverage and an Unreleased changelog entry. ## 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 - The in-app browser surface was unavailable in this environment. The responsive class contract is covered by the focused regression and the production client bundle compiled successfully. - Manually verify the custom-agent editor's enabled/disabled Read Behind control and the Lorebook Keeper action stack at a phone viewport. ### Automated verification performed - `scripts/regressions/open-issues.regression.ts` - Localization audit - Prettier check - Workspace lint/typecheck - Shared, server, and production client builds (run separately with matching local native build binaries) ## 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: the in-app browser surface was unavailable during this run. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Custom lorebook-writing agents can look back through previous messages when processing replies. - Read-behind settings are validated, saved, and included when exporting agent configurations. - Delayed processing can attach results to the relevant historical reply. - **Bug Fixes** - Prevented duplicate processing after message swipes or retries. - Improved reliability when handling delayed lorebook updates. - **Style** - Updated Lorebook Keeper controls for a more usable mobile layout. <!-- 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:34 +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#6667
No description provided.