mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8153] [MERGED] feat(agents): attach lorebooks per chat and agent #8131
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8131
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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+)
3a712c9feat(agents): define per-chat lorebook attachmentsc0fe8a3feat: attach chat-scoped lorebooks to individual agentsde0f1e0Merge remote-tracking branch 'origin/staging' into feat/chat-agent-lorebook-attachments46faa1afeat: expose scoped lorebook references to package agentsc3e042etest: cover package compatibility and prove negative agent cases execute2740c81fix: include saved generation guides in package reference scans26d3b54fix: keep agent lorebook attachments out of chat profiles2cf7306fix: preserve valid agent lorebook selections and setup defaultsa96c341fix(agents): reset wizard attachments through valid merged entries29db298fix(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.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
aea876c470277331009750a9c4f7e5c16295ef88repairs 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
nullstill 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
087dbba301925b7b98bf0b5797b2257c49ae9b09added one accurate user-facing limitation paragraph and integrated the separately reviewed scene-video wording from actual staginge6b1ac67. That documentation-only head retained every runtime, regression and workflow byte from03f0d47f4. 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
03freports concern missing or stripped legacy intent. A fresh actual-route counterexample runs normaluser → A → Bgeneration and a real no-input Continue of B. Trusted saved snapshots correctly distinguishchatfromcontinue/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:
lastTurnandpriorTurnonly 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
03fruntime, 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-only087completed 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
a97Dottore findings are valid and repaired in03f0d47f4d7da7f6b592e543e0913ff05ecb9c5f(repaire3e2f5bc33, integrated actual staging611a1200c). 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
a97fails 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/startresponses contain storage-encoded metadata, anduseStartSessioncaches that response. The attachment control now uses existingreadChatMetadata. 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 upstreamillustratorStillOnlyin 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
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 → Band 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
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.
[PR #8153] feat(agents): attach lorebooks per chat and agentto [PR #8153] [MERGED] feat(agents): attach lorebooks per chat and agent