[PR #8153] [MERGED] feat(agents): attach lorebooks per chat and agent #8131

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

📋 Pull Request Information

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

Base: staging ← Head: feat/chat-agent-lorebook-attachments


📝 Commits (10+)

  • 3a712c9 feat(agents): define per-chat lorebook attachments
  • c0fe8a3 feat: attach chat-scoped lorebooks to individual agents
  • de0f1e0 Merge remote-tracking branch 'origin/staging' into feat/chat-agent-lorebook-attachments
  • 46faa1a feat: expose scoped lorebook references to package agents
  • c3e042e test: cover package compatibility and prove negative agent cases execute
  • 2740c81 fix: include saved generation guides in package reference scans
  • 26d3b54 fix: keep agent lorebook attachments out of chat profiles
  • 2cf7306 fix: preserve valid agent lorebook selections and setup defaults
  • a96c341 fix(agents): reset wizard attachments through valid merged entries
  • 29db298 fix(agents): bound package history before evaluating macros

📊 Changes

44 files changed (+4577 additions, -89 deletions)

View changed files

📝 docs/agents/agents-overview.md (+10 -0)
➕ e2e/agent-lorebook-attachment.e2e.ts (+137 -0)
➕ e2e/agent-lorebook-concurrent-fields.e2e.ts (+131 -0)
➕ e2e/agent-lorebook-game-session.e2e.ts (+204 -0)
➕ e2e/agent-lorebook-package-compatibility.e2e.ts (+141 -0)
➕ e2e/agent-lorebook-save-errors.e2e.ts (+169 -0)
➕ e2e/agent-lorebook-state-boundaries.e2e.ts (+186 -0)
➕ e2e/agent-lorebook-wizard-defaults.e2e.ts (+176 -0)
➕ packages/client/src/components/chat/AgentLorebookAttachment.tsx (+73 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+41 -0)
📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+7 -2)
📝 packages/client/src/hooks/use-chats.ts (+12 -1)
📝 packages/client/src/lib/chat-wizard-defaults.ts (+28 -2)
📝 packages/client/src/localization/locales/en.json (+10 -0)
📝 packages/server/src/routes/chats.routes.ts (+27 -3)
📝 packages/server/src/routes/generate.routes.ts (+28 -10)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+219 -52)
📝 packages/server/src/services/agents/agent-executor.ts (+28 -3)
➕ packages/server/src/services/capability-packages/capability-agent-lorebook.service.ts (+209 -0)
📝 packages/server/src/services/capability-packages/capability-module-runtime.service.ts (+11 -0)

...and 24 more files

📄 Description

Final fetched-head review and source-based disposition

The genuine final-head Dottore FULL examination 40004990805 completed on aea876c470277331009750a9c4f7e5c16295ef88. Its actual result is Repair Required: 5 findings and 2 notes. All five reports were checked against the current supported flow and rejected for the specific source/proof reasons below; this PR does not claim that Dottore reported zero findings or that the local review warning disappeared. No bot marker, repair contract, workflow or commit status was rewritten.

Report Source-based disposition and evidence
Retry legacy intent, 4363206623 Actual normal group generation and genuine Continue become indistinguishable after trusted provenance is stripped; promoting older input breaks the real Continue. The documented conservative fallback is deliberate. Fresh exact-head 34-call replay and source hashes.
Package legacy intent, 4363206643 Same concrete ambiguity; current writes retain trusted snapshots. The additionally alleged replay regeneration field does not exist in the replay builder/normalizer. Active-swipe/system-tail controls pass in the linked replay.
Retry merged source seeding, 4363206634 The context scanner receives original agents before execution merges them. Twelve actual normal/post/historical-pre routes explicitly cover an unattached base with an attached sibling, all distinct books, one call and per-entry deduplication. Exact current test sources, fresh results and call-order proof.
Merged settings, 4363206649 Duplicate of the same disproven seeding premise: original per-id maps already exist when the merged executor unions them. The same real-route and executor controls pass.
Cold detail/unparseable metadata, 4363206656 The real parent and overlay require a loaded chat from the same detail-query key; a held cold GET mounts no control and sends no PATCH. Warm503 keeps cached enabled/book state. Valid raw Game JSON is parsed; truly unreadable metadata is normalized by the server, so no intact hidden binding was demonstrated. Exact current maintained cold/warm controls and final 36-case proof.

