mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #4791] [Feature]: Teach workspace Professor Mari to author well-parameterized lorebooks (not just Name+Content+keys) #2639
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#2639
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?
Originally created by @kolacheee on GitHub (Aug 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4791
Originally assigned to: @kolacheee on GitHub.
What problem does this solve?
When a user asks the workspace Home assistant (Professor Mari) to build a lorebook — e.g. "make a lorebook for the setting Vlad the vampire lives in" — she produces near-skeletal entries: Name + Content + a couple of keys, and essentially nothing else. She never marks an always-on premise (
constant), never chooses placement (position/depth/order), never fills thedescriptionthe Knowledge Router reads, and never groups mutually-exclusive alternatives. The result is functional-but-shallow world info that under-uses the engine's own capabilities.The root cause is not the runtime — it is guidance and process. Her
lorebook.createruntime already persists far more than she's told about:buildLorebookEntryCreateRow(packages/server/src/services/mari-db/mari-db.service.ts:822-869) persistsname, content, description, tag, keys, secondaryKeys, constant, position, depth, order, role,andgroup.packages/server/src/services/mari-db/mari-db.service.ts:2467-2488) acceptsscanDepth, tokenBudget, entryLimit, recursion, and vector knobs.But her tool schema and prompt don't teach her to use any of it, and there is no authoring process that would surface the advanced parameters:
datafield description (packages/server/src/services/professor-mari/workspace-agent.service.ts:406) lists onlyname, content, keys, secondaryKeys, tag, constant, position, depth, role, orderfor entries — it omitsgroupand entrydescription(both accepted by the runtime), and lists onlyname, description, category, tagsfor the book (omitting every tuning knob).constant/position/depth/orderdo or when to reach for them.workspace-agent.service.ts:590, "The Glass City") — uses onlyname/content/keys, so she mirrors that skeletal shape.packages/server/src/services/professor-mari/guided-sequences.ts:6) goes straight from category/scope/topic chips to a one-shotlorebook.create— no self-informing step and no review pass in between.Net: she is aware some advanced fields exist but has no idea what they mean, when to use them, or what a good lorebook looks like — and nothing prompts her to double-check her own work — so she defaults to the lowest-common-denominator entry every time. The most visible casualty is the "always-true setting premise" (e.g. "vampires are real; the year is 1890"), which needs
constant: true: she has the field but is never told non-keyworded lore requires it, so premise facts get awkwardly keyworded or silently never fire.Scope note: this is specifically about workspace-Mari (the Home agentic assistant). The legacy conversation-mode
<create_lorebook>command is a separate, lower-capability surface that is effectively obsolete/legacy-only and is intentionally out of scope here.Proposed solution — a lorebook-authoring loop, not just a schema tweak
The fix is a small authoring workflow plus the guidance to power it. All of it is prompt / guided-sequence / schema-doc work in
workspace-agent.service.ts(+guided-sequences.ts) — no engine changes are required; the runtime already persists every field, and the read-back + refine tools already exist (lorebook.entries,lorebook.getEntry,lorebook.updateEntry).The loop:
lorebook.create(entries carrying the chosen parameters, not just name/content/keys).lorebook.entries/lorebook.getEntry) and critique each entry's parameters against the heuristic, thenlorebook.updateEntryto fix them — e.g. "this key is too broad → enable whole-word matching," "this fact is rarely typed in chat but doesn't deserve permanent tokens asconstant→ make it semantic instead," "these two entries are alternates → put them in onegroup."updateEntryalready surfaces the user an in-chat Keep/Restore review card, which fits this pass well.The guidance that powers it:
datafield description into a short field glossary (workspace-agent.service.ts:406): give each entry field a one-clause "what it does / when to use," and add the two fields the runtime already accepts but the schema omits — entrydescription(read by the Knowledge Router agent) andgroup(mutually-exclusive selection). Also surface the book-level tuning fields (scanDepth,tokenBudget,entryLimit, recursion, vectorization).constant: true, no keys; topical detail → non-constant + 3–8 keys; ambiguous keyword that mis-fires → Selective +secondaryKeys(+ whole-word); rarely-typed-but-relevant → semantic (vectorization), notconstant; alternates → samegroup; always filldescriptionfor the Knowledge Router. This is what she carries in-context; it needs zero doc round-trips for the common case.workspace-agent.service.ts:590) — aconstant: truepremise entry + a keyworded location entry + a filleddescription+ a deliberate placement/order choice — so she has a non-skeletal pattern to imitate.docs_read— which supports section-level reads by exact heading (unit-tested). Curate the exact{path, heading}targets in the heuristic so she reads only the relevant section (~250–425 tokens each) instead of whole files (~12K tokens for the full lorebook doc set) and never fumbles the keyword search. This depends on the docs actually teaching parameter use with examples — companion issue #4792.Execution & efficiency notes (from investigation)
workspaceCommandProtocolPrompt()(workspace-agent.service.ts:529) has no task-conditional branching; it andMARI_SYSTEM_PROMPTare pushed as system messages on every workspace turn (workspace-agent.service.ts:2115-2116), regardless of task. So anything baked in is resident for character/persona/theme/preset turns too. Implication: keep the baked heuristic compact and lean on targeted docs for depth.docs_readsection targeting is real and tested (packages/server/src/services/professor-mari/documentation-tools.ts, exact case-insensitive heading match;scripts/regressions/professor-mari-documentation.regression.ts).docs_searchis keyword (not semantic). Curate exact headings rather than trusting search wording. Also noteentries.md(~11.6K chars) exceedsdocs_read's defaultmaxCharsof 8,000, so whole-file reads truncate — another reason to target sections.Alternatives considered
<create_lorebook>command — declined; obsolete/legacy-only and lower-capability.constant) — rejected as too magic; better for Mari to choose explicitly and correctly, and the review pass catches mistakes.docs_readheading match fuzzy (to reduceHeading not founddead-ends) — recommend against. It's a shared tool with a regression asserting exact-section isolation, and a fuzzy near-miss that returns the wrong section silently is worse than a clean throw. Safer paths to the same goal: curate exact headings in the baked heuristic (no tool change) and rely on thedocs_search → docs_readhandshake. If dead-ends need softening, prefer changing the miss behavior to return the file's available-heading list (a cheap TOC) rather than a bare throw — this preserves exact-match precision. (Left as a design decision for the implementer; not required for this feature.)Additional context
workspace-agent.service.ts:406; skeletal exampleworkspace-agent.service.ts:590; always-on prompt assemblyworkspace-agent.service.ts:529,2115-2116; runtime persistsdescription+groupmari-db.service.ts:822-869; book-level create accepts tuning knobsmari-db.service.ts:2467-2488; guided flow with no docs/review stepguided-sequences.ts:6; docs toolingdocumentation-tools.ts+ regressionscripts/regressions/professor-mari-documentation.regression.ts. Thatdescriptionis read only by the Knowledge Router and thatgroupmakes entries mutually-exclusive is corroborated by the user docs themselves (docs/lorebooks/entries.md:44and:117).constantpremise entry + keyed detail entries + filleddescriptions, not name/content/keys only; (b) she offers a fidelity review rather than auto-running it; (c) on acceptance she reads the entries back and refines parameters (e.g. narrows an over-broad key, switches a rarely-typed constant to semantic). No automated harness models real model output here.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: