[GH-ISSUE #1905] [Feature]: Long-Term Memory: one character note when a chat uses both a short and a full name #1818

Closed
opened 2026-11-07 16:36:52 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @Promansis on GitHub.

What problem does this solve?

When a chat calls the same side character "Preston" in one place and "Preston Farraday" in another, Long-Term Memory writes two character notes: one per name. Each note collects half of that character's facts, recall finds only the half whose name matches, and facts end up split or in conflict across the two.

This happens for characters LTM creates from the chat itself (characters that aren't a card or a persona). LTM already relates a short name to a card or persona with a longer name, and sends that match to review instead of making a new note. It doesn't do this for characters it created on its own, so each name form gets its own note.

It gets worse as pieces get smaller, because each piece is a new chance to see a different name form:

  • A 366-message roleplay chat imported as Chat messages, at the current 24k-character pieces (18 pieces): 1 short/full-name pair per vault.
  • The same chat at 12k-character pieces (38 pieces): 5–6 pairs per vault. Examples: Preston / Preston Farraday, Vivienne / Vivienne Farraday, Veliko / Veliko Kudelin, Marcus / Marcus Vance. An Opus judge found 8–10 groups of duplicate character notes per vault, and most of the wrong facts were in those split notes.
  • An earlier hand-labelled pass over imported memories (PL-1) found the same misses for Ash and Preston.

Smaller pieces add 60–80 real facts per vault in that test. So stopping these splits is what makes smaller pieces worth having.

Proposed package or change

When LTM resolves a character name from a new piece, it also relates that name to its own characters in the same chat by whole name parts, the way it already does for cards and personas:

  • "Preston" matches an existing "Preston Farraday", and "Preston Farraday" matches an existing "Preston". Both directions.
  • It matches only on whole name parts. "Ash" is not part of "Ashleigh Farraday", so the two stay apart (see Non-goals).
  • If exactly one of LTM's own characters in the chat matches, the name resolves to that character. The other name form is kept as an alias, so the next piece matches it directly.
  • If two or more match ("Farraday" against Preston, Vivienne and Ashleigh Farraday), nothing is bound. The name goes to review, as a short name for a card does today.
  • Cards and personas keep today's behaviour exactly.

Before / after, for two pieces of one chat:

Piece 1 says Piece 2 says Today After
Unique Preston Farraday Preston two notes one note, alias "Preston"
Shared family name Preston Farraday, Vivienne Farraday Farraday new "Farraday" note review, no new note
Two people, same first name Preston Farraday, Preston Hale Preston new "Preston" note review, no new note

Why a unique match binds on its own instead of going to review: both notes are LTM's own guesses from the same chat, so no card or persona is at stake. Sending each one to review would hold back every split fact in a whole-chat import until the user reviews it, and there would be dozens. The ambiguous cases still fail closed.

Minimal fix

Under packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/identity/:

  • subject-matching.ts
    • matchTrustedNameRelation (~150) and partialNameCandidateEntries (~118) only consider entries that are an exact/alias match or pass isTrustedCharacterOrPersonaSubject (~110). Add LTM's own character entries in the same chat family (familyId set, sourceScope local_note or local_source) as candidates:
      • one match → a new basis (for example local_name_relation), matched;
      • several → ambiguous, with the same identityReview the trusted case builds.
    • Trusted card/persona entries keep partial_name_requires_review, and a trusted match outranks a local one.
  • subject-names.ts
    • partialNameTokensMatch (~203) checks only short-name-to-longer-entry. The local relation also needs the reverse (a longer new name to a shorter existing entry), using the same whole-token rule.
  • subject-identity.ts
    • preResolveBatchSubjectNames (~808) and resolveAndCacheSubjectName (~915) already call matchTrustedNameRelation for names that aren't known. Check that the new basis flows through them, and that names in the same batch ("Preston" and "Preston Farraday" both new in one piece) relate before provisional entries are made, which is the batch_provisional_duplicate path (~958).
    • Record the matched name form as an alias on the resolved character, so later pieces hit matchDirect instead of the relation.
  • subject-catalog.ts
    • Saved local notes enter the catalog at ~292 with familyId and sourceScope: "local_note"; nothing to change there.
    • mutableHasRelatedIdentity (~556) keeps short source-note names from creating a duplicate of a trusted subject. Extend it to local entries in the same family the same way, so source-note names and extracted names follow one rule.

Regression: extend the table of short-name cases (#1291) in tests/long-term-memory-extraction-graph.regression.ts (~3384), which already builds a catalog and resolves one named unit:

  1. A saved local "Preston Farraday" plus a new "Preston" resolves to the saved key, with no dropped candidate.
  2. The reverse, a saved local "Preston" plus a new "Preston Farraday", resolves to the saved key.
  3. Both forms new in one batch give one local key.
  4. A saved "Preston Farraday" and "Vivienne Farraday" plus a new "Farraday": no new key, and a review diagnostic.
  5. A saved "Preston Farraday" and "Preston Hale" plus a new "Preston": no new key, and a review diagnostic.
  6. A local character from another chat is never matched (the existing "out-of-scope local donor" case covers the borrowing path; add the relation path).
  7. A card "Ashleigh Farraday" plus a new "Ash" behaves as today (local "Ash" note), and a card "Ashleigh Farraday" plus a new "Ashleigh" still goes to partial_name_requires_review.
  8. Prediction (identityKeyForUnit) and resolution agree for cases 1–3, as the borrowing tests already check.

Non-goals

  • Nicknames that aren't a whole name part ("Ash" for "Ashleigh", "Liz" for "Elizabeth"). Matching by prefix would join different people. A card's aliases or nicknames field already covers a card character, and it is read today (subject-catalog.ts extractAliases).
  • Merging notes that are already split in an existing vault. This change stops new splits. Repairing old ones is a separate repair pass.
  • Signals for world notes or other kinds of notes (the rest of EX-I10).
  • Changing the Chat messages piece size. That is measured separately once this lands.

Why should this be optional?

It shouldn't be a setting. It only joins LTM's own characters when exactly one fits on whole name parts, and anything less certain goes to review. A setting would mostly leave users with duplicate notes they didn't choose.

Alternatives considered

  • Tell the model the names of LTM's own characters in the extraction prompt, and let it copy the full name. The catalog prompt already lists names, but the model still writes the form the piece uses. The server has to relate them anyway, and it can fail closed where the model can't.
  • Send every local short/full-name match to review. Safe, but a whole-chat import would hold back dozens of facts for review. Rejected for unique matches. Ambiguous matches still go to review.
  • Fuzzy or prefix matching. Joins different people. Rejected; see Non-goals.

Additional context

  • The measurement harness treated the user's persona as a side character (it had no persona list), so the "Damo / Damo Korvak" pair it found may not happen in real use: a persona's short name already relates to its full name today. The other pairs are side characters and don't depend on that.
  • Damo's two conflicting backstories in the 12k run come from two kept swipes, which are separate from this change.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1905 Originally assigned to: @Promansis on GitHub. ## What problem does this solve? When a chat calls the same side character "Preston" in one place and "Preston Farraday" in another, Long-Term Memory writes two character notes: one per name. Each note collects half of that character's facts, recall finds only the half whose name matches, and facts end up split or in conflict across the two. This happens for characters LTM creates from the chat itself (characters that aren't a card or a persona). LTM already relates a short name to a **card or persona** with a longer name, and sends that match to review instead of making a new note. It doesn't do this for characters it created on its own, so each name form gets its own note. It gets worse as pieces get smaller, because each piece is a new chance to see a different name form: - A 366-message roleplay chat imported as Chat messages, at the current 24k-character pieces (18 pieces): 1 short/full-name pair per vault. - The same chat at 12k-character pieces (38 pieces): 5–6 pairs per vault. Examples: Preston / Preston Farraday, Vivienne / Vivienne Farraday, Veliko / Veliko Kudelin, Marcus / Marcus Vance. An Opus judge found 8–10 groups of duplicate character notes per vault, and most of the wrong facts were in those split notes. - An earlier hand-labelled pass over imported memories (PL-1) found the same misses for Ash and Preston. Smaller pieces add 60–80 real facts per vault in that test. So stopping these splits is what makes smaller pieces worth having. ## Proposed package or change When LTM resolves a character name from a new piece, it also relates that name to **its own characters in the same chat** by whole name parts, the way it already does for cards and personas: - "Preston" matches an existing "Preston Farraday", and "Preston Farraday" matches an existing "Preston". Both directions. - It matches only on **whole name parts**. "Ash" is not part of "Ashleigh Farraday", so the two stay apart (see Non-goals). - If **exactly one** of LTM's own characters in the chat matches, the name resolves to that character. The other name form is kept as an alias, so the next piece matches it directly. - If **two or more** match ("Farraday" against Preston, Vivienne and Ashleigh Farraday), nothing is bound. The name goes to review, as a short name for a card does today. - Cards and personas keep today's behaviour exactly. Before / after, for two pieces of one chat: | | Piece 1 says | Piece 2 says | Today | After | |---|---|---|---|---| | Unique | Preston Farraday | Preston | two notes | one note, alias "Preston" | | Shared family name | Preston Farraday, Vivienne Farraday | Farraday | new "Farraday" note | review, no new note | | Two people, same first name | Preston Farraday, Preston Hale | Preston | new "Preston" note | review, no new note | **Why a unique match binds on its own instead of going to review:** both notes are LTM's own guesses from the same chat, so no card or persona is at stake. Sending each one to review would hold back every split fact in a whole-chat import until the user reviews it, and there would be dozens. The ambiguous cases still fail closed. ### Minimal fix Under `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/identity/`: - `subject-matching.ts` - `matchTrustedNameRelation` (~150) and `partialNameCandidateEntries` (~118) only consider entries that are an exact/alias match or pass `isTrustedCharacterOrPersonaSubject` (~110). Add LTM's own character entries in the same chat family (`familyId` set, `sourceScope` `local_note` or `local_source`) as candidates: - one match → a new basis (for example `local_name_relation`), matched; - several → ambiguous, with the same `identityReview` the trusted case builds. - Trusted card/persona entries keep `partial_name_requires_review`, and a trusted match outranks a local one. - `subject-names.ts` - `partialNameTokensMatch` (~203) checks only short-name-to-longer-entry. The local relation also needs the reverse (a longer new name to a shorter existing entry), using the same whole-token rule. - `subject-identity.ts` - `preResolveBatchSubjectNames` (~808) and `resolveAndCacheSubjectName` (~915) already call `matchTrustedNameRelation` for names that aren't known. Check that the new basis flows through them, and that names in the **same batch** ("Preston" and "Preston Farraday" both new in one piece) relate before provisional entries are made, which is the `batch_provisional_duplicate` path (~958). - Record the matched name form as an alias on the resolved character, so later pieces hit `matchDirect` instead of the relation. - `subject-catalog.ts` - Saved local notes enter the catalog at ~292 with `familyId` and `sourceScope: "local_note"`; nothing to change there. - `mutableHasRelatedIdentity` (~556) keeps short source-note names from creating a duplicate of a **trusted** subject. Extend it to local entries in the same family the same way, so source-note names and extracted names follow one rule. Regression: extend the table of short-name cases (#1291) in `tests/long-term-memory-extraction-graph.regression.ts` (~3384), which already builds a catalog and resolves one named unit: 1. A saved local "Preston Farraday" plus a new "Preston" resolves to the saved key, with no dropped candidate. 2. The reverse, a saved local "Preston" plus a new "Preston Farraday", resolves to the saved key. 3. Both forms new in one batch give one local key. 4. A saved "Preston Farraday" and "Vivienne Farraday" plus a new "Farraday": no new key, and a review diagnostic. 5. A saved "Preston Farraday" and "Preston Hale" plus a new "Preston": no new key, and a review diagnostic. 6. A local character from another chat is never matched (the existing "out-of-scope local donor" case covers the borrowing path; add the relation path). 7. A card "Ashleigh Farraday" plus a new "Ash" behaves as today (local "Ash" note), and a card "Ashleigh Farraday" plus a new "Ashleigh" still goes to `partial_name_requires_review`. 8. Prediction (`identityKeyForUnit`) and resolution agree for cases 1–3, as the borrowing tests already check. ### Non-goals - **Nicknames that aren't a whole name part** ("Ash" for "Ashleigh", "Liz" for "Elizabeth"). Matching by prefix would join different people. A card's `aliases` or `nicknames` field already covers a card character, and it is read today (`subject-catalog.ts` `extractAliases`). - Merging notes that are already split in an existing vault. This change stops new splits. Repairing old ones is a separate repair pass. - Signals for world notes or other kinds of notes (the rest of EX-I10). - Changing the Chat messages piece size. That is measured separately once this lands. ## Why should this be optional? It shouldn't be a setting. It only joins LTM's own characters when exactly one fits on whole name parts, and anything less certain goes to review. A setting would mostly leave users with duplicate notes they didn't choose. ## Alternatives considered - **Tell the model the names of LTM's own characters in the extraction prompt, and let it copy the full name.** The catalog prompt already lists names, but the model still writes the form the piece uses. The server has to relate them anyway, and it can fail closed where the model can't. - **Send every local short/full-name match to review.** Safe, but a whole-chat import would hold back dozens of facts for review. Rejected for unique matches. Ambiguous matches still go to review. - **Fuzzy or prefix matching.** Joins different people. Rejected; see Non-goals. ## Additional context - The measurement harness treated the user's persona as a side character (it had no persona list), so the "Damo / Damo Korvak" pair it found may not happen in real use: a persona's short name already relates to its full name today. The other pairs are side characters and don't depend on that. - Damo's two conflicting backstories in the 12k run come from two kept swipes, which are separate from this change. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-11-07 16:36:52 +07:00
Author
Owner

@Promansis commented on GitHub (Oct 30, 2026):

Fixed by #1909, merged to staging as a5acc6329.

<!-- gh-comment-id:6513435095 --> @Promansis commented on GitHub (Oct 30, 2026): Fixed by #1909, merged to staging as a5acc6329.
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#1818
No description provided.