All 8 required checks pass on the exact head; hosted Node regressions pass 1,064/1,064 and platform jobs pass 10/10. Final source-based replies and thread resolution are recorded individually. The merge preflight preserves every tested field-repair source hash and the English overview bytes alongside separately reviewed upstream #8007. Local validation and its CodeRabbit warning remain scoped below. The repeated full-review cycle stops here; future follow-up pushes remain ready and use ordinary incremental review.

Current independent-field repair and proof

Candidate aea876c470277331009750a9c4f7e5c16295ef88 repairs the supported same-agent counterwriter cases from the dependent audio review. Two actual unchanged-source browser failures show the problem: toggling an attachment restores the old rendered book after another HTTP writer selected a newer one; choosing a book re-enables an attachment another writer disabled. The separate cold-detail mounting allegation retains its existing proof boundary.

Each control now sends only the field the user changed. A strict, non-empty partial-entry PATCH schema accepts that request while the complete stored/snapshot schema remains unchanged. The server merges those fields against fresh metadata inside the existing storage queue, retaining unrelated agent entries. Explicit null still clears a book; new entries receive complete safe defaults; full-entry clients and wizard resets still set both fields. The optimistic cache uses the same pure merge without changing the sparse wire variables. Edits to the same field retain queued write order.

Current source, runnable regressions, original failures, final results and review qualification contains 24 raw files verified byte-for-byte. Local full pnpm check, 36 focused browser cases, 15 unique canonical regression files, 7 full-server source smokes and 3 freshly compiled startup/reload cases pass. Browser cases cover dark/light desktop Chromium, mobile Chromium and mobile WebKit: 12 independent-field cases, 12 real reused/carried Game sessions, 6 save-failure/queue controls and 6 cold/warm/wire controls. These use isolated HTTP/storage fixtures and an inert agent manifest; no physical-device, full-package or paid-provider validation is claimed. Compiled startup used a Lite backend fixture. An initial source-smoke Lite/full fixture mismatch produced /api/sidecar/status404; its original and unchanged-replay failures are retained. Only the disposable starter changed to explicit full mode; all 7 source smokes then passed with source/assertions unchanged.

Local review qualification: the fresh nine-file CodeRabbit examination completed with 0 confirmed findings, but reports completed_with_warnings / “Review completed with unverified findings.” No warning candidate details or new comments were persisted; this is not claimed as an unqualified clean review. The same-scope findings command surfaces an older, separately repaired historical-backfill record, identified by its distinct stored review. Nothing was cleared or relabeled. Independent review of all four production files found no defect. The final-head hosted review, required checks and source-based dispositions are recorded separately below.

Capability API 1.380, storage layout and the overview's 803b51ba… English bytes are unchanged by this field repair. #8155 aligns all ten overview translations; its publication still waits for the actual English merge. No review status or bot contract is overridden.

Previous legacy disposition and documentation (087)

The preceding 087dbba301925b7b98bf0b5797b2257c49ae9b09 added one accurate user-facing limitation paragraph and integrated the separately reviewed scene-video wording from actual staging e6b1ac67. That documentation-only head retained every runtime, regression and workflow byte from 03f0d47f4. The one-file English documentation review completed with zero findings. Ten overview translations are aligned separately in #8155; publication waits for the English merge.

The two 03f reports concern missing or stripped legacy intent. A fresh actual-route counterexample runs normal user → A → B generation and a real no-input Continue of B. Trusted saved snapshots correctly distinguish chat from continue/autonomous. Removing only B's saved intent gives both states identical consumed fallback inputs, including the same older user inside Context Size 8, adjacent assistant, null replay and active swipe 0. The real retry endpoint in both phases and the package service then use the established conservative fallback; older input remains macro context. Promoting that older input would misclassify the genuine Continue as chat. All 34 actual retry calls pass. Completed current Engine generation writes trusted intent on every assistant, group reply, split part and swipe. Older/imported messages can lack that information; this PR does not promise perfect retrospective reconstruction.

The package report's swipe premise does not match current source: lastTurn and priorTurn only accept visible user/assistant rows. A system/narrator tail cannot replace the eligible assistant, and fresh service replay preserves both derivable legacy chat and active-swipe intent across those tails. Two independent read-only audits agree. The repeated merged proof gap is also disproven by a fresh run of the maintained 12 actual normal/post/historical-pre routes, including an unattached base with an attached sibling and real stored keyword entries. No production trigger or grouping change is justified by these reports.

