[PR #7333] [MERGED] fix(advanced-memory): offer local models as the memory Decision model #7684

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

📋 Pull Request Information

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

Base: staging ← Head: fix/7326-amr-primary-local-model


📝 Commits (8)

  • 3e26316 fix(advanced-memory): offer local models as the memory Decision model
  • 93b8640 Merge origin/staging into fix/7326-amr-primary-local-model
  • ebc82f3 fix(decision): stop waiting for a loading local model when the caller gives up
  • 3e05bb2 Merge origin/fix/7326-amr-primary-local-model into fix/7326-amr-primary-local-model
  • d5ebf2a fix(advanced-memory): say when the local model list fails to load
  • cc4ec95 Merge origin/staging into fix/7326-amr-primary-local-model
  • 93d0545 Merge origin/staging into fix/7326-amr-primary-local-model
  • 454e028 Move the CHANGELOG entry away from other open PRs

📊 Changes

9 files changed (+352 additions, -53 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/agents/memory.md (+1 -1)
📝 docs/connections/decision-models.md (+2 -2)
📝 packages/client/src/components/chat/AdvancedMemorySettings.tsx (+44 -12)
📝 packages/client/src/components/connections/DecisionDefaultControl.tsx (+33 -18)
📝 packages/server/src/routes/advanced-memory.routes.ts (+1 -0)
📝 packages/server/src/services/advanced-memory.ts (+20 -6)
📝 packages/server/src/services/decision/decision-slots.ts (+26 -14)
➕ scripts/regressions/advanced-memory-local-decision.regression.ts (+224 -0)

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

Why this change

  • A user who runs a Primary local model already gets lorebook decisions from it through the global Decision model, but could not pick it in Advanced Memory Recall: Memory Decision connection listed only saved Decision connections. So the one free, private Decision model they had could not drive scene checks or recall.
  • Root cause: the Advanced Memory dropdown filtered connections to provider === "decision" (AdvancedMemorySettings.tsx), and the server could not have used a local model anyway. memoryDecisionBackend hard-coded getLocalDefault: async () => null (advanced-memory.ts), and updateSettings refused any id that is not a saved Decision connection row.

What changed

  • Server (advanced-memory.ts): the chat's Decision choice now goes through the same resolveDecisionBackend path as lorebooks, prompt statements and activation questions. A local model id (sidecar:local, the utility slot, the decision sidecar) resolves as that local model; any other id stays a connection row as before.
    • Choosing a local model that cannot answer (no model downloaded) is refused, with the same describeDecisionSlot rule the global /decision/select uses.
    • A stopped local model counts as usable: asking it starts it (forceStart), as it does for lorebooks. If it fails to start, recall falls back to ordinary recall and scene checks to the helper, as they already did for an unreachable connection.
    • If the model is removed after it was chosen, the existing "Choose a usable Decision connection" warning shows, and recall falls back.
  • Client: the dropdown now has a Local models group, built from the global Decision model's /decision/options list, so entries that cannot answer are greyed out with the same reason the global dropdown gives. The existing connections are under Connections. The option row renderer moved out of DecisionDefaultControl so both dropdowns share it. No new UI text: the group labels and reasons reuse existing keys.
  • Utility local model and Decision sidecar show up too, because they take the same code path and the global dropdown lists them. The issue asked only for the Primary local model.
  • Verifier follow-up (decision-slots.ts, advanced-memory.routes.ts): starting a stopped Primary or Utility local model is now raced against the caller's signal, as the decision sidecar already was. Without it a recall pass waited for the whole cold load instead of falling back after its 10-second limit, and a cancelled generation also waited for the load; the start carries on in the background. The Advanced Memory settings route also answers 400 with the reason, not a 500, when a local model that cannot answer is chosen. The regression now checks that a model still loading does not hold its caller past the time limit (it fails without the change).
  • Verifier follow-up (client): if /decision/options fails to load, the existing load-failure line under Memory Decision connection now shows that error too, with Retry, and the menu stays disabled until the list loads (found by local CodeRabbit). That line now uses the steady accent, so it does not pulse with Accent Pulse. No new text.
  • Docs: docs/agents/memory.md (Optional Decision model) and docs/connections/decision-models.md. CHANGELOG entry under [Unreleased].
  • Regression: scripts/regressions/advanced-memory-local-decision.regression.ts uses a fake llama-server and a fake Primary local model. It checks that the model is refused with no model downloaded. It then checks that scene checks and recall send one-token log-probability requests to the local model and none to the helper's classifier, and that the model is started with forceStart. Last, it checks the fallbacks when the model fails to start or is removed. Before the fix it fails at the first assertion. With only the settings check fixed, it fails at "the local model checks scene boundaries".

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

  • Manually verify that with a Primary local model downloaded, Roleplay Chat Settings → Memory Recall → Advanced Memory Recall → Use Decision model shows Local models → Primary local model — in Memory Decision connection, and that choosing it saves and survives a reload.
  • Manually verify that with no local model downloaded, the Primary local model entry is greyed out with "No model downloaded — set up in Local Model" and cannot be picked.
  • Manually verify that after choosing the Primary local model, a Roleplay reply with older scenes shows decision-recall in the recall receipt and that Peek Prompt → Decision diagnostics → Advanced Memory activity names the local model.
  • Manually verify that with the local sidecar stopped, the next reply starts it and still completes without waiting for the whole load: recall falls back to ordinary recall after about 10 seconds while the model loads, and a later reply shows decision-recall.
  • Manually verify that cancelling a reply while a stopped Primary local model is loading for a lorebook Decision stops the wait at once, and the model still finishes loading.
  • Manually verify that saved Decision connections still appear under Connections and can still be chosen, on desktop and on a phone-width window, in the Chat Settings drawer and in the Roleplay setup wizard.
  • Manually verify that when /decision/options fails (for example, block it in DevTools), Memory Decision connection is disabled and the line under it shows the error with Retry, and that Retry brings the local models back.
  • Manually verify that Connections → Connection defaults → Decision model still renders and greys out entries as before (its option row renderer was shared).

Agent-run checks: node ./scripts/run-regressions.mjs --filter for advanced-memory-local-decision (new), advanced-memory-decisions, advanced-memory-recall-shortlist, advanced-memory-visibility, advanced-memory-post-generation, advanced-memory-core, roleplay-user-private-memory, decision-local-models, and decision-conditionals: all passed. pnpm localization:check: no new or changed keys. pnpm check (through the shared slot limiter): passed. No browser run was done.

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)

Translations: tracked in #7332.

Existing copy that is now slightly off but was not changed, per the no-side-copy-edits rule: the placeholder "Choose a Decision connection", the label "Memory Decision connection", the help line "Create a Decision connection in Connections, then pick it here…", and the warning "Choose a usable Decision connection…" all say "connection" even when a local model is chosen.

UI evidence (if applicable)

Not captured. The change adds <optgroup> groups to an existing native select.

Summary by CodeRabbit

  • New Features
    • Advanced Memory can use a local model for scene-boundary checks and memory recall, alongside saved Decision connections.
    • Unavailable local models appear disabled with an explanation. Stopped models can start when Advanced Memory needs them.
    • If a selected local model becomes unavailable, it remains selected and is shown with an availability warning.
  • Bug Fixes
    • Replies are no longer held up beyond the usual 10-second recall wait while a local model loads. Cancelling a reply also stops the wait.

🔄 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/7333 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/7326-amr-primary-local-model` --- ### 📝 Commits (8) - [`3e26316`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3e263160e5a780a59c3fccc56d6402b6132b4fe6) fix(advanced-memory): offer local models as the memory Decision model - [`93b8640`](https://github.com/Pasta-Devs/Marinara-Engine/commit/93b864043de46c6178fc97559c37bff50b5b9098) Merge origin/staging into fix/7326-amr-primary-local-model - [`ebc82f3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ebc82f35d4b9b5bf83203e08d58d5c919c31e755) fix(decision): stop waiting for a loading local model when the caller gives up - [`3e05bb2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3e05bb28a6c1789396b7d92c82123bbb4d05af57) Merge origin/fix/7326-amr-primary-local-model into fix/7326-amr-primary-local-model - [`d5ebf2a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d5ebf2a518e8d0ac1a34590be3f754795dbd672a) fix(advanced-memory): say when the local model list fails to load - [`cc4ec95`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cc4ec95634620519c6cac48a7c31fdc3c5315e6b) Merge origin/staging into fix/7326-amr-primary-local-model - [`93d0545`](https://github.com/Pasta-Devs/Marinara-Engine/commit/93d05459827d3875a095f3952dcd850b33cfc75c) Merge origin/staging into fix/7326-amr-primary-local-model - [`454e028`](https://github.com/Pasta-Devs/Marinara-Engine/commit/454e0284d730c886cc15a3077b5681ceb13b922d) Move the CHANGELOG entry away from other open PRs ### 📊 Changes **9 files changed** (+352 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/agents/memory.md` (+1 -1) 📝 `docs/connections/decision-models.md` (+2 -2) 📝 `packages/client/src/components/chat/AdvancedMemorySettings.tsx` (+44 -12) 📝 `packages/client/src/components/connections/DecisionDefaultControl.tsx` (+33 -18) 📝 `packages/server/src/routes/advanced-memory.routes.ts` (+1 -0) 📝 `packages/server/src/services/advanced-memory.ts` (+20 -6) 📝 `packages/server/src/services/decision/decision-slots.ts` (+26 -14) ➕ `scripts/regressions/advanced-memory-local-decision.regression.ts` (+224 -0) </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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7326 ## Why this change - A user who runs a Primary local model already gets lorebook decisions from it through the global **Decision model**, but could not pick it in Advanced Memory Recall: **Memory Decision connection** listed only saved Decision connections. So the one free, private Decision model they had could not drive scene checks or recall. - Root cause: the Advanced Memory dropdown filtered connections to `provider === "decision"` (`AdvancedMemorySettings.tsx`), and the server could not have used a local model anyway. `memoryDecisionBackend` hard-coded `getLocalDefault: async () => null` (`advanced-memory.ts`), and `updateSettings` refused any id that is not a saved Decision connection row. ## What changed - **Server (`advanced-memory.ts`)**: the chat's Decision choice now goes through the same `resolveDecisionBackend` path as lorebooks, prompt statements and activation questions. A local model id (`sidecar:local`, the utility slot, the decision sidecar) resolves as that local model; any other id stays a connection row as before. - Choosing a local model that cannot answer (no model downloaded) is refused, with the same `describeDecisionSlot` rule the global `/decision/select` uses. - A stopped local model counts as usable: asking it starts it (`forceStart`), as it does for lorebooks. If it fails to start, recall falls back to ordinary recall and scene checks to the helper, as they already did for an unreachable connection. - If the model is removed after it was chosen, the existing "Choose a usable Decision connection" warning shows, and recall falls back. - **Client**: the dropdown now has a **Local models** group, built from the global Decision model's `/decision/options` list, so entries that cannot answer are greyed out with the same reason the global dropdown gives. The existing connections are under **Connections**. The option row renderer moved out of `DecisionDefaultControl` so both dropdowns share it. No new UI text: the group labels and reasons reuse existing keys. - Utility local model and Decision sidecar show up too, because they take the same code path and the global dropdown lists them. The issue asked only for the Primary local model. - **Verifier follow-up (`decision-slots.ts`, `advanced-memory.routes.ts`)**: starting a stopped Primary or Utility local model is now raced against the caller's signal, as the decision sidecar already was. Without it a recall pass waited for the whole cold load instead of falling back after its 10-second limit, and a cancelled generation also waited for the load; the start carries on in the background. The Advanced Memory settings route also answers 400 with the reason, not a 500, when a local model that cannot answer is chosen. The regression now checks that a model still loading does not hold its caller past the time limit (it fails without the change). - **Verifier follow-up (client)**: if `/decision/options` fails to load, the existing load-failure line under **Memory Decision connection** now shows that error too, with **Retry**, and the menu stays disabled until the list loads (found by local CodeRabbit). That line now uses the steady accent, so it does not pulse with Accent Pulse. No new text. - Docs: `docs/agents/memory.md` (Optional Decision model) and `docs/connections/decision-models.md`. CHANGELOG entry under `[Unreleased]`. - Regression: `scripts/regressions/advanced-memory-local-decision.regression.ts` uses a fake llama-server and a fake Primary local model. It checks that the model is refused with no model downloaded. It then checks that scene checks and recall send one-token log-probability requests to the local model and none to the helper's classifier, and that the model is started with `forceStart`. Last, it checks the fallbacks when the model fails to start or is removed. Before the fix it fails at the first assertion. With only the settings check fixed, it fails at "the local model checks scene boundaries". ## 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 - Manually verify that with a Primary local model downloaded, **Roleplay Chat Settings → Memory Recall → Advanced Memory Recall → Use Decision model** shows **Local models → Primary local model — <model name>** in **Memory Decision connection**, and that choosing it saves and survives a reload. - Manually verify that with no local model downloaded, the Primary local model entry is greyed out with "No model downloaded — set up in Local Model" and cannot be picked. - Manually verify that after choosing the Primary local model, a Roleplay reply with older scenes shows **decision-recall** in the recall receipt and that **Peek Prompt → Decision diagnostics → Advanced Memory activity** names the local model. - Manually verify that with the local sidecar stopped, the next reply starts it and still completes without waiting for the whole load: recall falls back to ordinary recall after about 10 seconds while the model loads, and a later reply shows **decision-recall**. - Manually verify that cancelling a reply while a stopped Primary local model is loading for a lorebook Decision stops the wait at once, and the model still finishes loading. - Manually verify that saved Decision connections still appear under **Connections** and can still be chosen, on desktop and on a phone-width window, in the Chat Settings drawer and in the Roleplay setup wizard. - Manually verify that when `/decision/options` fails (for example, block it in DevTools), **Memory Decision connection** is disabled and the line under it shows the error with **Retry**, and that Retry brings the local models back. - Manually verify that **Connections → Connection defaults → Decision model** still renders and greys out entries as before (its option row renderer was shared). **Agent-run checks:** `node ./scripts/run-regressions.mjs --filter` for `advanced-memory-local-decision` (new), `advanced-memory-decisions`, `advanced-memory-recall-shortlist`, `advanced-memory-visibility`, `advanced-memory-post-generation`, `advanced-memory-core`, `roleplay-user-private-memory`, `decision-local-models`, and `decision-conditionals`: all passed. `pnpm localization:check`: no new or changed keys. `pnpm check` (through the shared slot limiter): passed. No browser run was done. ## 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) Translations: tracked in #7332. Existing copy that is now slightly off but was not changed, per the no-side-copy-edits rule: the placeholder "Choose a Decision connection", the label "Memory Decision connection", the help line "Create a Decision connection in Connections, then pick it here…", and the warning "Choose a usable Decision connection…" all say "connection" even when a local model is chosen. ## UI evidence (if applicable) Not captured. The change adds `<optgroup>` groups to an existing native select. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Advanced Memory can use a local model for scene-boundary checks and memory recall, alongside saved Decision connections. * Unavailable local models appear disabled with an explanation. Stopped models can start when Advanced Memory needs them. * If a selected local model becomes unavailable, it remains selected and is shown with an availability warning. * **Bug Fixes** * Replies are no longer held up beyond the usual 10-second recall wait while a local model loads. Cancelling a reply also stops the wait. <!-- 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-24 04:06:31 +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#7684
No description provided.