mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7187] [MERGED] fix(memory): shortlist recall and let the decision model pick scenes, then messages #7616
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#7616
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/7187
Author: @SpicyMarinara
Created: 10/6/2026
Status: ✅ Merged
Merged: 10/6/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/memory-recall-two-stage-7182📝 Commits (6)
ab0f5b0fix(memory): shortlist recall and let the decision model pick scenes, then messages55ed28dfix(memory): skip the message pass when the Decision model must be deferred0384796fix(memory): keep speaker names out of name weighting and flag text-centred excerptsf9487b7Merge remote-tracking branch 'origin/staging' into fix/memory-recall-two-stage-7182467bfefMerge branch 'staging' into fix/memory-recall-two-stage-7182760e4acMerge remote-tracking branch 'origin/staging' into fix/memory-recall-two-stage-7182📊 Changes
9 files changed (+535 additions, -118 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/agents/memory.md(+4 -4)📝
docs/connections/decision-models.md(+1 -1)📝
packages/client/src/localization/locales/en.json(+2 -2)📝
packages/server/src/services/advanced-memory-decisions.ts(+9 -6)📝
packages/server/src/services/advanced-memory-ranking.ts(+28 -2)📝
packages/server/src/services/advanced-memory.ts(+152 -103)➕
scripts/regressions/advanced-memory-recall-shortlist.regression.ts(+336 -0)📝
scripts/run-regressions.mjs(+2 -0)📄 Description
Linked issue
Closes #7182
Why this change
What changed
MEMORY_DECISION_BATCH_SIZE, one request), kindscene. If Maximum recalled scenes is above 24, the shortlist widens to that setting, so it is never capped below it. Scenes scoring at or above the calibration threshold are selected, best first, up to Maximum recalled scenes and within the recall budget (summaries are reserved first, as before). If pass 1 fails, the shortlist's ordinary ranking chooses the scenes (decision-recall-fallback) and pass 2 is skipped.MEMORY_DECISION_MESSAGES_PER_SCENE). The best message at or above the threshold centres that scene's excerpt. If pass 2 fails, text matching chooses excerpts (decision-excerpt-fallback). If the model accepts none of a scene's messages, text matching centres that excerpt and the receipt recordsdecision-excerpt-fallback. Otherwise Advanced Memory activity would show those messages as Selected below the threshold under "Decision check completed".MEMORY_DECISION_RECALL_TIMEOUT_MSbudget, using a fresh backend signal. Trade-off: the worst case is now two 10-second passes instead of one combined 10 seconds. Normally pass 1 is a single request and pass 2 one or two (with the default 3 scenes).advanced-memory-ranking.ts). A word from the latest user message is treated as a name when the texts (candidates plus that message) write it capitalised mid-sentence and never in lowercase. A name gets 8x BM25 weight, unless it appears in more than half of the candidates. The responding characters' and the persona's own names never get it: they say who is talking, not about what. Without that rule, a group-chat responder named in under half of the memories outranked the topic the user asked them about. "Shiro's" tokenises toshiro. The same scoring orders each scene's messages for the pass-2 shortlist and the text-matched excerpt centre.respondingCharactersor the user, does not. The earlier draft said "the characters' own names", which a small model could apply to a named pet.Scenerows and pass 2 asMessagerows (both labels already exist), with correct Selected flags. The receipt text fordecision-recallnow reads "The Decision model judged which past memories were relevant." The old text claimed a selection even when Jev selected nothing.decision-excerpt-fallbacknow reads "Some original excerpts were chosen by text matching because the Decision model did not pick a message for them." That is true both when the message pass fails and when it rejects every message.validatePreparedreceipts, read-only previews (no Decision calls), budgets, the 6-attempt fitting loop and abort handling.docs/agents/memory.mdanddocs/connections/decision-models.mddescribe the two passes, the shortlist, per-pass limits and name weighting. CHANGELOG entry under[Unreleased].debugMode/DEBUG_AGENTS(logDebugOverrideinsystem-one.client.tsandsidecar-decision.backend.ts). Recall passesinput.debugModeto the backend.Validation
pnpm checkpasses locallyCONTRIBUTING.mdAgent-run checks (on a heavily loaded machine, load average 20–40):
pnpm check: exit 0.scripts/regressions/advanced-memory-recall-shortlist.regression.tsuses 64 closed scenes: 3 about Shiro, 1 about "the cats at the Cat's Tail inn", and all of them mentioning the persona and character names. The last message is "Kaito, have you seen my cat? Shiro's bowl is still full." A fake System One server records every call. It passes on this branch and fails onorigin/stagingin every section:scenecandidates, at most 24, including all Shiro scenes. The Shiro scenes are selected. Pass 2 receives only messages from those scenes, and the excerpts centre on the Shiro messages. Diagnostics show 3 selectedsceneand 3 selectedmessagerows, withfallback: false.validatePreparedaccepts the receipt. On staging, recall made 9 requests instead of 2.decision-recall-fallback, and the Shiro scenes are chosen without the cat-inn scene. Staging chose[cat-inn, shiro, shiro].decision-excerpt-fallbackwith diagnosticsfallback: true.decision-recall), proving separate budgets. Staging fell back at 10 s. The runner timeout for this file is raised to 60 s inscripts/run-regressions.mjs. There is no test seam for the 10 s constant, so this check waits about 11 real seconds.memory-recall-exclusivity,memory-recall-revectorize,roleplay-user-private-memory,native-export-memory,regression-timeout-policyandpnpm regression:promptpass too. Under the machine load, core, history-start, post-generation, native-export-memory and inspector first hit the runner's 30 s limit or the inspector's 5 s timing check. Rerun directly or once the load dropped, they all passed; the inspector's 1000-message prepare took 318 ms and 606 ms.pnpm localization:checkpasses.prettier --checkpasses on the changed TS, MD and JSON files.scripts/run-regressions.mjsanddocs/connections/decision-models.mdwere already unformatted on staging and were left as they are.Adversarial verification (second agent, head
038479669):sceneSourcemessages, which are eligible for the audience, indexed and not disabled, from scenes that passedcanRecallExcerpt. The existing decisions regression still proves hidden (PRIVATE_SECRET) and conditional (CONDITION_SECRET) text never reaches a request or the diagnostics. Read-only previews make no calls, compatible swipes reuse the snapshot, and abort still throws.038479669): the speaker-name exclusion, the honestdecision-excerpt-fallbackwhen the model rejects every message, the shortlist widening for Maximum recalled scenes above 24, and the question wording. Each new assertion was checked to fail with only its own fix neutralised.[0S,3S,8]to[0S,3S,6S], and the 300-word message from[2,3S,7]to[0S,3S,6S]. Lowercase "shiro's", the no-name, persona-name and side-name controls are unchanged.pnpm checkexits 0. All 12 Advanced Memory regressions pass, as domemory-recall-exclusivity,memory-recall-revectorize,roleplay-user-private-memory,native-export-memory,regression-timeout-policyandpnpm regression:prompt, at a load average of about 5.pnpm localization:checkand prettier on the changed files also pass.038479669.Local CodeRabbit review by the builder (CLI 0.7.6, committed changes against the staging merge base, head
55ed28d5b):deferPreGeneration). A reasoning chat-model connection can learn that it reasons during the scene pass, and the message pass then uses text matching withdecision-excerpt-fallback.Manual verification notes
Scenerows, thenMessagerows from the chosen scenes only, with the recalled ones marked Selected and "Decision check completed."decision-recall-fallbackreason in the memory receipt (Chat Settings → Advanced Memory) when the Decision connection is healthy.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Changed English docs:
docs/agents/memory.mdanddocs/connections/decision-models.md. The translated packs ondocs-i18nstill need matching updates or a[docs-i18n]follow-up issue.UI evidence (if applicable)
No layout change. Diagnostics rows reuse the existing
SceneandMessagelabels, and one receipt string inen.jsonwas reworded.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.