Fresh 34-call counterexample, scripts, exact unchanged-source hashes, independent audits, package/swipe/system and merged-route replays, doc delta and review contains 17 raw files verified byte-for-byte. The earlier 51-file repair/integration proof retains its exact revision scope. On the identical 03f runtime, hosted 1,063/1,063 Node files and 10/10 platform jobs pass, alongside the local full check, 14 focused Node files, 18 focused UI cases, 7 source smokes and 3 compiled-startup cases proof below. Its pnpm smoke setup hit an Ubuntu mirror download timeout before assertions; the unchanged retry passed. The later documentation-only 087 completed all eight required checks and an actual incremental Viable With Notes review (0 defects, 1 note). Those historical results retain their exact scope; the new runtime repair above requires its own hosted checks and actual review.

Earlier target/history and Game-session repair

The two actual a97 Dottore findings are valid and repaired in 03f0d47f4d7da7f6b592e543e0913ff05ecb9c5f (repair e3e2f5bc33, integrated actual staging 611a1200c). Manual retry now uses its selected target’s own saved canonical generation intent. The shared validator accepts only the same four complete shapes already supported by package resolution; invalid, cross-mode and old messages retain their established fallback. The final selected custom-backfill target is chosen before deriving intent.

Historical reference context is rebuilt for the actual target in custom backfill, custom read-behind and Lorebook Keeper, using the existing context builder with that target’s raw history, active swipe, input macros, character scope and game anchor. Only its resolved reference map is copied into the established historical agent context; tools, effects and memory remain. Returned macro variables are not persisted again. Unattached agents and an already-selected target skip the extra preparation. This adds bounded context/scanner preparation for genuinely historical reference-enabled calls, with no additional agent model request.

The maintained real Fastify/storage/model-stub regressions cover 30 pre/post retry requests, all three historical execution variants and an unattached control. They assert both included and excluded entries, distinct old/new keywords and input macros, speaker isolation and one agent request. Exact a97 fails read-behind/Keeper historical context; the snapshot-only intermediate repair also fails final backfill intent. Both negative controls are retained separately. Normal grouped generation, true Continue, guide/system tails, original/regenerated swipe, impersonation, bounded keyword/semantic windows, merged rewrite routes and additive legacy sources remain covered.

The client finding is a supported Game session cache boundary: real reused/carried /game/session/start responses contain storage-encoded metadata, and useStartSession caches that response. The attachment control now uses existing readChatMetadata. Its maintained UI regression drives real session creation/reuse with an eligible World Maps tracker and a selected prompt preset, holds later detail GETs, asserts the actual raw cached string and verifies the toggle’s PATCH and stored selected book. The unchanged component fails both before cases. 12 dark/light desktop/mobile Chromium/WebKit cases and six existing cold/warm/wire controls pass. These use an inert package registry fixture, not the full Maps runtime or physical devices.

Final runnable controls, original failures, exact hashes and review logs contains the maintained regressions, negative controls, exact source hashes and current validation/review logs. All 51 raw files match local bytes. Final pnpm check, 14 focused canonical Node files, seven shell smokes and three compiled-startup cases pass on this repair. The seven-file repair review and final one-file integration review both completed zero findings; the earlier intermediate review’s one valid final-backfill finding was repaired. The E2E-only generic-call type error and runtime-equivalent result-assertion correction are recorded separately, with final fullcheck passing. Earlier review results remain scoped to their original heads. Capability API 1.380 and English overview bytes are unchanged. Hosted checks, the actual fetched-head review and zero unresolved threads remain merge gates; source-based finding dispositions retain the actual reported counts. The sole actual-staging conflict preserves upstream illustratorStillOnly in the factored retry context arguments; independent source review and actual Roleplay-video/GM/provider controls pass.

Why this change

An agent needs its own extra reference lorebook in a chat, without exposing it to the main reply, unrelated agents or other chats. Closes #8145 and addresses the attachment portion of #8148; its creation notice already landed in #8150. Owner: @SpicyMarinara (Codex).

