[PR #4918] [MERGED] fix(mari): teach workspace Professor Mari to revise an existing memory instead of declining #6541

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4918
Author: @kolacheee
Created: 8/11/2026
Status: ✅ Merged
Merged: 8/11/2026
Merged by: @kolacheee

Base: staging ← Head: fix/mari-memory-edit-guidance


📝 Commits (1)

  • 5b40940 fix(mari): teach workspace Professor Mari to revise an existing memory (#4917)

📊 Changes

3 files changed (+36 additions, -0 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+4 -0)
📝 scripts/regressions/mari-instructions-memory.regression.ts (+31 -0)

📄 Description

Linked issue

Closes #4917

Why this change

A user's tester asked workspace Professor Mari to make an aesthetic adjustment to a saved, enabled, persistent memory. She inspected it and declined — "the requested state already exists, no mutation was necessary" — and saved nothing.

This is not a capability gap. I traced the whole path: instruction.update fully persists a content change to an existing enabled/persistent memory (the new content is written, the memory stays enabled because buildInstructionPatch never touches enabled and the deep-merge preserves it, apply:true applies immediately with the Keep/Restore card acting only as a post-hoc undo), and there is no diff/no-op/"already matches" short-circuit anywhere in the engine. For a persistent memory the full body is also injected every turn, so Mari has the true content in front of her.

The cause is prompt-side. The memory-editing guidance was uniquely thin and conservative compared to its peers:

  • Every other read-modify-write entity gets an explicit recipe + worked example — presets ("read the section's full content, splice your change in, then preset.updateSection with the whole new content", with an example), lorebooks the same. Memories got neither — one bullet naming instruction.update with no fields, no recipe, no example.
  • instruction.get was framed only as read-to-obey ("read the full memory, then follow it"), never read-to-edit.
  • The memory bullet carried extra hedging ("a memory is a standing instruction", "treat them as authoritative") with no counterweight encouraging revision.

So a cosmetic-looking edit gets rationalized as already-satisfied.

What changed

  • packages/server/src/services/professor-mari/workspace-agent.service.ts — added a "Revising an existing memory" bullet (read the full text with instruction.get, edit it, write the WHOLE new content back with instruction.update apply:true; same read-splice-rewrite loop as a preset section; works on an enabled/persistent memory without disabling it; do not decline as already-satisfied), plus a worked instruction.get → instruction.update example mirroring the preset-section example. The existing "ONLY save or change a memory when the USER explicitly asks" guardrail is unchanged, and the new bullet is scoped to "when the user asks."
  • scripts/regressions/mari-instructions-memory.regression.ts — new step (7b) that edits an ENABLED, persistent memory's content, keeps it (not restored), and asserts the new body persists, the memory stays enabled and persistent, and the new body is what injects into the prompt. Closes the coverage gap (existing update tests only edited a disabled memory and reverted it).
  • CHANGELOG.md — one entry under Fixed.

No engine/data-path code changed — the action layer already supports this end-to-end.

One edge caveat (documented in the issue): content is .trim()'d on save, so a purely leading/trailing-whitespace edit is a legitimate no-op; an internal formatting change is a real diff.

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

Automated, done by me:

  • pnpm check passes (TypeScript + ESLint + build, exit 0).
  • mari-instructions-memory.regression.ts passes, including the new enabled+persistent content-edit-and-keep step ("Mari instructions-memory regressions passed.").

Still needs a human (please verify in a real browser, don't trust the boxes above):

  • Ask workspace Mari to reword/reformat an existing enabled memory; confirm she reads it, updates it via instruction.update, the new content is saved, and the memory stays enabled — rather than declining as "already exists."

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)

CHANGELOG.md updated. No docs/ change (this is Mari's internal prompt guidance) and no version bump.

UI evidence (if applicable)

Summary by CodeRabbit

  • Bug Fixes

    • Professor Mari can now revise existing saved memories while preserving their enabled and persistent status.
    • Updated memory content remains available for retrieval and appears correctly in rendered prompts.
  • Tests

    • Added regression coverage for reviewing, applying, and validating updates to persistent memories.
  • Documentation

    • Documented the memory revision fix in the changelog.

🔄 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/4918 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/11/2026 **Status:** ✅ Merged **Merged:** 8/11/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `fix/mari-memory-edit-guidance` --- ### 📝 Commits (1) - [`5b40940`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5b4094078ad318d9b7c6d78cdb3ddf6adeaf1acb) fix(mari): teach workspace Professor Mari to revise an existing memory (#4917) ### 📊 Changes **3 files changed** (+36 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+4 -0) 📝 `scripts/regressions/mari-instructions-memory.regression.ts` (+31 -0) </details> ### 📄 Description ## Linked issue Closes #4917 ## Why this change A user's tester asked workspace Professor Mari to make an aesthetic adjustment to a saved, enabled, persistent memory. She inspected it and declined — "the requested state already exists, no mutation was necessary" — and saved nothing. This is **not** a capability gap. I traced the whole path: `instruction.update` fully persists a content change to an existing enabled/persistent memory (the new content is written, the memory stays enabled because `buildInstructionPatch` never touches `enabled` and the deep-merge preserves it, `apply:true` applies immediately with the Keep/Restore card acting only as a post-hoc undo), and there is **no diff/no-op/"already matches" short-circuit anywhere in the engine**. For a persistent memory the full body is also injected every turn, so Mari has the true content in front of her. The cause is prompt-side. The memory-editing guidance was uniquely thin and conservative compared to its peers: - Every other read-modify-write entity gets an explicit recipe + worked example — presets ("read the section's full content, splice your change in, then `preset.updateSection` with the whole new content", with an example), lorebooks the same. Memories got **neither** — one bullet naming `instruction.update` with no fields, no recipe, no example. - `instruction.get` was framed only as read-to-**obey** ("read the full memory, then follow it"), never read-to-**edit**. - The memory bullet carried extra hedging ("a memory is a standing instruction", "treat them as authoritative") with **no counterweight** encouraging revision. So a cosmetic-looking edit gets rationalized as already-satisfied. ## What changed - **`packages/server/src/services/professor-mari/workspace-agent.service.ts`** — added a "Revising an existing memory" bullet (read the full text with `instruction.get`, edit it, write the WHOLE new content back with `instruction.update` `apply:true`; same read-splice-rewrite loop as a preset section; works on an enabled/persistent memory without disabling it; **do not decline as already-satisfied**), plus a worked `instruction.get` → `instruction.update` example mirroring the preset-section example. The existing "ONLY save or change a memory when the USER explicitly asks" guardrail is unchanged, and the new bullet is scoped to "when the user asks." - **`scripts/regressions/mari-instructions-memory.regression.ts`** — new step (7b) that edits an ENABLED, persistent memory's content, keeps it (not restored), and asserts the new body persists, the memory stays enabled and persistent, and the new body is what injects into the prompt. Closes the coverage gap (existing update tests only edited a disabled memory and reverted it). - **`CHANGELOG.md`** — one entry under Fixed. No engine/data-path code changed — the action layer already supports this end-to-end. One edge caveat (documented in the issue): content is `.trim()`'d on save, so a purely leading/trailing-whitespace edit is a legitimate no-op; an internal formatting change is a real diff. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated, done by me: - `pnpm check` passes (TypeScript + ESLint + build, exit 0). - `mari-instructions-memory.regression.ts` passes, including the new enabled+persistent content-edit-and-keep step ("Mari instructions-memory regressions passed."). Still needs a human (please verify in a real browser, don't trust the boxes above): - Ask workspace Mari to reword/reformat an existing enabled memory; confirm she reads it, updates it via `instruction.update`, the new content is saved, and the memory stays enabled — rather than declining as "already exists." ## Docs and release impact - [ ] No docs changes needed - [x] 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) `CHANGELOG.md` updated. No `docs/` change (this is Mari's internal prompt guidance) and no version bump. ## UI evidence (if applicable) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Professor Mari can now revise existing saved memories while preserving their enabled and persistent status. * Updated memory content remains available for retrieval and appears correctly in rendered prompts. * **Tests** * Added regression coverage for reviewing, applying, and validating updates to persistent memories. * **Documentation** * Documented the memory revision fix in the changelog. <!-- 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:11:24 +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#6541
No description provided.