mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1465] [Issue]: Long-Term Memory: a memory that shares one distinctive word with the chat is never recalled #744
Labels
No labels
agent: chess
agent: conversation-calls
agent: eightball
agent: haptic
agent: hierarchical-maps
agent: hierarchical-maps
agent: illustrator
agent: poker
agent: rock-paper-scissors
agent: tic-tac-toe
agent: uno
artifacts
bug
bugfix
build
catalog
ci
client
dependencies
docs
documentation
enhancement
feature
fixed-in-staging
in-pr
normal-scope
packages
pull-request
qol
regression
roadmap
scope-risk
server
soup
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Agents#744
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 @Promansis on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1465
Originally assigned to: @SpicyMarinara, @Promansis on GitHub.
Summary
A memory whose only overlap with the chat is one distinctive word is never recalled, even when full-text search agrees it matches. Since #1264, a single ordinary exact keyword is capped at half the keyword lane (relevance 0.28 under the balanced style), which is below the 0.35 default threshold. The cap is right for everyday words, but it also blocks these memories, and on a labelled test fixture they are the largest group of missed essential memories. Counting the word when BM25 also rates the memory a reasonable match (normalized score ≥ 0.2) brings them back within the agreed noise limit.
Affected package
long-term-memory1.4.53 (upstream/staging2a3c37bb2).S=packages/long-term-memory/src/engine/packages/server/src/services/long-term-memoryExpected behavior
An invented example. The chat says: "Want to hear me play the violin? Shut the door first."
Today the reply can contradict the first memory ("Elena tunes her violin..."). Expected: the AI knows the violin is gone.
Actual behavior
S/recall/keyword-index.ts:209-218caps every single ordinary exact keyword atLTM_KEYWORD_MAX_SCORE / 2. With the balanced keyword weight 0.56 that is relevance 0.28, so the 0.35 threshold drops the memory unless another lane scores it higher. The cap only changes a hit when3 × frequency weight ≥ 2, which means the keyword is on about 5 or fewer of ~150 in-scope memories, so every capped hit is already a distinctive word.Measurement
A private labelled fixture: 4 roleplay chats, 76 queries run as short and long windows (152), 89 essential labels per window length, plus off-topic windows. Balanced style, local MiniLM embeddings, threshold 0.35, cap 12. Notes are counted against today's selections. Only aggregate numbers are shared here.
Ruled out first:
Decision (2026-10-19): a single shared word counts only when it is distinctive and BM25 agrees, and a fix may bring in at most 2 unwanted memories for each forgotten one it recovers. The pass rule and the variant were fixed before the run.
Caveats: the pass is narrow, and most of the gain is on one chat (17 recovered for 18 unwanted; the other three give 7 for 28). The 0.2 gate came from an analysis that included that chat. A 0.3 gate gave 18 for 27; it is listed for context only and was not the pre-registered variant.
Steps to reproduce
Minimal fix
One PR, patch bump.
S/recall/keyword-index.ts:searchLtmKeywordIndextakes an optionallexicalScores?: ReadonlyMap<string, number>(chunk id to BM25 normalized score). In the #1264 cap loop (:209-218), a hit the cap would actually reduce (score ≥LTM_KEYWORD_MAX_SCORE / 2before the cap) whose lexical score is ≥ 0.2 scoresLTM_KEYWORD_MAX_SCORE * 0.75instead of being capped. Export the 0.2 gate as a named constant next toLTM_KEYWORD_MAX_SCORE. Names, multi-word phrases and two-keyword hits are unchanged, and a hit the cap does not reduce (an everyday word) is never lifted.S/recall/retrieval.ts:178: pass the BM25 normalized scores that:152already computes (lexical), keyed by chunk id.## Unreleased: one bullet.Not included
Regression proof
tests/long-term-memory-index-keys.regression.ts, beside the #1264 single-keyword case (:424): with a lexical score of 0.25 a single distinctive keyword scores 0.75 of the maximum; at 0.15, or with no map, it stays at or below 0.5; a keyword the cap does not reduce is not lifted, even with a high lexical score; the name and pair cases are unchanged.:354); a single-keyword chunk there may need text that keeps BM25 under the gate.Environment
staging2039583ca)upstream/staging2a3c37bb2)Logs, screenshots, or video
None. The numbers come from a private labelled fixture and harness; the fixture contains private chat data, so only aggregates are shared.
Additional context
Tracker item RS-7. Follows #1264 (the single-keyword cap) and #1363 (known names keep full credit).
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Oct 19, 2026):
@Promansis the maintainer asked us to land this for the release, so it is in Pasta-Devs/Marinara-Agents#1472, after the Pasta-Devs/Marinara-Agents#1467 keyword-lane fix (Long-Term Memory 1.4.54). It is implemented as written: an optional
lexicalScoresmap,LTM_SINGLE_KEYWORD_BM25_AGREEMENT = 0.2exported besideLTM_KEYWORD_MAX_SCORE, a flatLTM_KEYWORD_MAX_SCORE * 0.75for a hit the cap would cut, and retrieval passing its BM25 normalized scores. The regression adds your violin example as a balanced-style retrieval case. The changelog bullet is under the 1.4.54 heading instead of## Unreleased, because the notes build requires the version it publishes. Thank you for the labelled-fixture measurements and the pre-registered pass rule.@SpicyMarinara commented on GitHub (Oct 19, 2026):
Fixed on staging by #1472; update Long-Term Memory from the catalog to get it.