What changed

  • Add a default-off attachment toggle and one-book dropdown to eligible writing, tracking and custom-agent menus. Save per-chat bindings, preserve independent per-agent and per-field edits, and show localized save errors while preserving queued saves.
  • Reuse normal triggers, budgets, macros and character visibility in normal generation, manual/historical retries and grouped agents. Existing custom-agent lorebook sources remain additive.
  • Expose permission-checked, cancellable package-bound API 1.380 resolution. World Maps has equivalent Roleplay/Game controls and update guidance for older installed packages; global templates remain outside chat attachments.
  • Keep ordinary reusable wizard defaults free of chat-owned bindings at both Save and Apply, including legacy templates. Full initial/profile snapshots and same-chat Reset retain schema-valid bindings without deleting unrelated concurrently added agents.
  • Retain trusted generation intent on new assistant rows, split parts and swipes; portable import/export strips it. Preserve bounded history slots and supplemental guide semantics without copying or macro-resolving whole transcripts.
  • Document the behavior and add canonical English UI copy. Ten-pack publication #8155 waits for this English source to merge.

Established behavior and review boundaries

Merged agents resolve original per-agent sources before merging. The executor unions/deduplicates those already-resolved entries. Twelve actual normal/post/historical-pre routes and the original real-route proof cover unattached base/attached sibling, only base, all distinct books, unmatched/unrelated exclusions and one combined provider call. No group production repair was necessary.

Old group intent cannot be reconstructed universally after provenance is removed. Actual ordinary user → A → B and true no-input continuation can leave indistinguishable legacy rows. Arbitrary older input remains macro context, not proof of a new turn. The conservative legacy fallback is deliberate; derivable chat/swipe intent survives narrator/system tails. The earlier cold Conversation query and optimistic-copy allegations were disproven by six actual boundary controls. The newly reproduced raw Game-session writer is a separate supported path and is fixed above.

Published Maps package 1.7.1/API 1.380 compatibility is already merged in Pasta-Devs/Marinara-Agents#1614; exact ZIP/catalog bytes were verified. This Engine host remains its delivery dependency. Combat-style API 1.379 is preserved; audio API 1.381 belongs to dependent #8167.

Earlier bounded-window/name proof, window/guide repair, wizard reset, reusable-default and generation-intent proof, save-error/legacy-tail proof and roster controls retain their exact tested-head scope. Earlier upstream findings were tracked separately; they are not folded into this reference feature or called zero findings. No release version or CHANGELOG changes.

Manual verification

  • Manually verify two agents/chats, grouping, ordinary generation and historical retries.
  • Manually verify physical phones, deleted/disabled books and updating Engine and Maps together.

Browser emulation and local model fixtures are distinct from physical-device and paid-provider validation. The existing unrelated Professor hook warning is recorded. No queued/pending hosted result is claimed as passed.

UI evidence

Published desktop/mobile dark/light and World Maps gallery. Its HTML/embedded PNGs are byte-verified. Current Game-session metadata screenshots and their qualified visual limits are included in the current repair proof.


