[GH-ISSUE #1363] [Issue]: LTM recall: a character's name loses name credit at the start of a sentence, in lowercase, or in a caseless script #694

Closed
opened 2026-10-20 17:29:49 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Oct 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1363

Originally assigned to: @Promansis on GitHub.

Summary

Since #1264, a single ordinary keyword match gets half keyword credit, but a name keeps full credit. LTM decides what counts as a name only by capitalisation: a capitalised word that is not at the start of a sentence, quote or line. A character's name therefore loses name credit when the user starts a sentence with it, types in lowercase, or writes in a script without letter case, such as Korean. The vault already knows its characters' names, but recall doesn't use them.

Affected package

long-term-memory 1.4.30 (upstream/staging a468f18e6), under packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/:

  • keyword-index.ts: queryNameTerms (lines 66-77), used by the single-keyword cap (lines 206-214)
  • retrieval.ts:159: the keyword search call
  • Tests: tests/long-term-memory-index-keys.regression.ts:380-440 (the #1264 name cases)

Expected behavior

  • A word or phrase in the recall window that matches a character memory's title, ignoring case, counts as a name wherever it appears: at the start of a sentence, in lowercase, or in a caseless script.
  • A single exact keyword match on such a name keeps full keyword credit, the same as a capitalised mid-sentence name does today.
  • Nothing else changes: no new lane, and no change to the threshold, BM25 or vector scoring.

Actual behavior

With a character memory titled "Mira" and the keyword mira:

  1. "Then Mira walked in." → Mira is mid-sentence, so it counts as a name and keeps full credit.
  2. "Mira walked in." → Mira starts the sentence, so it does not count as a name. The match is capped at half credit.
  3. "i told mira already" → lowercase, not a name, capped.
  4. A Korean name never counts as a name, because Hangul has no capitals.

Steps to reproduce

  1. Create a character memory titled "Mira" with the keyword mira, and nothing else in common with the chat.
  2. Use the default balanced style with debug logging on.
  3. Send "Then Mira walked in." and then "Mira walked in." The keyword lane score in the Debug tab is halved on the second turn.

Environment

  • Marinara Engine version: 2.5.0 line (package range >=2.4.1 <4.0.0)
  • Package version: long-term-memory 1.4.30 (upstream/staging a468f18e6)
  • Install type: source (code reading plus a private evaluation running the package's real retrieval code)
  • OS + version: not platform-specific
  • Browser or app shell: any

Logs, screenshots, or video

Evaluation context (aggregate only; the evaluation uses a real vault):

  • In the evaluation behind #1360, the blind holdout set has low baseline essential recall: .326 on short windows and .209 on long ones.
  • An exploratory entity-seeding rule (not shipped) raised holdout F1 from .443 to .622 on short windows and from .321 to .529 on long ones. Its gain came from names in the window matching memory text, not from stored links.
  • The same rule lost precision on the other two sets and raised off-topic injections, because it seeded every memory that mentions the name.
  • The minimal fix below takes only the name signal, as keyword credit, and seeds nothing. Whether it keeps the holdout gain is untested; step 4 measures it.

Additional context

Minimal fix:

  1. In retrieveLongTermMemory, build a set of known names from the allowed chunks whose noteType is character. Use each chunk's title in lowercase, plus each title word that is not a stop word and is at least 2 characters long.
  2. Pass the set to searchLtmKeywordIndex as an optional knownNames option. In the single-keyword cap (keyword-index.ts:212), a term in knownNames also keeps full credit.
  3. Add regressions beside the #1264 cases. A sentence-initial name, a lowercase name and a Korean name each keep full credit. A single ordinary keyword is still capped. A title word that is a stop word is ignored.
  4. Gate: rerun the #1360 evaluation (all three sets, short and long windows). Ship only if F1 rises and off-topic injections don't.

Known limits:

  • A character named after a common word, such as "Hope", gets full credit for that word everywhere. Stop-word filtering only covers the most common words.
  • Nicknames are not covered. Character aliases exist only in the host-backed subject catalog used during extraction (subject-identity.ts:48, :499), not on stored memories. Matching aliases is a follow-up.

Related: #1264 (single-keyword cap and name rule), #1360 (linked recall, which starts from the memories this improves).

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 13, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1363 Originally assigned to: @Promansis on GitHub. ## Summary Since #1264, a single ordinary keyword match gets half keyword credit, but a name keeps full credit. LTM decides what counts as a name only by capitalisation: a capitalised word that is not at the start of a sentence, quote or line. A character's name therefore loses name credit when the user starts a sentence with it, types in lowercase, or writes in a script without letter case, such as Korean. The vault already knows its characters' names, but recall doesn't use them. ## Affected package `long-term-memory` 1.4.30 (`upstream/staging` a468f18e6), under `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/`: - `keyword-index.ts`: `queryNameTerms` (lines 66-77), used by the single-keyword cap (lines 206-214) - `retrieval.ts:159`: the keyword search call - Tests: `tests/long-term-memory-index-keys.regression.ts:380-440` (the #1264 name cases) ## Expected behavior - A word or phrase in the recall window that matches a character memory's title, ignoring case, counts as a name wherever it appears: at the start of a sentence, in lowercase, or in a caseless script. - A single exact keyword match on such a name keeps full keyword credit, the same as a capitalised mid-sentence name does today. - Nothing else changes: no new lane, and no change to the threshold, BM25 or vector scoring. ## Actual behavior With a character memory titled "Mira" and the keyword `mira`: 1. "Then Mira walked in." → `Mira` is mid-sentence, so it counts as a name and keeps full credit. 2. "Mira walked in." → `Mira` starts the sentence, so it does not count as a name. The match is capped at half credit. 3. "i told mira already" → lowercase, not a name, capped. 4. A Korean name never counts as a name, because Hangul has no capitals. ## Steps to reproduce 1. Create a `character` memory titled "Mira" with the keyword `mira`, and nothing else in common with the chat. 2. Use the default `balanced` style with debug logging on. 3. Send "Then Mira walked in." and then "Mira walked in." The keyword lane score in the Debug tab is halved on the second turn. ## Environment - Marinara Engine version: 2.5.0 line (package range `>=2.4.1 <4.0.0`) - Package version: long-term-memory 1.4.30 (`upstream/staging` a468f18e6) - Install type: source (code reading plus a private evaluation running the package's real retrieval code) - OS + version: not platform-specific - Browser or app shell: any ## Logs, screenshots, or video **Evaluation context (aggregate only; the evaluation uses a real vault):** - In the evaluation behind #1360, the blind holdout set has low baseline essential recall: .326 on short windows and .209 on long ones. - An exploratory entity-seeding rule (not shipped) raised holdout F1 from .443 to .622 on short windows and from .321 to .529 on long ones. Its gain came from names in the window matching memory text, not from stored links. - The same rule lost precision on the other two sets and raised off-topic injections, because it seeded every memory that mentions the name. - The minimal fix below takes only the name signal, as keyword credit, and seeds nothing. Whether it keeps the holdout gain is untested; step 4 measures it. ## Additional context **Minimal fix:** 1. In `retrieveLongTermMemory`, build a set of known names from the allowed chunks whose `noteType` is `character`. Use each chunk's title in lowercase, plus each title word that is not a stop word and is at least 2 characters long. 2. Pass the set to `searchLtmKeywordIndex` as an optional `knownNames` option. In the single-keyword cap (`keyword-index.ts:212`), a term in `knownNames` also keeps full credit. 3. Add regressions beside the #1264 cases. A sentence-initial name, a lowercase name and a Korean name each keep full credit. A single ordinary keyword is still capped. A title word that is a stop word is ignored. 4. Gate: rerun the #1360 evaluation (all three sets, short and long windows). Ship only if F1 rises and off-topic injections don't. **Known limits:** - A character named after a common word, such as "Hope", gets full credit for that word everywhere. Stop-word filtering only covers the most common words. - Nicknames are not covered. Character aliases exist only in the host-backed subject catalog used during extraction (`subject-identity.ts:48`, `:499`), not on stored memories. Matching aliases is a follow-up. Related: #1264 (single-keyword cap and name rule), #1360 (linked recall, which starts from the memories this improves). ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:29:49 +07:00
  • closed this issue
  • added the
    bug
    label
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-Agents#694
No description provided.