🔄 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/8153 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/chat-agent-lorebook-attachments` --- ### 📝 Commits (10+) - [`3a712c9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3a712c943b3950ad2b5894643d68c94fc41ac29a) feat(agents): define per-chat lorebook attachments - [`c0fe8a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c0fe8a3e2d15ebf6a731d207a88b281533c21574) feat: attach chat-scoped lorebooks to individual agents - [`de0f1e0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/de0f1e0a07c30afe0f79c726116dcab09e1ac5af) Merge remote-tracking branch 'origin/staging' into feat/chat-agent-lorebook-attachments - [`46faa1a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/46faa1ad32a945054a94b88971349908151b773b) feat: expose scoped lorebook references to package agents - [`c3e042e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c3e042eafc530b111371a64e7ba01a43b17231e1) test: cover package compatibility and prove negative agent cases execute - [`2740c81`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2740c81e92b6d86bb57ec40d9090d92fad1ce722) fix: include saved generation guides in package reference scans - [`26d3b54`](https://github.com/Pasta-Devs/Marinara-Engine/commit/26d3b545fb7d3f90a12297753b2f25e725b54272) fix: keep agent lorebook attachments out of chat profiles - [`2cf7306`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2cf73066dab3c515a4ccd902cbc54c5818b252ff) fix: preserve valid agent lorebook selections and setup defaults - [`a96c341`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a96c341151590266c7011179f033069b4c4aac0d) fix(agents): reset wizard attachments through valid merged entries - [`29db298`](https://github.com/Pasta-Devs/Marinara-Engine/commit/29db2988ca8c76f4d79a97630b86f9dd9cfffd9b) fix(agents): bound package history before evaluating macros ### 📊 Changes **44 files changed** (+4577 additions, -89 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/agents-overview.md` (+10 -0) ➕ `e2e/agent-lorebook-attachment.e2e.ts` (+137 -0) ➕ `e2e/agent-lorebook-concurrent-fields.e2e.ts` (+131 -0) ➕ `e2e/agent-lorebook-game-session.e2e.ts` (+204 -0) ➕ `e2e/agent-lorebook-package-compatibility.e2e.ts` (+141 -0) ➕ `e2e/agent-lorebook-save-errors.e2e.ts` (+169 -0) ➕ `e2e/agent-lorebook-state-boundaries.e2e.ts` (+186 -0) ➕ `e2e/agent-lorebook-wizard-defaults.e2e.ts` (+176 -0) ➕ `packages/client/src/components/chat/AgentLorebookAttachment.tsx` (+73 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+41 -0) 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+7 -2) 📝 `packages/client/src/hooks/use-chats.ts` (+12 -1) 📝 `packages/client/src/lib/chat-wizard-defaults.ts` (+28 -2) 📝 `packages/client/src/localization/locales/en.json` (+10 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+27 -3) 📝 `packages/server/src/routes/generate.routes.ts` (+28 -10) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+219 -52) 📝 `packages/server/src/services/agents/agent-executor.ts` (+28 -3) ➕ `packages/server/src/services/capability-packages/capability-agent-lorebook.service.ts` (+209 -0) 📝 `packages/server/src/services/capability-packages/capability-module-runtime.service.ts` (+11 -0) _...and 24 more files_ </details> ### 📄 Description ## Final fetched-head review and source-based disposition The genuine final-head Dottore FULL examination [40004990805](https://github.com/Pasta-Devs/Marinara-Engine/actions/runs/40004990805) completed on **`aea876c470277331009750a9c4f7e5c16295ef88`**. Its actual result is **Repair Required: 5 findings and 2 notes**. All five reports were checked against the current supported flow and rejected for the specific source/proof reasons below; this PR does **not** claim that Dottore reported zero findings or that the local review warning disappeared. No bot marker, repair contract, workflow or commit status was rewritten. | Report | Source-based disposition and evidence | | --- | --- | | Retry legacy intent, 4363206623 | Actual normal group generation and genuine Continue become indistinguishable after trusted provenance is stripped; promoting older input breaks the real Continue. The documented conservative fallback is deliberate. [Fresh exact-head 34-call replay and source hashes](https://gist.github.com/SpicyMarinara/9735c1b628cbbd4a1bbbe999fda2694d). | | Package legacy intent, 4363206643 | Same concrete ambiguity; current writes retain trusted snapshots. The additionally alleged replay regeneration field does not exist in the replay builder/normalizer. Active-swipe/system-tail controls pass in the linked replay. | | Retry merged source seeding, 4363206634 | The context scanner receives original agents before execution merges them. Twelve actual normal/post/historical-pre routes explicitly cover an unattached base with an attached sibling, all distinct books, one call and per-entry deduplication. [Exact current test sources, fresh results and call-order proof](https://gist.github.com/SpicyMarinara/7ec49fedaa6e919bdf194c7803aff830). | | Merged settings, 4363206649 | Duplicate of the same disproven seeding premise: original per-id maps already exist when the merged executor unions them. The same real-route and executor controls pass. | | Cold detail/unparseable metadata, 4363206656 | The real parent and overlay require a loaded chat from the same detail-query key; a held cold GET mounts no control and sends no PATCH. Warm503 keeps cached enabled/book state. Valid raw Game JSON is parsed; truly unreadable metadata is normalized by the server, so no intact hidden binding was demonstrated. [Exact current maintained cold/warm controls](https://github.com/Pasta-Devs/Marinara-Engine/blob/aea876c470277331009750a9c4f7e5c16295ef88/e2e/agent-lorebook-state-boundaries.e2e.ts#L105) and [final 36-case proof](https://gist.github.com/SpicyMarinara/60d6711a6da5fc6810193132c2b41a45). | All **8 required checks pass** on the exact head; hosted Node regressions pass **1,064/1,064** and platform jobs pass **10/10**. Final source-based replies and thread resolution are recorded individually. The merge preflight preserves every tested field-repair source hash and the English overview bytes alongside separately reviewed upstream #8007. Local validation and its CodeRabbit warning remain scoped below. The repeated full-review cycle stops here; future follow-up pushes remain ready and use ordinary incremental review. ## Current independent-field repair and proof Candidate **`aea876c470277331009750a9c4f7e5c16295ef88`** repairs the supported same-agent counterwriter cases from [the dependent audio review](https://github.com/Pasta-Devs/Marinara-Engine/pull/8167#discussion_r4362866074). Two actual unchanged-source browser failures show the problem: toggling an attachment restores the old rendered book after another HTTP writer selected a newer one; choosing a book re-enables an attachment another writer disabled. The separate cold-detail mounting allegation retains its existing proof boundary. Each control now sends only the field the user changed. A strict, non-empty **partial-entry PATCH schema** accepts that request while the complete stored/snapshot schema remains unchanged. The server merges those fields against **fresh metadata inside the existing storage queue**, retaining unrelated agent entries. Explicit `null` still clears a book; new entries receive complete safe defaults; full-entry clients and wizard resets still set both fields. The optimistic cache uses the same pure merge without changing the sparse wire variables. Edits to the same field retain queued write order. [Current source, runnable regressions, original failures, final results and review qualification](https://gist.github.com/SpicyMarinara/60d6711a6da5fc6810193132c2b41a45) contains **24 raw files verified byte-for-byte**. Local full `pnpm check`, **36 focused browser cases**, **15 unique canonical regression files**, **7 full-server source smokes** and **3 freshly compiled startup/reload cases** pass. Browser cases cover dark/light desktop Chromium, mobile Chromium and mobile WebKit: 12 independent-field cases, 12 real reused/carried Game sessions, 6 save-failure/queue controls and 6 cold/warm/wire controls. These use isolated HTTP/storage fixtures and an inert agent manifest; no physical-device, full-package or paid-provider validation is claimed. Compiled startup used a Lite backend fixture. An initial source-smoke Lite/full fixture mismatch produced `/api/sidecar/status`404; its original and unchanged-replay failures are retained. Only the disposable starter changed to explicit full mode; all 7 source smokes then passed with source/assertions unchanged. **Local review qualification:** the fresh nine-file CodeRabbit examination completed with **0 confirmed findings**, but reports **`completed_with_warnings` / “Review completed with unverified findings.”** No warning candidate details or new comments were persisted; this is not claimed as an unqualified clean review. The same-scope findings command surfaces an older, separately repaired historical-backfill record, identified by its distinct stored review. Nothing was cleared or relabeled. Independent review of all four production files found no defect. The final-head hosted review, required checks and source-based dispositions are recorded separately below. Capability API **1.380**, storage layout and the overview's **`803b51ba…`** English bytes are unchanged by this field repair. #8155 aligns all ten overview translations; its publication still waits for the actual English merge. No review status or bot contract is overridden. ## Previous legacy disposition and documentation (`087`) The preceding **`087dbba301925b7b98bf0b5797b2257c49ae9b09`** added one accurate user-facing limitation paragraph and integrated the separately reviewed scene-video wording from actual staging `e6b1ac67`. **That documentation-only head retained every runtime, regression and workflow byte from `03f0d47f4`.** The one-file English documentation review completed with zero findings. Ten overview translations are aligned separately in #8155; publication waits for the English merge. The two `03f` reports concern **missing or stripped legacy intent**. A fresh actual-route counterexample runs normal `user → A → B` generation and a real no-input Continue of B. Trusted saved snapshots correctly distinguish `chat` from `continue/autonomous`. Removing only B's saved intent gives both states **identical consumed fallback inputs**, including the same older user inside Context Size 8, adjacent assistant, null replay and active swipe 0. The real retry endpoint in **both phases** and the package service then use the established conservative fallback; older input remains macro context. **Promoting that older input would misclassify the genuine Continue as chat.** All 34 actual retry calls pass. Completed current Engine generation writes trusted intent on every assistant, group reply, split part and swipe. Older/imported messages can lack that information; this PR does not promise perfect retrospective reconstruction. The package report's swipe premise does not match current source: **`lastTurn` and `priorTurn` only accept visible user/assistant rows**. A system/narrator tail cannot replace the eligible assistant, and fresh service replay preserves both derivable legacy chat and active-swipe intent across those tails. Two independent read-only audits agree. The repeated merged proof gap is also disproven by a fresh run of the maintained **12 actual normal/post/historical-pre routes**, including an unattached base with an attached sibling and real stored keyword entries. No production trigger or grouping change is justified by these reports. [Fresh 34-call counterexample, scripts, exact unchanged-source hashes, independent audits, package/swipe/system and merged-route replays, doc delta and review](https://gist.github.com/SpicyMarinara/c7fb643a8deed381cf9e70874742d79f) contains **17 raw files verified byte-for-byte**. The earlier [51-file repair/integration proof](https://gist.github.com/SpicyMarinara/3172356d40fc217fbd25ea4ff8632021) retains its exact revision scope. On the identical `03f` runtime, hosted **1,063/1,063 Node files and 10/10 platform jobs pass**, alongside the local full check, 14 focused Node files, 18 focused UI cases, 7 source smokes and 3 compiled-startup cases proof below. Its pnpm smoke setup hit an Ubuntu mirror download timeout before assertions; the unchanged retry passed. The later documentation-only `087` completed all eight required checks and an actual incremental Viable With Notes review (0 defects, 1 note). Those historical results retain their exact scope; the new runtime repair above requires its own hosted checks and actual review. ## Earlier target/history and Game-session repair The two actual `a97` Dottore findings are valid and repaired in `03f0d47f4d7da7f6b592e543e0913ff05ecb9c5f` (repair `e3e2f5bc33`, integrated actual staging `611a1200c`). Manual retry now uses its **selected target’s own saved canonical generation intent**. The shared validator accepts only the same four complete shapes already supported by package resolution; invalid, cross-mode and old messages retain their established fallback. The final selected custom-backfill target is chosen before deriving intent. Historical reference context is rebuilt for the actual target in **custom backfill, custom read-behind and Lorebook Keeper**, using the existing context builder with that target’s raw history, active swipe, input macros, character scope and game anchor. Only its resolved reference map is copied into the established historical agent context; tools, effects and memory remain. Returned macro variables are not persisted again. Unattached agents and an already-selected target skip the extra preparation. This adds bounded context/scanner preparation for genuinely historical reference-enabled calls, with no additional agent model request. The maintained real Fastify/storage/model-stub regressions cover **30 pre/post retry requests**, all three historical execution variants and an unattached control. They assert both included and excluded entries, distinct old/new keywords and input macros, speaker isolation and one agent request. Exact `a97` fails read-behind/Keeper historical context; the snapshot-only intermediate repair also fails final backfill intent. Both negative controls are retained separately. Normal grouped generation, true Continue, guide/system tails, original/regenerated swipe, impersonation, bounded keyword/semantic windows, merged rewrite routes and additive legacy sources remain covered. The client finding is a supported **Game session cache boundary**: real reused/carried `/game/session/start` responses contain storage-encoded metadata, and `useStartSession` caches that response. The attachment control now uses existing `readChatMetadata`. Its maintained UI regression drives real session creation/reuse with an eligible World Maps tracker and a selected prompt preset, holds later detail GETs, asserts the actual raw cached string and verifies the toggle’s PATCH and stored selected book. The unchanged component fails both before cases. **12 dark/light desktop/mobile Chromium/WebKit cases and six existing cold/warm/wire controls pass**. These use an inert package registry fixture, not the full Maps runtime or physical devices. [Final runnable controls, original failures, exact hashes and review logs](https://gist.github.com/SpicyMarinara/3172356d40fc217fbd25ea4ff8632021) contains the maintained regressions, negative controls, exact source hashes and current validation/review logs. All **51 raw files** match local bytes. Final `pnpm check`, **14 focused canonical Node files**, **seven shell smokes** and **three compiled-startup cases** pass on this repair. The seven-file repair review and final one-file integration review both completed **zero findings**; the earlier intermediate review’s one valid final-backfill finding was repaired. The E2E-only generic-call type error and runtime-equivalent result-assertion correction are recorded separately, with final fullcheck passing. Earlier review results remain scoped to their original heads. **Capability API 1.380 and English overview bytes are unchanged.** Hosted checks, the actual fetched-head review and zero unresolved threads remain merge gates; source-based finding dispositions retain the actual reported counts. The sole actual-staging conflict preserves upstream **`illustratorStillOnly`** in the factored retry context arguments; independent source review and actual Roleplay-video/GM/provider controls pass. ## Why this change An agent needs its own extra reference lorebook in a chat, without exposing it to the main reply, unrelated agents or other chats. Closes #8145 and addresses the attachment portion of #8148; its creation notice already landed in #8150. Owner: @SpicyMarinara (Codex). ## What changed - Add a default-off attachment toggle and one-book dropdown to eligible writing, tracking and custom-agent menus. Save per-chat bindings, preserve independent per-agent and per-field edits, and show localized save errors while preserving queued saves. - Reuse normal triggers, budgets, macros and character visibility in normal generation, manual/historical retries and grouped agents. Existing custom-agent lorebook sources remain additive. - Expose permission-checked, cancellable package-bound API 1.380 resolution. World Maps has equivalent Roleplay/Game controls and update guidance for older installed packages; global templates remain outside chat attachments. - Keep ordinary reusable wizard defaults free of chat-owned bindings at both Save and Apply, including legacy templates. Full initial/profile snapshots and same-chat Reset retain schema-valid bindings without deleting unrelated concurrently added agents. - Retain trusted generation intent on new assistant rows, split parts and swipes; portable import/export strips it. Preserve bounded history slots and supplemental guide semantics without copying or macro-resolving whole transcripts. - Document the behavior and add canonical English UI copy. Ten-pack publication #8155 waits for this English source to merge. ## Established behavior and review boundaries **Merged agents resolve original per-agent sources before merging.** The executor unions/deduplicates those already-resolved entries. [Twelve actual normal/post/historical-pre routes](https://gist.github.com/SpicyMarinara/d5eb1123182f38f1103ca7ede0feefea) and [the original real-route proof](https://gist.github.com/SpicyMarinara/c9b20fdf4a383ca5cd11f4ca99fa6e50) cover unattached base/attached sibling, only base, all distinct books, unmatched/unrelated exclusions and one combined provider call. No group production repair was necessary. **Old group intent cannot be reconstructed universally after provenance is removed.** Actual ordinary `user → A → B` and true no-input continuation can leave indistinguishable legacy rows. Arbitrary older input remains macro context, not proof of a new turn. The conservative legacy fallback is deliberate; derivable chat/swipe intent survives narrator/system tails. The earlier cold Conversation query and optimistic-copy allegations were disproven by [six actual boundary controls](https://gist.github.com/SpicyMarinara/0e1e6713b179f734afdad88848231750). The newly reproduced raw Game-session writer is a separate supported path and is fixed above. Published Maps package 1.7.1/API 1.380 compatibility is already merged in Pasta-Devs/Marinara-Agents#1614; exact ZIP/catalog bytes were verified. This Engine host remains its delivery dependency. Combat-style API 1.379 is preserved; audio API 1.381 belongs to dependent #8167. Earlier [bounded-window/name proof](https://gist.github.com/SpicyMarinara/e7226310cecfda126a09cfe236ab4919), [window/guide repair](https://gist.github.com/SpicyMarinara/86bea61b71b5ffbb4f34402e5e5676ed), [wizard reset](https://gist.github.com/SpicyMarinara/62ba2230b182baf73ea1d5bdcfb4240c), [reusable-default and generation-intent proof](https://gist.github.com/SpicyMarinara/a73d58bfe9a4e29ecf308b464202bef8), [save-error/legacy-tail proof](https://gist.github.com/SpicyMarinara/d5eb1123182f38f1103ca7ede0feefea) and [roster controls](https://gist.github.com/SpicyMarinara/eb318842c81239e69d16c3b128b84247) retain their exact tested-head scope. Earlier upstream findings were tracked separately; they are not folded into this reference feature or called zero findings. No release version or CHANGELOG changes. ## Manual verification - [ ] Manually verify two agents/chats, grouping, ordinary generation and historical retries. - [ ] Manually verify physical phones, deleted/disabled books and updating Engine and Maps together. Browser emulation and local model fixtures are distinct from physical-device and paid-provider validation. The existing unrelated Professor hook warning is recorded. No queued/pending hosted result is claimed as passed. ## UI evidence [Published desktop/mobile dark/light and World Maps gallery](https://gist.githack.com/SpicyMarinara/634995e325ef665979b8d3ae02b44012/raw/fd6744604d334eb613d793ed38aafaa368be251d/marinara-agent-lorebook-ui-evidence.html). Its HTML/embedded PNGs are byte-verified. Current Game-session metadata screenshots and their qualified visual limits are included in the current repair proof. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #8153] feat(agents): attach lorebooks per chat and agent to [PR #8153] [MERGED] feat(agents): attach lorebooks per chat and agent 2026-10-25 04:04:18 +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#8131
No description provided.